babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137
  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 Vector3 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/Misc/performanceMonitor" {
  5234. /**
  5235. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5236. */
  5237. export class PerformanceMonitor {
  5238. private _enabled;
  5239. private _rollingFrameTime;
  5240. private _lastFrameTimeMs;
  5241. /**
  5242. * constructor
  5243. * @param frameSampleSize The number of samples required to saturate the sliding window
  5244. */
  5245. constructor(frameSampleSize?: number);
  5246. /**
  5247. * Samples current frame
  5248. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5249. */
  5250. sampleFrame(timeMs?: number): void;
  5251. /**
  5252. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5253. */
  5254. readonly averageFrameTime: number;
  5255. /**
  5256. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5257. */
  5258. readonly averageFrameTimeVariance: number;
  5259. /**
  5260. * Returns the frame time of the most recent frame
  5261. */
  5262. readonly instantaneousFrameTime: number;
  5263. /**
  5264. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5265. */
  5266. readonly averageFPS: number;
  5267. /**
  5268. * Returns the average framerate in frames per second using the most recent frame time
  5269. */
  5270. readonly instantaneousFPS: number;
  5271. /**
  5272. * Returns true if enough samples have been taken to completely fill the sliding window
  5273. */
  5274. readonly isSaturated: boolean;
  5275. /**
  5276. * Enables contributions to the sliding window sample set
  5277. */
  5278. enable(): void;
  5279. /**
  5280. * Disables contributions to the sliding window sample set
  5281. * Samples will not be interpolated over the disabled period
  5282. */
  5283. disable(): void;
  5284. /**
  5285. * Returns true if sampling is enabled
  5286. */
  5287. readonly isEnabled: boolean;
  5288. /**
  5289. * Resets performance monitor
  5290. */
  5291. reset(): void;
  5292. }
  5293. /**
  5294. * RollingAverage
  5295. *
  5296. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5297. */
  5298. export class RollingAverage {
  5299. /**
  5300. * Current average
  5301. */
  5302. average: number;
  5303. /**
  5304. * Current variance
  5305. */
  5306. variance: number;
  5307. protected _samples: Array<number>;
  5308. protected _sampleCount: number;
  5309. protected _pos: number;
  5310. protected _m2: number;
  5311. /**
  5312. * constructor
  5313. * @param length The number of samples required to saturate the sliding window
  5314. */
  5315. constructor(length: number);
  5316. /**
  5317. * Adds a sample to the sample set
  5318. * @param v The sample value
  5319. */
  5320. add(v: number): void;
  5321. /**
  5322. * Returns previously added values or null if outside of history or outside the sliding window domain
  5323. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5324. * @return Value previously recorded with add() or null if outside of range
  5325. */
  5326. history(i: number): number;
  5327. /**
  5328. * Returns true if enough samples have been taken to completely fill the sliding window
  5329. * @return true if sample-set saturated
  5330. */
  5331. isSaturated(): boolean;
  5332. /**
  5333. * Resets the rolling average (equivalent to 0 samples taken so far)
  5334. */
  5335. reset(): void;
  5336. /**
  5337. * Wraps a value around the sample range boundaries
  5338. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5339. * @return Wrapped position in sample range
  5340. */
  5341. protected _wrapPosition(i: number): number;
  5342. }
  5343. }
  5344. declare module "babylonjs/Misc/stringDictionary" {
  5345. import { Nullable } from "babylonjs/types";
  5346. /**
  5347. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5348. * The underlying implementation relies on an associative array to ensure the best performances.
  5349. * The value can be anything including 'null' but except 'undefined'
  5350. */
  5351. export class StringDictionary<T> {
  5352. /**
  5353. * This will clear this dictionary and copy the content from the 'source' one.
  5354. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5355. * @param source the dictionary to take the content from and copy to this dictionary
  5356. */
  5357. copyFrom(source: StringDictionary<T>): void;
  5358. /**
  5359. * Get a value based from its key
  5360. * @param key the given key to get the matching value from
  5361. * @return the value if found, otherwise undefined is returned
  5362. */
  5363. get(key: string): T | undefined;
  5364. /**
  5365. * Get a value from its key or add it if it doesn't exist.
  5366. * This method will ensure you that a given key/data will be present in the dictionary.
  5367. * @param key the given key to get the matching value from
  5368. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5369. * The factory will only be invoked if there's no data for the given key.
  5370. * @return the value corresponding to the key.
  5371. */
  5372. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5373. /**
  5374. * Get a value from its key if present in the dictionary otherwise add it
  5375. * @param key the key to get the value from
  5376. * @param val if there's no such key/value pair in the dictionary add it with this value
  5377. * @return the value corresponding to the key
  5378. */
  5379. getOrAdd(key: string, val: T): T;
  5380. /**
  5381. * Check if there's a given key in the dictionary
  5382. * @param key the key to check for
  5383. * @return true if the key is present, false otherwise
  5384. */
  5385. contains(key: string): boolean;
  5386. /**
  5387. * Add a new key and its corresponding value
  5388. * @param key the key to add
  5389. * @param value the value corresponding to the key
  5390. * @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
  5391. */
  5392. add(key: string, value: T): boolean;
  5393. /**
  5394. * Update a specific value associated to a key
  5395. * @param key defines the key to use
  5396. * @param value defines the value to store
  5397. * @returns true if the value was updated (or false if the key was not found)
  5398. */
  5399. set(key: string, value: T): boolean;
  5400. /**
  5401. * Get the element of the given key and remove it from the dictionary
  5402. * @param key defines the key to search
  5403. * @returns the value associated with the key or null if not found
  5404. */
  5405. getAndRemove(key: string): Nullable<T>;
  5406. /**
  5407. * Remove a key/value from the dictionary.
  5408. * @param key the key to remove
  5409. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5410. */
  5411. remove(key: string): boolean;
  5412. /**
  5413. * Clear the whole content of the dictionary
  5414. */
  5415. clear(): void;
  5416. /**
  5417. * Gets the current count
  5418. */
  5419. readonly count: number;
  5420. /**
  5421. * Execute a callback on each key/val of the dictionary.
  5422. * Note that you can remove any element in this dictionary in the callback implementation
  5423. * @param callback the callback to execute on a given key/value pair
  5424. */
  5425. forEach(callback: (key: string, val: T) => void): void;
  5426. /**
  5427. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5428. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5429. * Note that you can remove any element in this dictionary in the callback implementation
  5430. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5431. * @returns the first item
  5432. */
  5433. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5434. private _count;
  5435. private _data;
  5436. }
  5437. }
  5438. declare module "babylonjs/Misc/promise" {
  5439. /**
  5440. * Helper class that provides a small promise polyfill
  5441. */
  5442. export class PromisePolyfill {
  5443. /**
  5444. * Static function used to check if the polyfill is required
  5445. * If this is the case then the function will inject the polyfill to window.Promise
  5446. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5447. */
  5448. static Apply(force?: boolean): void;
  5449. }
  5450. }
  5451. declare module "babylonjs/Meshes/buffer" {
  5452. import { Nullable, DataArray } from "babylonjs/types";
  5453. /**
  5454. * Class used to store data that will be store in GPU memory
  5455. */
  5456. export class Buffer {
  5457. private _engine;
  5458. private _buffer;
  5459. /** @hidden */
  5460. _data: Nullable<DataArray>;
  5461. private _updatable;
  5462. private _instanced;
  5463. /**
  5464. * Gets the byte stride.
  5465. */
  5466. readonly byteStride: number;
  5467. /**
  5468. * Constructor
  5469. * @param engine the engine
  5470. * @param data the data to use for this buffer
  5471. * @param updatable whether the data is updatable
  5472. * @param stride the stride (optional)
  5473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5474. * @param instanced whether the buffer is instanced (optional)
  5475. * @param useBytes set to true if the stride in in bytes (optional)
  5476. */
  5477. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5478. /**
  5479. * Create a new VertexBuffer based on the current buffer
  5480. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5481. * @param offset defines offset in the buffer (0 by default)
  5482. * @param size defines the size in floats of attributes (position is 3 for instance)
  5483. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5484. * @param instanced defines if the vertex buffer contains indexed data
  5485. * @param useBytes defines if the offset and stride are in bytes
  5486. * @returns the new vertex buffer
  5487. */
  5488. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5489. /**
  5490. * Gets a boolean indicating if the Buffer is updatable?
  5491. * @returns true if the buffer is updatable
  5492. */
  5493. isUpdatable(): boolean;
  5494. /**
  5495. * Gets current buffer's data
  5496. * @returns a DataArray or null
  5497. */
  5498. getData(): Nullable<DataArray>;
  5499. /**
  5500. * Gets underlying native buffer
  5501. * @returns underlying native buffer
  5502. */
  5503. getBuffer(): Nullable<WebGLBuffer>;
  5504. /**
  5505. * Gets the stride in float32 units (i.e. byte stride / 4).
  5506. * May not be an integer if the byte stride is not divisible by 4.
  5507. * DEPRECATED. Use byteStride instead.
  5508. * @returns the stride in float32 units
  5509. */
  5510. getStrideSize(): number;
  5511. /**
  5512. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5513. * @param data defines the data to store
  5514. */
  5515. create(data?: Nullable<DataArray>): void;
  5516. /** @hidden */
  5517. _rebuild(): void;
  5518. /**
  5519. * Update current buffer data
  5520. * @param data defines the data to store
  5521. */
  5522. update(data: DataArray): void;
  5523. /**
  5524. * Updates the data directly.
  5525. * @param data the new data
  5526. * @param offset the new offset
  5527. * @param vertexCount the vertex count (optional)
  5528. * @param useBytes set to true if the offset is in bytes
  5529. */
  5530. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5531. /**
  5532. * Release all resources
  5533. */
  5534. dispose(): void;
  5535. }
  5536. /**
  5537. * Specialized buffer used to store vertex data
  5538. */
  5539. export class VertexBuffer {
  5540. /** @hidden */
  5541. _buffer: Buffer;
  5542. private _kind;
  5543. private _size;
  5544. private _ownsBuffer;
  5545. private _instanced;
  5546. private _instanceDivisor;
  5547. /**
  5548. * The byte type.
  5549. */
  5550. static readonly BYTE: number;
  5551. /**
  5552. * The unsigned byte type.
  5553. */
  5554. static readonly UNSIGNED_BYTE: number;
  5555. /**
  5556. * The short type.
  5557. */
  5558. static readonly SHORT: number;
  5559. /**
  5560. * The unsigned short type.
  5561. */
  5562. static readonly UNSIGNED_SHORT: number;
  5563. /**
  5564. * The integer type.
  5565. */
  5566. static readonly INT: number;
  5567. /**
  5568. * The unsigned integer type.
  5569. */
  5570. static readonly UNSIGNED_INT: number;
  5571. /**
  5572. * The float type.
  5573. */
  5574. static readonly FLOAT: number;
  5575. /**
  5576. * Gets or sets the instance divisor when in instanced mode
  5577. */
  5578. instanceDivisor: number;
  5579. /**
  5580. * Gets the byte stride.
  5581. */
  5582. readonly byteStride: number;
  5583. /**
  5584. * Gets the byte offset.
  5585. */
  5586. readonly byteOffset: number;
  5587. /**
  5588. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5589. */
  5590. readonly normalized: boolean;
  5591. /**
  5592. * Gets the data type of each component in the array.
  5593. */
  5594. readonly type: number;
  5595. /**
  5596. * Constructor
  5597. * @param engine the engine
  5598. * @param data the data to use for this vertex buffer
  5599. * @param kind the vertex buffer kind
  5600. * @param updatable whether the data is updatable
  5601. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5602. * @param stride the stride (optional)
  5603. * @param instanced whether the buffer is instanced (optional)
  5604. * @param offset the offset of the data (optional)
  5605. * @param size the number of components (optional)
  5606. * @param type the type of the component (optional)
  5607. * @param normalized whether the data contains normalized data (optional)
  5608. * @param useBytes set to true if stride and offset are in bytes (optional)
  5609. */
  5610. 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);
  5611. /** @hidden */
  5612. _rebuild(): void;
  5613. /**
  5614. * Returns the kind of the VertexBuffer (string)
  5615. * @returns a string
  5616. */
  5617. getKind(): string;
  5618. /**
  5619. * Gets a boolean indicating if the VertexBuffer is updatable?
  5620. * @returns true if the buffer is updatable
  5621. */
  5622. isUpdatable(): boolean;
  5623. /**
  5624. * Gets current buffer's data
  5625. * @returns a DataArray or null
  5626. */
  5627. getData(): Nullable<DataArray>;
  5628. /**
  5629. * Gets underlying native buffer
  5630. * @returns underlying native buffer
  5631. */
  5632. getBuffer(): Nullable<WebGLBuffer>;
  5633. /**
  5634. * Gets the stride in float32 units (i.e. byte stride / 4).
  5635. * May not be an integer if the byte stride is not divisible by 4.
  5636. * DEPRECATED. Use byteStride instead.
  5637. * @returns the stride in float32 units
  5638. */
  5639. getStrideSize(): number;
  5640. /**
  5641. * Returns the offset as a multiple of the type byte length.
  5642. * DEPRECATED. Use byteOffset instead.
  5643. * @returns the offset in bytes
  5644. */
  5645. getOffset(): number;
  5646. /**
  5647. * Returns the number of components per vertex attribute (integer)
  5648. * @returns the size in float
  5649. */
  5650. getSize(): number;
  5651. /**
  5652. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5653. * @returns true if this buffer is instanced
  5654. */
  5655. getIsInstanced(): boolean;
  5656. /**
  5657. * Returns the instancing divisor, zero for non-instanced (integer).
  5658. * @returns a number
  5659. */
  5660. getInstanceDivisor(): number;
  5661. /**
  5662. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5663. * @param data defines the data to store
  5664. */
  5665. create(data?: DataArray): void;
  5666. /**
  5667. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5668. * This function will create a new buffer if the current one is not updatable
  5669. * @param data defines the data to store
  5670. */
  5671. update(data: DataArray): void;
  5672. /**
  5673. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5674. * Returns the directly updated WebGLBuffer.
  5675. * @param data the new data
  5676. * @param offset the new offset
  5677. * @param useBytes set to true if the offset is in bytes
  5678. */
  5679. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5680. /**
  5681. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5682. */
  5683. dispose(): void;
  5684. /**
  5685. * Enumerates each value of this vertex buffer as numbers.
  5686. * @param count the number of values to enumerate
  5687. * @param callback the callback function called for each value
  5688. */
  5689. forEach(count: number, callback: (value: number, index: number) => void): void;
  5690. /**
  5691. * Positions
  5692. */
  5693. static readonly PositionKind: string;
  5694. /**
  5695. * Normals
  5696. */
  5697. static readonly NormalKind: string;
  5698. /**
  5699. * Tangents
  5700. */
  5701. static readonly TangentKind: string;
  5702. /**
  5703. * Texture coordinates
  5704. */
  5705. static readonly UVKind: string;
  5706. /**
  5707. * Texture coordinates 2
  5708. */
  5709. static readonly UV2Kind: string;
  5710. /**
  5711. * Texture coordinates 3
  5712. */
  5713. static readonly UV3Kind: string;
  5714. /**
  5715. * Texture coordinates 4
  5716. */
  5717. static readonly UV4Kind: string;
  5718. /**
  5719. * Texture coordinates 5
  5720. */
  5721. static readonly UV5Kind: string;
  5722. /**
  5723. * Texture coordinates 6
  5724. */
  5725. static readonly UV6Kind: string;
  5726. /**
  5727. * Colors
  5728. */
  5729. static readonly ColorKind: string;
  5730. /**
  5731. * Matrix indices (for bones)
  5732. */
  5733. static readonly MatricesIndicesKind: string;
  5734. /**
  5735. * Matrix weights (for bones)
  5736. */
  5737. static readonly MatricesWeightsKind: string;
  5738. /**
  5739. * Additional matrix indices (for bones)
  5740. */
  5741. static readonly MatricesIndicesExtraKind: string;
  5742. /**
  5743. * Additional matrix weights (for bones)
  5744. */
  5745. static readonly MatricesWeightsExtraKind: string;
  5746. /**
  5747. * Deduces the stride given a kind.
  5748. * @param kind The kind string to deduce
  5749. * @returns The deduced stride
  5750. */
  5751. static DeduceStride(kind: string): number;
  5752. /**
  5753. * Gets the byte length of the given type.
  5754. * @param type the type
  5755. * @returns the number of bytes
  5756. */
  5757. static GetTypeByteLength(type: number): number;
  5758. /**
  5759. * Enumerates each value of the given parameters as numbers.
  5760. * @param data the data to enumerate
  5761. * @param byteOffset the byte offset of the data
  5762. * @param byteStride the byte stride of the data
  5763. * @param componentCount the number of components per element
  5764. * @param componentType the type of the component
  5765. * @param count the total number of components
  5766. * @param normalized whether the data is normalized
  5767. * @param callback the callback function called for each value
  5768. */
  5769. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5770. private static _GetFloatValue;
  5771. }
  5772. }
  5773. declare module "babylonjs/Maths/sphericalPolynomial" {
  5774. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5775. /**
  5776. * Class representing spherical polynomial coefficients to the 3rd degree
  5777. */
  5778. export class SphericalPolynomial {
  5779. /**
  5780. * The x coefficients of the spherical polynomial
  5781. */
  5782. x: Vector3;
  5783. /**
  5784. * The y coefficients of the spherical polynomial
  5785. */
  5786. y: Vector3;
  5787. /**
  5788. * The z coefficients of the spherical polynomial
  5789. */
  5790. z: Vector3;
  5791. /**
  5792. * The xx coefficients of the spherical polynomial
  5793. */
  5794. xx: Vector3;
  5795. /**
  5796. * The yy coefficients of the spherical polynomial
  5797. */
  5798. yy: Vector3;
  5799. /**
  5800. * The zz coefficients of the spherical polynomial
  5801. */
  5802. zz: Vector3;
  5803. /**
  5804. * The xy coefficients of the spherical polynomial
  5805. */
  5806. xy: Vector3;
  5807. /**
  5808. * The yz coefficients of the spherical polynomial
  5809. */
  5810. yz: Vector3;
  5811. /**
  5812. * The zx coefficients of the spherical polynomial
  5813. */
  5814. zx: Vector3;
  5815. /**
  5816. * Adds an ambient color to the spherical polynomial
  5817. * @param color the color to add
  5818. */
  5819. addAmbient(color: Color3): void;
  5820. /**
  5821. * Scales the spherical polynomial by the given amount
  5822. * @param scale the amount to scale
  5823. */
  5824. scale(scale: number): void;
  5825. /**
  5826. * Gets the spherical polynomial from harmonics
  5827. * @param harmonics the spherical harmonics
  5828. * @returns the spherical polynomial
  5829. */
  5830. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5831. /**
  5832. * Constructs a spherical polynomial from an array.
  5833. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5834. * @returns the spherical polynomial
  5835. */
  5836. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5837. }
  5838. /**
  5839. * Class representing spherical harmonics coefficients to the 3rd degree
  5840. */
  5841. export class SphericalHarmonics {
  5842. /**
  5843. * The l0,0 coefficients of the spherical harmonics
  5844. */
  5845. l00: Vector3;
  5846. /**
  5847. * The l1,-1 coefficients of the spherical harmonics
  5848. */
  5849. l1_1: Vector3;
  5850. /**
  5851. * The l1,0 coefficients of the spherical harmonics
  5852. */
  5853. l10: Vector3;
  5854. /**
  5855. * The l1,1 coefficients of the spherical harmonics
  5856. */
  5857. l11: Vector3;
  5858. /**
  5859. * The l2,-2 coefficients of the spherical harmonics
  5860. */
  5861. l2_2: Vector3;
  5862. /**
  5863. * The l2,-1 coefficients of the spherical harmonics
  5864. */
  5865. l2_1: Vector3;
  5866. /**
  5867. * The l2,0 coefficients of the spherical harmonics
  5868. */
  5869. l20: Vector3;
  5870. /**
  5871. * The l2,1 coefficients of the spherical harmonics
  5872. */
  5873. l21: Vector3;
  5874. /**
  5875. * The l2,2 coefficients of the spherical harmonics
  5876. */
  5877. lL22: Vector3;
  5878. /**
  5879. * Adds a light to the spherical harmonics
  5880. * @param direction the direction of the light
  5881. * @param color the color of the light
  5882. * @param deltaSolidAngle the delta solid angle of the light
  5883. */
  5884. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5885. /**
  5886. * Scales the spherical harmonics by the given amount
  5887. * @param scale the amount to scale
  5888. */
  5889. scale(scale: number): void;
  5890. /**
  5891. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5892. *
  5893. * ```
  5894. * E_lm = A_l * L_lm
  5895. * ```
  5896. *
  5897. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5898. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5899. * the scaling factors are given in equation 9.
  5900. */
  5901. convertIncidentRadianceToIrradiance(): void;
  5902. /**
  5903. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5904. *
  5905. * ```
  5906. * L = (1/pi) * E * rho
  5907. * ```
  5908. *
  5909. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5910. */
  5911. convertIrradianceToLambertianRadiance(): void;
  5912. /**
  5913. * Gets the spherical harmonics from polynomial
  5914. * @param polynomial the spherical polynomial
  5915. * @returns the spherical harmonics
  5916. */
  5917. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5918. /**
  5919. * Constructs a spherical harmonics from an array.
  5920. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5921. * @returns the spherical harmonics
  5922. */
  5923. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5924. }
  5925. }
  5926. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5927. import { Nullable } from "babylonjs/types";
  5928. /**
  5929. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5930. */
  5931. export interface CubeMapInfo {
  5932. /**
  5933. * The pixel array for the front face.
  5934. * This is stored in format, left to right, up to down format.
  5935. */
  5936. front: Nullable<ArrayBufferView>;
  5937. /**
  5938. * The pixel array for the back face.
  5939. * This is stored in format, left to right, up to down format.
  5940. */
  5941. back: Nullable<ArrayBufferView>;
  5942. /**
  5943. * The pixel array for the left face.
  5944. * This is stored in format, left to right, up to down format.
  5945. */
  5946. left: Nullable<ArrayBufferView>;
  5947. /**
  5948. * The pixel array for the right face.
  5949. * This is stored in format, left to right, up to down format.
  5950. */
  5951. right: Nullable<ArrayBufferView>;
  5952. /**
  5953. * The pixel array for the up face.
  5954. * This is stored in format, left to right, up to down format.
  5955. */
  5956. up: Nullable<ArrayBufferView>;
  5957. /**
  5958. * The pixel array for the down face.
  5959. * This is stored in format, left to right, up to down format.
  5960. */
  5961. down: Nullable<ArrayBufferView>;
  5962. /**
  5963. * The size of the cubemap stored.
  5964. *
  5965. * Each faces will be size * size pixels.
  5966. */
  5967. size: number;
  5968. /**
  5969. * The format of the texture.
  5970. *
  5971. * RGBA, RGB.
  5972. */
  5973. format: number;
  5974. /**
  5975. * The type of the texture data.
  5976. *
  5977. * UNSIGNED_INT, FLOAT.
  5978. */
  5979. type: number;
  5980. /**
  5981. * Specifies whether the texture is in gamma space.
  5982. */
  5983. gammaSpace: boolean;
  5984. }
  5985. /**
  5986. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5987. */
  5988. export class PanoramaToCubeMapTools {
  5989. private static FACE_FRONT;
  5990. private static FACE_BACK;
  5991. private static FACE_RIGHT;
  5992. private static FACE_LEFT;
  5993. private static FACE_DOWN;
  5994. private static FACE_UP;
  5995. /**
  5996. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5997. *
  5998. * @param float32Array The source data.
  5999. * @param inputWidth The width of the input panorama.
  6000. * @param inputHeight The height of the input panorama.
  6001. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6002. * @return The cubemap data
  6003. */
  6004. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6005. private static CreateCubemapTexture;
  6006. private static CalcProjectionSpherical;
  6007. }
  6008. }
  6009. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6010. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6012. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6013. /**
  6014. * Helper class dealing with the extraction of spherical polynomial dataArray
  6015. * from a cube map.
  6016. */
  6017. export class CubeMapToSphericalPolynomialTools {
  6018. private static FileFaces;
  6019. /**
  6020. * Converts a texture to the according Spherical Polynomial data.
  6021. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6022. *
  6023. * @param texture The texture to extract the information from.
  6024. * @return The Spherical Polynomial data.
  6025. */
  6026. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6027. /**
  6028. * Converts a cubemap to the according Spherical Polynomial data.
  6029. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6030. *
  6031. * @param cubeInfo The Cube map to extract the information from.
  6032. * @return The Spherical Polynomial data.
  6033. */
  6034. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6035. }
  6036. }
  6037. declare module "babylonjs/Engines/engineStore" {
  6038. import { Nullable } from "babylonjs/types";
  6039. import { Engine } from "babylonjs/Engines/engine";
  6040. import { Scene } from "babylonjs/scene";
  6041. /**
  6042. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6043. * during the life time of the application.
  6044. */
  6045. export class EngineStore {
  6046. /** Gets the list of created engines */
  6047. static Instances: import("babylonjs/Engines/engine").Engine[];
  6048. /**
  6049. * Gets the latest created engine
  6050. */
  6051. static readonly LastCreatedEngine: Nullable<Engine>;
  6052. /**
  6053. * Gets the latest created scene
  6054. */
  6055. static readonly LastCreatedScene: Nullable<Scene>;
  6056. }
  6057. }
  6058. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6059. /**
  6060. * Define options used to create a render target texture
  6061. */
  6062. export class RenderTargetCreationOptions {
  6063. /**
  6064. * Specifies is mipmaps must be generated
  6065. */
  6066. generateMipMaps?: boolean;
  6067. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6068. generateDepthBuffer?: boolean;
  6069. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6070. generateStencilBuffer?: boolean;
  6071. /** Defines texture type (int by default) */
  6072. type?: number;
  6073. /** Defines sampling mode (trilinear by default) */
  6074. samplingMode?: number;
  6075. /** Defines format (RGBA by default) */
  6076. format?: number;
  6077. }
  6078. }
  6079. declare module "babylonjs/States/alphaCullingState" {
  6080. /**
  6081. * @hidden
  6082. **/
  6083. export class _AlphaState {
  6084. private _isAlphaBlendDirty;
  6085. private _isBlendFunctionParametersDirty;
  6086. private _isBlendEquationParametersDirty;
  6087. private _isBlendConstantsDirty;
  6088. private _alphaBlend;
  6089. private _blendFunctionParameters;
  6090. private _blendEquationParameters;
  6091. private _blendConstants;
  6092. /**
  6093. * Initializes the state.
  6094. */
  6095. constructor();
  6096. readonly isDirty: boolean;
  6097. alphaBlend: boolean;
  6098. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6099. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6100. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6101. reset(): void;
  6102. apply(gl: WebGLRenderingContext): void;
  6103. }
  6104. }
  6105. declare module "babylonjs/States/depthCullingState" {
  6106. import { Nullable } from "babylonjs/types";
  6107. /**
  6108. * @hidden
  6109. **/
  6110. export class _DepthCullingState {
  6111. private _isDepthTestDirty;
  6112. private _isDepthMaskDirty;
  6113. private _isDepthFuncDirty;
  6114. private _isCullFaceDirty;
  6115. private _isCullDirty;
  6116. private _isZOffsetDirty;
  6117. private _isFrontFaceDirty;
  6118. private _depthTest;
  6119. private _depthMask;
  6120. private _depthFunc;
  6121. private _cull;
  6122. private _cullFace;
  6123. private _zOffset;
  6124. private _frontFace;
  6125. /**
  6126. * Initializes the state.
  6127. */
  6128. constructor();
  6129. readonly isDirty: boolean;
  6130. zOffset: number;
  6131. cullFace: Nullable<number>;
  6132. cull: Nullable<boolean>;
  6133. depthFunc: Nullable<number>;
  6134. depthMask: boolean;
  6135. depthTest: boolean;
  6136. frontFace: Nullable<number>;
  6137. reset(): void;
  6138. apply(gl: WebGLRenderingContext): void;
  6139. }
  6140. }
  6141. declare module "babylonjs/States/stencilState" {
  6142. /**
  6143. * @hidden
  6144. **/
  6145. export class _StencilState {
  6146. /** 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 */
  6147. static readonly ALWAYS: number;
  6148. /** Passed to stencilOperation to specify that stencil value must be kept */
  6149. static readonly KEEP: number;
  6150. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6151. static readonly REPLACE: number;
  6152. private _isStencilTestDirty;
  6153. private _isStencilMaskDirty;
  6154. private _isStencilFuncDirty;
  6155. private _isStencilOpDirty;
  6156. private _stencilTest;
  6157. private _stencilMask;
  6158. private _stencilFunc;
  6159. private _stencilFuncRef;
  6160. private _stencilFuncMask;
  6161. private _stencilOpStencilFail;
  6162. private _stencilOpDepthFail;
  6163. private _stencilOpStencilDepthPass;
  6164. readonly isDirty: boolean;
  6165. stencilFunc: number;
  6166. stencilFuncRef: number;
  6167. stencilFuncMask: number;
  6168. stencilOpStencilFail: number;
  6169. stencilOpDepthFail: number;
  6170. stencilOpStencilDepthPass: number;
  6171. stencilMask: number;
  6172. stencilTest: boolean;
  6173. constructor();
  6174. reset(): void;
  6175. apply(gl: WebGLRenderingContext): void;
  6176. }
  6177. }
  6178. declare module "babylonjs/States/index" {
  6179. export * from "babylonjs/States/alphaCullingState";
  6180. export * from "babylonjs/States/depthCullingState";
  6181. export * from "babylonjs/States/stencilState";
  6182. }
  6183. declare module "babylonjs/Instrumentation/timeToken" {
  6184. import { Nullable } from "babylonjs/types";
  6185. /**
  6186. * @hidden
  6187. **/
  6188. export class _TimeToken {
  6189. _startTimeQuery: Nullable<WebGLQuery>;
  6190. _endTimeQuery: Nullable<WebGLQuery>;
  6191. _timeElapsedQuery: Nullable<WebGLQuery>;
  6192. _timeElapsedQueryEnded: boolean;
  6193. }
  6194. }
  6195. declare module "babylonjs/Materials/Textures/internalTexture" {
  6196. import { Observable } from "babylonjs/Misc/observable";
  6197. import { Nullable, int } from "babylonjs/types";
  6198. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6199. import { Engine } from "babylonjs/Engines/engine";
  6200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6201. /**
  6202. * Class used to store data associated with WebGL texture data for the engine
  6203. * This class should not be used directly
  6204. */
  6205. export class InternalTexture {
  6206. /** hidden */
  6207. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6208. /**
  6209. * The source of the texture data is unknown
  6210. */
  6211. static DATASOURCE_UNKNOWN: number;
  6212. /**
  6213. * Texture data comes from an URL
  6214. */
  6215. static DATASOURCE_URL: number;
  6216. /**
  6217. * Texture data is only used for temporary storage
  6218. */
  6219. static DATASOURCE_TEMP: number;
  6220. /**
  6221. * Texture data comes from raw data (ArrayBuffer)
  6222. */
  6223. static DATASOURCE_RAW: number;
  6224. /**
  6225. * Texture content is dynamic (video or dynamic texture)
  6226. */
  6227. static DATASOURCE_DYNAMIC: number;
  6228. /**
  6229. * Texture content is generated by rendering to it
  6230. */
  6231. static DATASOURCE_RENDERTARGET: number;
  6232. /**
  6233. * Texture content is part of a multi render target process
  6234. */
  6235. static DATASOURCE_MULTIRENDERTARGET: number;
  6236. /**
  6237. * Texture data comes from a cube data file
  6238. */
  6239. static DATASOURCE_CUBE: number;
  6240. /**
  6241. * Texture data comes from a raw cube data
  6242. */
  6243. static DATASOURCE_CUBERAW: number;
  6244. /**
  6245. * Texture data come from a prefiltered cube data file
  6246. */
  6247. static DATASOURCE_CUBEPREFILTERED: number;
  6248. /**
  6249. * Texture content is raw 3D data
  6250. */
  6251. static DATASOURCE_RAW3D: number;
  6252. /**
  6253. * Texture content is a depth texture
  6254. */
  6255. static DATASOURCE_DEPTHTEXTURE: number;
  6256. /**
  6257. * Texture data comes from a raw cube data encoded with RGBD
  6258. */
  6259. static DATASOURCE_CUBERAW_RGBD: number;
  6260. /**
  6261. * Defines if the texture is ready
  6262. */
  6263. isReady: boolean;
  6264. /**
  6265. * Defines if the texture is a cube texture
  6266. */
  6267. isCube: boolean;
  6268. /**
  6269. * Defines if the texture contains 3D data
  6270. */
  6271. is3D: boolean;
  6272. /**
  6273. * Defines if the texture contains multiview data
  6274. */
  6275. isMultiview: boolean;
  6276. /**
  6277. * Gets the URL used to load this texture
  6278. */
  6279. url: string;
  6280. /**
  6281. * Gets the sampling mode of the texture
  6282. */
  6283. samplingMode: number;
  6284. /**
  6285. * Gets a boolean indicating if the texture needs mipmaps generation
  6286. */
  6287. generateMipMaps: boolean;
  6288. /**
  6289. * Gets the number of samples used by the texture (WebGL2+ only)
  6290. */
  6291. samples: number;
  6292. /**
  6293. * Gets the type of the texture (int, float...)
  6294. */
  6295. type: number;
  6296. /**
  6297. * Gets the format of the texture (RGB, RGBA...)
  6298. */
  6299. format: number;
  6300. /**
  6301. * Observable called when the texture is loaded
  6302. */
  6303. onLoadedObservable: Observable<InternalTexture>;
  6304. /**
  6305. * Gets the width of the texture
  6306. */
  6307. width: number;
  6308. /**
  6309. * Gets the height of the texture
  6310. */
  6311. height: number;
  6312. /**
  6313. * Gets the depth of the texture
  6314. */
  6315. depth: number;
  6316. /**
  6317. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6318. */
  6319. baseWidth: number;
  6320. /**
  6321. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6322. */
  6323. baseHeight: number;
  6324. /**
  6325. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6326. */
  6327. baseDepth: number;
  6328. /**
  6329. * Gets a boolean indicating if the texture is inverted on Y axis
  6330. */
  6331. invertY: boolean;
  6332. /** @hidden */
  6333. _invertVScale: boolean;
  6334. /** @hidden */
  6335. _associatedChannel: number;
  6336. /** @hidden */
  6337. _dataSource: number;
  6338. /** @hidden */
  6339. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6340. /** @hidden */
  6341. _bufferView: Nullable<ArrayBufferView>;
  6342. /** @hidden */
  6343. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6344. /** @hidden */
  6345. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6346. /** @hidden */
  6347. _size: number;
  6348. /** @hidden */
  6349. _extension: string;
  6350. /** @hidden */
  6351. _files: Nullable<string[]>;
  6352. /** @hidden */
  6353. _workingCanvas: HTMLCanvasElement;
  6354. /** @hidden */
  6355. _workingContext: CanvasRenderingContext2D;
  6356. /** @hidden */
  6357. _framebuffer: Nullable<WebGLFramebuffer>;
  6358. /** @hidden */
  6359. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6360. /** @hidden */
  6361. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6362. /** @hidden */
  6363. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6364. /** @hidden */
  6365. _attachments: Nullable<number[]>;
  6366. /** @hidden */
  6367. _cachedCoordinatesMode: Nullable<number>;
  6368. /** @hidden */
  6369. _cachedWrapU: Nullable<number>;
  6370. /** @hidden */
  6371. _cachedWrapV: Nullable<number>;
  6372. /** @hidden */
  6373. _cachedWrapR: Nullable<number>;
  6374. /** @hidden */
  6375. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6376. /** @hidden */
  6377. _isDisabled: boolean;
  6378. /** @hidden */
  6379. _compression: Nullable<string>;
  6380. /** @hidden */
  6381. _generateStencilBuffer: boolean;
  6382. /** @hidden */
  6383. _generateDepthBuffer: boolean;
  6384. /** @hidden */
  6385. _comparisonFunction: number;
  6386. /** @hidden */
  6387. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6388. /** @hidden */
  6389. _lodGenerationScale: number;
  6390. /** @hidden */
  6391. _lodGenerationOffset: number;
  6392. /** @hidden */
  6393. _colorTextureArray: Nullable<WebGLTexture>;
  6394. /** @hidden */
  6395. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6396. /** @hidden */
  6397. _lodTextureHigh: BaseTexture;
  6398. /** @hidden */
  6399. _lodTextureMid: BaseTexture;
  6400. /** @hidden */
  6401. _lodTextureLow: BaseTexture;
  6402. /** @hidden */
  6403. _isRGBD: boolean;
  6404. /** @hidden */
  6405. _webGLTexture: Nullable<WebGLTexture>;
  6406. /** @hidden */
  6407. _references: number;
  6408. private _engine;
  6409. /**
  6410. * Gets the Engine the texture belongs to.
  6411. * @returns The babylon engine
  6412. */
  6413. getEngine(): Engine;
  6414. /**
  6415. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6416. */
  6417. readonly dataSource: number;
  6418. /**
  6419. * Creates a new InternalTexture
  6420. * @param engine defines the engine to use
  6421. * @param dataSource defines the type of data that will be used
  6422. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6423. */
  6424. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6425. /**
  6426. * Increments the number of references (ie. the number of Texture that point to it)
  6427. */
  6428. incrementReferences(): void;
  6429. /**
  6430. * Change the size of the texture (not the size of the content)
  6431. * @param width defines the new width
  6432. * @param height defines the new height
  6433. * @param depth defines the new depth (1 by default)
  6434. */
  6435. updateSize(width: int, height: int, depth?: int): void;
  6436. /** @hidden */
  6437. _rebuild(): void;
  6438. /** @hidden */
  6439. _swapAndDie(target: InternalTexture): void;
  6440. /**
  6441. * Dispose the current allocated resources
  6442. */
  6443. dispose(): void;
  6444. }
  6445. }
  6446. declare module "babylonjs/Animations/easing" {
  6447. /**
  6448. * This represents the main contract an easing function should follow.
  6449. * Easing functions are used throughout the animation system.
  6450. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6451. */
  6452. export interface IEasingFunction {
  6453. /**
  6454. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6455. * of the easing function.
  6456. * The link below provides some of the most common examples of easing functions.
  6457. * @see https://easings.net/
  6458. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6459. * @returns the corresponding value on the curve defined by the easing function
  6460. */
  6461. ease(gradient: number): number;
  6462. }
  6463. /**
  6464. * Base class used for every default easing function.
  6465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6466. */
  6467. export class EasingFunction implements IEasingFunction {
  6468. /**
  6469. * Interpolation follows the mathematical formula associated with the easing function.
  6470. */
  6471. static readonly EASINGMODE_EASEIN: number;
  6472. /**
  6473. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6474. */
  6475. static readonly EASINGMODE_EASEOUT: number;
  6476. /**
  6477. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6478. */
  6479. static readonly EASINGMODE_EASEINOUT: number;
  6480. private _easingMode;
  6481. /**
  6482. * Sets the easing mode of the current function.
  6483. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6484. */
  6485. setEasingMode(easingMode: number): void;
  6486. /**
  6487. * Gets the current easing mode.
  6488. * @returns the easing mode
  6489. */
  6490. getEasingMode(): number;
  6491. /**
  6492. * @hidden
  6493. */
  6494. easeInCore(gradient: number): number;
  6495. /**
  6496. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6497. * of the easing function.
  6498. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6499. * @returns the corresponding value on the curve defined by the easing function
  6500. */
  6501. ease(gradient: number): number;
  6502. }
  6503. /**
  6504. * Easing function with a circle shape (see link below).
  6505. * @see https://easings.net/#easeInCirc
  6506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6507. */
  6508. export class CircleEase extends EasingFunction implements IEasingFunction {
  6509. /** @hidden */
  6510. easeInCore(gradient: number): number;
  6511. }
  6512. /**
  6513. * Easing function with a ease back shape (see link below).
  6514. * @see https://easings.net/#easeInBack
  6515. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6516. */
  6517. export class BackEase extends EasingFunction implements IEasingFunction {
  6518. /** Defines the amplitude of the function */
  6519. amplitude: number;
  6520. /**
  6521. * Instantiates a back ease easing
  6522. * @see https://easings.net/#easeInBack
  6523. * @param amplitude Defines the amplitude of the function
  6524. */
  6525. constructor(
  6526. /** Defines the amplitude of the function */
  6527. amplitude?: number);
  6528. /** @hidden */
  6529. easeInCore(gradient: number): number;
  6530. }
  6531. /**
  6532. * Easing function with a bouncing shape (see link below).
  6533. * @see https://easings.net/#easeInBounce
  6534. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6535. */
  6536. export class BounceEase extends EasingFunction implements IEasingFunction {
  6537. /** Defines the number of bounces */
  6538. bounces: number;
  6539. /** Defines the amplitude of the bounce */
  6540. bounciness: number;
  6541. /**
  6542. * Instantiates a bounce easing
  6543. * @see https://easings.net/#easeInBounce
  6544. * @param bounces Defines the number of bounces
  6545. * @param bounciness Defines the amplitude of the bounce
  6546. */
  6547. constructor(
  6548. /** Defines the number of bounces */
  6549. bounces?: number,
  6550. /** Defines the amplitude of the bounce */
  6551. bounciness?: number);
  6552. /** @hidden */
  6553. easeInCore(gradient: number): number;
  6554. }
  6555. /**
  6556. * Easing function with a power of 3 shape (see link below).
  6557. * @see https://easings.net/#easeInCubic
  6558. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6559. */
  6560. export class CubicEase extends EasingFunction implements IEasingFunction {
  6561. /** @hidden */
  6562. easeInCore(gradient: number): number;
  6563. }
  6564. /**
  6565. * Easing function with an elastic shape (see link below).
  6566. * @see https://easings.net/#easeInElastic
  6567. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6568. */
  6569. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6570. /** Defines the number of oscillations*/
  6571. oscillations: number;
  6572. /** Defines the amplitude of the oscillations*/
  6573. springiness: number;
  6574. /**
  6575. * Instantiates an elastic easing function
  6576. * @see https://easings.net/#easeInElastic
  6577. * @param oscillations Defines the number of oscillations
  6578. * @param springiness Defines the amplitude of the oscillations
  6579. */
  6580. constructor(
  6581. /** Defines the number of oscillations*/
  6582. oscillations?: number,
  6583. /** Defines the amplitude of the oscillations*/
  6584. springiness?: number);
  6585. /** @hidden */
  6586. easeInCore(gradient: number): number;
  6587. }
  6588. /**
  6589. * Easing function with an exponential shape (see link below).
  6590. * @see https://easings.net/#easeInExpo
  6591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6592. */
  6593. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6594. /** Defines the exponent of the function */
  6595. exponent: number;
  6596. /**
  6597. * Instantiates an exponential easing function
  6598. * @see https://easings.net/#easeInExpo
  6599. * @param exponent Defines the exponent of the function
  6600. */
  6601. constructor(
  6602. /** Defines the exponent of the function */
  6603. exponent?: number);
  6604. /** @hidden */
  6605. easeInCore(gradient: number): number;
  6606. }
  6607. /**
  6608. * Easing function with a power shape (see link below).
  6609. * @see https://easings.net/#easeInQuad
  6610. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6611. */
  6612. export class PowerEase extends EasingFunction implements IEasingFunction {
  6613. /** Defines the power of the function */
  6614. power: number;
  6615. /**
  6616. * Instantiates an power base easing function
  6617. * @see https://easings.net/#easeInQuad
  6618. * @param power Defines the power of the function
  6619. */
  6620. constructor(
  6621. /** Defines the power of the function */
  6622. power?: number);
  6623. /** @hidden */
  6624. easeInCore(gradient: number): number;
  6625. }
  6626. /**
  6627. * Easing function with a power of 2 shape (see link below).
  6628. * @see https://easings.net/#easeInQuad
  6629. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6630. */
  6631. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6632. /** @hidden */
  6633. easeInCore(gradient: number): number;
  6634. }
  6635. /**
  6636. * Easing function with a power of 4 shape (see link below).
  6637. * @see https://easings.net/#easeInQuart
  6638. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6639. */
  6640. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with a power of 5 shape (see link below).
  6646. * @see https://easings.net/#easeInQuint
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6650. /** @hidden */
  6651. easeInCore(gradient: number): number;
  6652. }
  6653. /**
  6654. * Easing function with a sin shape (see link below).
  6655. * @see https://easings.net/#easeInSine
  6656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6657. */
  6658. export class SineEase extends EasingFunction implements IEasingFunction {
  6659. /** @hidden */
  6660. easeInCore(gradient: number): number;
  6661. }
  6662. /**
  6663. * Easing function with a bezier shape (see link below).
  6664. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6665. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6666. */
  6667. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6668. /** Defines the x component of the start tangent in the bezier curve */
  6669. x1: number;
  6670. /** Defines the y component of the start tangent in the bezier curve */
  6671. y1: number;
  6672. /** Defines the x component of the end tangent in the bezier curve */
  6673. x2: number;
  6674. /** Defines the y component of the end tangent in the bezier curve */
  6675. y2: number;
  6676. /**
  6677. * Instantiates a bezier function
  6678. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6679. * @param x1 Defines the x component of the start tangent in the bezier curve
  6680. * @param y1 Defines the y component of the start tangent in the bezier curve
  6681. * @param x2 Defines the x component of the end tangent in the bezier curve
  6682. * @param y2 Defines the y component of the end tangent in the bezier curve
  6683. */
  6684. constructor(
  6685. /** Defines the x component of the start tangent in the bezier curve */
  6686. x1?: number,
  6687. /** Defines the y component of the start tangent in the bezier curve */
  6688. y1?: number,
  6689. /** Defines the x component of the end tangent in the bezier curve */
  6690. x2?: number,
  6691. /** Defines the y component of the end tangent in the bezier curve */
  6692. y2?: number);
  6693. /** @hidden */
  6694. easeInCore(gradient: number): number;
  6695. }
  6696. }
  6697. declare module "babylonjs/Animations/animationKey" {
  6698. /**
  6699. * Defines an interface which represents an animation key frame
  6700. */
  6701. export interface IAnimationKey {
  6702. /**
  6703. * Frame of the key frame
  6704. */
  6705. frame: number;
  6706. /**
  6707. * Value at the specifies key frame
  6708. */
  6709. value: any;
  6710. /**
  6711. * The input tangent for the cubic hermite spline
  6712. */
  6713. inTangent?: any;
  6714. /**
  6715. * The output tangent for the cubic hermite spline
  6716. */
  6717. outTangent?: any;
  6718. /**
  6719. * The animation interpolation type
  6720. */
  6721. interpolation?: AnimationKeyInterpolation;
  6722. }
  6723. /**
  6724. * Enum for the animation key frame interpolation type
  6725. */
  6726. export enum AnimationKeyInterpolation {
  6727. /**
  6728. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6729. */
  6730. STEP = 1
  6731. }
  6732. }
  6733. declare module "babylonjs/Animations/animationRange" {
  6734. /**
  6735. * Represents the range of an animation
  6736. */
  6737. export class AnimationRange {
  6738. /**The name of the animation range**/
  6739. name: string;
  6740. /**The starting frame of the animation */
  6741. from: number;
  6742. /**The ending frame of the animation*/
  6743. to: number;
  6744. /**
  6745. * Initializes the range of an animation
  6746. * @param name The name of the animation range
  6747. * @param from The starting frame of the animation
  6748. * @param to The ending frame of the animation
  6749. */
  6750. constructor(
  6751. /**The name of the animation range**/
  6752. name: string,
  6753. /**The starting frame of the animation */
  6754. from: number,
  6755. /**The ending frame of the animation*/
  6756. to: number);
  6757. /**
  6758. * Makes a copy of the animation range
  6759. * @returns A copy of the animation range
  6760. */
  6761. clone(): AnimationRange;
  6762. }
  6763. }
  6764. declare module "babylonjs/Animations/animationEvent" {
  6765. /**
  6766. * Composed of a frame, and an action function
  6767. */
  6768. export class AnimationEvent {
  6769. /** The frame for which the event is triggered **/
  6770. frame: number;
  6771. /** The event to perform when triggered **/
  6772. action: (currentFrame: number) => void;
  6773. /** Specifies if the event should be triggered only once**/
  6774. onlyOnce?: boolean | undefined;
  6775. /**
  6776. * Specifies if the animation event is done
  6777. */
  6778. isDone: boolean;
  6779. /**
  6780. * Initializes the animation event
  6781. * @param frame The frame for which the event is triggered
  6782. * @param action The event to perform when triggered
  6783. * @param onlyOnce Specifies if the event should be triggered only once
  6784. */
  6785. constructor(
  6786. /** The frame for which the event is triggered **/
  6787. frame: number,
  6788. /** The event to perform when triggered **/
  6789. action: (currentFrame: number) => void,
  6790. /** Specifies if the event should be triggered only once**/
  6791. onlyOnce?: boolean | undefined);
  6792. /** @hidden */
  6793. _clone(): AnimationEvent;
  6794. }
  6795. }
  6796. declare module "babylonjs/Behaviors/behavior" {
  6797. import { Nullable } from "babylonjs/types";
  6798. /**
  6799. * Interface used to define a behavior
  6800. */
  6801. export interface Behavior<T> {
  6802. /** gets or sets behavior's name */
  6803. name: string;
  6804. /**
  6805. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6806. */
  6807. init(): void;
  6808. /**
  6809. * Called when the behavior is attached to a target
  6810. * @param target defines the target where the behavior is attached to
  6811. */
  6812. attach(target: T): void;
  6813. /**
  6814. * Called when the behavior is detached from its target
  6815. */
  6816. detach(): void;
  6817. }
  6818. /**
  6819. * Interface implemented by classes supporting behaviors
  6820. */
  6821. export interface IBehaviorAware<T> {
  6822. /**
  6823. * Attach a behavior
  6824. * @param behavior defines the behavior to attach
  6825. * @returns the current host
  6826. */
  6827. addBehavior(behavior: Behavior<T>): T;
  6828. /**
  6829. * Remove a behavior from the current object
  6830. * @param behavior defines the behavior to detach
  6831. * @returns the current host
  6832. */
  6833. removeBehavior(behavior: Behavior<T>): T;
  6834. /**
  6835. * Gets a behavior using its name to search
  6836. * @param name defines the name to search
  6837. * @returns the behavior or null if not found
  6838. */
  6839. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6840. }
  6841. }
  6842. declare module "babylonjs/Collisions/intersectionInfo" {
  6843. import { Nullable } from "babylonjs/types";
  6844. /**
  6845. * @hidden
  6846. */
  6847. export class IntersectionInfo {
  6848. bu: Nullable<number>;
  6849. bv: Nullable<number>;
  6850. distance: number;
  6851. faceId: number;
  6852. subMeshId: number;
  6853. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6854. }
  6855. }
  6856. declare module "babylonjs/Culling/boundingSphere" {
  6857. import { DeepImmutable } from "babylonjs/types";
  6858. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6859. /**
  6860. * Class used to store bounding sphere information
  6861. */
  6862. export class BoundingSphere {
  6863. /**
  6864. * Gets the center of the bounding sphere in local space
  6865. */
  6866. readonly center: Vector3;
  6867. /**
  6868. * Radius of the bounding sphere in local space
  6869. */
  6870. radius: number;
  6871. /**
  6872. * Gets the center of the bounding sphere in world space
  6873. */
  6874. readonly centerWorld: Vector3;
  6875. /**
  6876. * Radius of the bounding sphere in world space
  6877. */
  6878. radiusWorld: number;
  6879. /**
  6880. * Gets the minimum vector in local space
  6881. */
  6882. readonly minimum: Vector3;
  6883. /**
  6884. * Gets the maximum vector in local space
  6885. */
  6886. readonly maximum: Vector3;
  6887. private _worldMatrix;
  6888. private static readonly TmpVector3;
  6889. /**
  6890. * Creates a new bounding sphere
  6891. * @param min defines the minimum vector (in local space)
  6892. * @param max defines the maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6896. /**
  6897. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6898. * @param min defines the new minimum vector (in local space)
  6899. * @param max defines the new maximum vector (in local space)
  6900. * @param worldMatrix defines the new world matrix
  6901. */
  6902. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6903. /**
  6904. * Scale the current bounding sphere by applying a scale factor
  6905. * @param factor defines the scale factor to apply
  6906. * @returns the current bounding box
  6907. */
  6908. scale(factor: number): BoundingSphere;
  6909. /**
  6910. * Gets the world matrix of the bounding box
  6911. * @returns a matrix
  6912. */
  6913. getWorldMatrix(): DeepImmutable<Matrix>;
  6914. /** @hidden */
  6915. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6916. /**
  6917. * Tests if the bounding sphere is intersecting the frustum planes
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if there is an intersection
  6920. */
  6921. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if the bounding sphere center is in between the frustum planes.
  6924. * Used for optimistic fast inclusion.
  6925. * @param frustumPlanes defines the frustum planes to test
  6926. * @returns true if the sphere center is in between the frustum planes
  6927. */
  6928. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6929. /**
  6930. * Tests if a point is inside the bounding sphere
  6931. * @param point defines the point to test
  6932. * @returns true if the point is inside the bounding sphere
  6933. */
  6934. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6935. /**
  6936. * Checks if two sphere intersct
  6937. * @param sphere0 sphere 0
  6938. * @param sphere1 sphere 1
  6939. * @returns true if the speres intersect
  6940. */
  6941. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6942. }
  6943. }
  6944. declare module "babylonjs/Culling/boundingBox" {
  6945. import { DeepImmutable } from "babylonjs/types";
  6946. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6947. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6948. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6949. /**
  6950. * Class used to store bounding box information
  6951. */
  6952. export class BoundingBox implements ICullable {
  6953. /**
  6954. * Gets the 8 vectors representing the bounding box in local space
  6955. */
  6956. readonly vectors: Vector3[];
  6957. /**
  6958. * Gets the center of the bounding box in local space
  6959. */
  6960. readonly center: Vector3;
  6961. /**
  6962. * Gets the center of the bounding box in world space
  6963. */
  6964. readonly centerWorld: Vector3;
  6965. /**
  6966. * Gets the extend size in local space
  6967. */
  6968. readonly extendSize: Vector3;
  6969. /**
  6970. * Gets the extend size in world space
  6971. */
  6972. readonly extendSizeWorld: Vector3;
  6973. /**
  6974. * Gets the OBB (object bounding box) directions
  6975. */
  6976. readonly directions: Vector3[];
  6977. /**
  6978. * Gets the 8 vectors representing the bounding box in world space
  6979. */
  6980. readonly vectorsWorld: Vector3[];
  6981. /**
  6982. * Gets the minimum vector in world space
  6983. */
  6984. readonly minimumWorld: Vector3;
  6985. /**
  6986. * Gets the maximum vector in world space
  6987. */
  6988. readonly maximumWorld: Vector3;
  6989. /**
  6990. * Gets the minimum vector in local space
  6991. */
  6992. readonly minimum: Vector3;
  6993. /**
  6994. * Gets the maximum vector in local space
  6995. */
  6996. readonly maximum: Vector3;
  6997. private _worldMatrix;
  6998. private static readonly TmpVector3;
  6999. /**
  7000. * @hidden
  7001. */
  7002. _tag: number;
  7003. /**
  7004. * Creates a new bounding box
  7005. * @param min defines the minimum vector (in local space)
  7006. * @param max defines the maximum vector (in local space)
  7007. * @param worldMatrix defines the new world matrix
  7008. */
  7009. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7010. /**
  7011. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7012. * @param min defines the new minimum vector (in local space)
  7013. * @param max defines the new maximum vector (in local space)
  7014. * @param worldMatrix defines the new world matrix
  7015. */
  7016. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7017. /**
  7018. * Scale the current bounding box by applying a scale factor
  7019. * @param factor defines the scale factor to apply
  7020. * @returns the current bounding box
  7021. */
  7022. scale(factor: number): BoundingBox;
  7023. /**
  7024. * Gets the world matrix of the bounding box
  7025. * @returns a matrix
  7026. */
  7027. getWorldMatrix(): DeepImmutable<Matrix>;
  7028. /** @hidden */
  7029. _update(world: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Tests if the bounding box is intersecting the frustum planes
  7032. * @param frustumPlanes defines the frustum planes to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7036. /**
  7037. * Tests if the bounding box is entirely inside the frustum planes
  7038. * @param frustumPlanes defines the frustum planes to test
  7039. * @returns true if there is an inclusion
  7040. */
  7041. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7042. /**
  7043. * Tests if a point is inside the bounding box
  7044. * @param point defines the point to test
  7045. * @returns true if the point is inside the bounding box
  7046. */
  7047. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7048. /**
  7049. * Tests if the bounding box intersects with a bounding sphere
  7050. * @param sphere defines the sphere to test
  7051. * @returns true if there is an intersection
  7052. */
  7053. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7054. /**
  7055. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7056. * @param min defines the min vector to use
  7057. * @param max defines the max vector to use
  7058. * @returns true if there is an intersection
  7059. */
  7060. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if two bounding boxes are intersections
  7063. * @param box0 defines the first box to test
  7064. * @param box1 defines the second box to test
  7065. * @returns true if there is an intersection
  7066. */
  7067. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7068. /**
  7069. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7070. * @param minPoint defines the minimum vector of the bounding box
  7071. * @param maxPoint defines the maximum vector of the bounding box
  7072. * @param sphereCenter defines the sphere center
  7073. * @param sphereRadius defines the sphere radius
  7074. * @returns true if there is an intersection
  7075. */
  7076. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7077. /**
  7078. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7079. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7080. * @param frustumPlanes defines the frustum planes to test
  7081. * @return true if there is an inclusion
  7082. */
  7083. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7084. /**
  7085. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7086. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7087. * @param frustumPlanes defines the frustum planes to test
  7088. * @return true if there is an intersection
  7089. */
  7090. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7091. }
  7092. }
  7093. declare module "babylonjs/Collisions/collider" {
  7094. import { Nullable, IndicesArray } from "babylonjs/types";
  7095. import { Vector3, Plane } from "babylonjs/Maths/math";
  7096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7097. /** @hidden */
  7098. export class Collider {
  7099. /** Define if a collision was found */
  7100. collisionFound: boolean;
  7101. /**
  7102. * Define last intersection point in local space
  7103. */
  7104. intersectionPoint: Vector3;
  7105. /**
  7106. * Define last collided mesh
  7107. */
  7108. collidedMesh: Nullable<AbstractMesh>;
  7109. private _collisionPoint;
  7110. private _planeIntersectionPoint;
  7111. private _tempVector;
  7112. private _tempVector2;
  7113. private _tempVector3;
  7114. private _tempVector4;
  7115. private _edge;
  7116. private _baseToVertex;
  7117. private _destinationPoint;
  7118. private _slidePlaneNormal;
  7119. private _displacementVector;
  7120. /** @hidden */
  7121. _radius: Vector3;
  7122. /** @hidden */
  7123. _retry: number;
  7124. private _velocity;
  7125. private _basePoint;
  7126. private _epsilon;
  7127. /** @hidden */
  7128. _velocityWorldLength: number;
  7129. /** @hidden */
  7130. _basePointWorld: Vector3;
  7131. private _velocityWorld;
  7132. private _normalizedVelocity;
  7133. /** @hidden */
  7134. _initialVelocity: Vector3;
  7135. /** @hidden */
  7136. _initialPosition: Vector3;
  7137. private _nearestDistance;
  7138. private _collisionMask;
  7139. collisionMask: number;
  7140. /**
  7141. * Gets the plane normal used to compute the sliding response (in local space)
  7142. */
  7143. readonly slidePlaneNormal: Vector3;
  7144. /** @hidden */
  7145. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7146. /** @hidden */
  7147. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7148. /** @hidden */
  7149. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7150. /** @hidden */
  7151. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7152. /** @hidden */
  7153. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7154. /** @hidden */
  7155. _getResponse(pos: Vector3, vel: Vector3): void;
  7156. }
  7157. }
  7158. declare module "babylonjs/Culling/boundingInfo" {
  7159. import { DeepImmutable } from "babylonjs/types";
  7160. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7161. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7162. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7163. import { Collider } from "babylonjs/Collisions/collider";
  7164. /**
  7165. * Interface for cullable objects
  7166. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7167. */
  7168. export interface ICullable {
  7169. /**
  7170. * Checks if the object or part of the object is in the frustum
  7171. * @param frustumPlanes Camera near/planes
  7172. * @returns true if the object is in frustum otherwise false
  7173. */
  7174. isInFrustum(frustumPlanes: Plane[]): boolean;
  7175. /**
  7176. * Checks if a cullable object (mesh...) is in the camera frustum
  7177. * Unlike isInFrustum this cheks the full bounding box
  7178. * @param frustumPlanes Camera near/planes
  7179. * @returns true if the object is in frustum otherwise false
  7180. */
  7181. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7182. }
  7183. /**
  7184. * Info for a bounding data of a mesh
  7185. */
  7186. export class BoundingInfo implements ICullable {
  7187. /**
  7188. * Bounding box for the mesh
  7189. */
  7190. readonly boundingBox: BoundingBox;
  7191. /**
  7192. * Bounding sphere for the mesh
  7193. */
  7194. readonly boundingSphere: BoundingSphere;
  7195. private _isLocked;
  7196. private static readonly TmpVector3;
  7197. /**
  7198. * Constructs bounding info
  7199. * @param minimum min vector of the bounding box/sphere
  7200. * @param maximum max vector of the bounding box/sphere
  7201. * @param worldMatrix defines the new world matrix
  7202. */
  7203. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7204. /**
  7205. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7206. * @param min defines the new minimum vector (in local space)
  7207. * @param max defines the new maximum vector (in local space)
  7208. * @param worldMatrix defines the new world matrix
  7209. */
  7210. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7211. /**
  7212. * min vector of the bounding box/sphere
  7213. */
  7214. readonly minimum: Vector3;
  7215. /**
  7216. * max vector of the bounding box/sphere
  7217. */
  7218. readonly maximum: Vector3;
  7219. /**
  7220. * If the info is locked and won't be updated to avoid perf overhead
  7221. */
  7222. isLocked: boolean;
  7223. /**
  7224. * Updates the bounding sphere and box
  7225. * @param world world matrix to be used to update
  7226. */
  7227. update(world: DeepImmutable<Matrix>): void;
  7228. /**
  7229. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7230. * @param center New center of the bounding info
  7231. * @param extend New extend of the bounding info
  7232. * @returns the current bounding info
  7233. */
  7234. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7235. /**
  7236. * Scale the current bounding info by applying a scale factor
  7237. * @param factor defines the scale factor to apply
  7238. * @returns the current bounding info
  7239. */
  7240. scale(factor: number): BoundingInfo;
  7241. /**
  7242. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7243. * @param frustumPlanes defines the frustum to test
  7244. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7245. * @returns true if the bounding info is in the frustum planes
  7246. */
  7247. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7248. /**
  7249. * Gets the world distance between the min and max points of the bounding box
  7250. */
  7251. readonly diagonalLength: number;
  7252. /**
  7253. * Checks if a cullable object (mesh...) is in the camera frustum
  7254. * Unlike isInFrustum this cheks the full bounding box
  7255. * @param frustumPlanes Camera near/planes
  7256. * @returns true if the object is in frustum otherwise false
  7257. */
  7258. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7259. /** @hidden */
  7260. _checkCollision(collider: Collider): boolean;
  7261. /**
  7262. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7263. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7264. * @param point the point to check intersection with
  7265. * @returns if the point intersects
  7266. */
  7267. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7268. /**
  7269. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7270. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7271. * @param boundingInfo the bounding info to check intersection with
  7272. * @param precise if the intersection should be done using OBB
  7273. * @returns if the bounding info intersects
  7274. */
  7275. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7276. }
  7277. }
  7278. declare module "babylonjs/Misc/smartArray" {
  7279. /**
  7280. * Defines an array and its length.
  7281. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7282. */
  7283. export interface ISmartArrayLike<T> {
  7284. /**
  7285. * The data of the array.
  7286. */
  7287. data: Array<T>;
  7288. /**
  7289. * The active length of the array.
  7290. */
  7291. length: number;
  7292. }
  7293. /**
  7294. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7295. */
  7296. export class SmartArray<T> implements ISmartArrayLike<T> {
  7297. /**
  7298. * The full set of data from the array.
  7299. */
  7300. data: Array<T>;
  7301. /**
  7302. * The active length of the array.
  7303. */
  7304. length: number;
  7305. protected _id: number;
  7306. /**
  7307. * Instantiates a Smart Array.
  7308. * @param capacity defines the default capacity of the array.
  7309. */
  7310. constructor(capacity: number);
  7311. /**
  7312. * Pushes a value at the end of the active data.
  7313. * @param value defines the object to push in the array.
  7314. */
  7315. push(value: T): void;
  7316. /**
  7317. * Iterates over the active data and apply the lambda to them.
  7318. * @param func defines the action to apply on each value.
  7319. */
  7320. forEach(func: (content: T) => void): void;
  7321. /**
  7322. * Sorts the full sets of data.
  7323. * @param compareFn defines the comparison function to apply.
  7324. */
  7325. sort(compareFn: (a: T, b: T) => number): void;
  7326. /**
  7327. * Resets the active data to an empty array.
  7328. */
  7329. reset(): void;
  7330. /**
  7331. * Releases all the data from the array as well as the array.
  7332. */
  7333. dispose(): void;
  7334. /**
  7335. * Concats the active data with a given array.
  7336. * @param array defines the data to concatenate with.
  7337. */
  7338. concat(array: any): void;
  7339. /**
  7340. * Returns the position of a value in the active data.
  7341. * @param value defines the value to find the index for
  7342. * @returns the index if found in the active data otherwise -1
  7343. */
  7344. indexOf(value: T): number;
  7345. /**
  7346. * Returns whether an element is part of the active data.
  7347. * @param value defines the value to look for
  7348. * @returns true if found in the active data otherwise false
  7349. */
  7350. contains(value: T): boolean;
  7351. private static _GlobalId;
  7352. }
  7353. /**
  7354. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7355. * The data in this array can only be present once
  7356. */
  7357. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7358. private _duplicateId;
  7359. /**
  7360. * Pushes a value at the end of the active data.
  7361. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7362. * @param value defines the object to push in the array.
  7363. */
  7364. push(value: T): void;
  7365. /**
  7366. * Pushes a value at the end of the active data.
  7367. * If the data is already present, it won t be added again
  7368. * @param value defines the object to push in the array.
  7369. * @returns true if added false if it was already present
  7370. */
  7371. pushNoDuplicate(value: T): boolean;
  7372. /**
  7373. * Resets the active data to an empty array.
  7374. */
  7375. reset(): void;
  7376. /**
  7377. * Concats the active data with a given array.
  7378. * This ensures no dupplicate will be present in the result.
  7379. * @param array defines the data to concatenate with.
  7380. */
  7381. concatWithNoDuplicate(array: any): void;
  7382. }
  7383. }
  7384. declare module "babylonjs/Materials/multiMaterial" {
  7385. import { Nullable } from "babylonjs/types";
  7386. import { Scene } from "babylonjs/scene";
  7387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7388. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7390. import { Material } from "babylonjs/Materials/material";
  7391. /**
  7392. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7393. * separate meshes. This can be use to improve performances.
  7394. * @see http://doc.babylonjs.com/how_to/multi_materials
  7395. */
  7396. export class MultiMaterial extends Material {
  7397. private _subMaterials;
  7398. /**
  7399. * Gets or Sets the list of Materials used within the multi material.
  7400. * They need to be ordered according to the submeshes order in the associated mesh
  7401. */
  7402. subMaterials: Nullable<Material>[];
  7403. /**
  7404. * Function used to align with Node.getChildren()
  7405. * @returns the list of Materials used within the multi material
  7406. */
  7407. getChildren(): Nullable<Material>[];
  7408. /**
  7409. * Instantiates a new Multi Material
  7410. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7411. * separate meshes. This can be use to improve performances.
  7412. * @see http://doc.babylonjs.com/how_to/multi_materials
  7413. * @param name Define the name in the scene
  7414. * @param scene Define the scene the material belongs to
  7415. */
  7416. constructor(name: string, scene: Scene);
  7417. private _hookArray;
  7418. /**
  7419. * Get one of the submaterial by its index in the submaterials array
  7420. * @param index The index to look the sub material at
  7421. * @returns The Material if the index has been defined
  7422. */
  7423. getSubMaterial(index: number): Nullable<Material>;
  7424. /**
  7425. * Get the list of active textures for the whole sub materials list.
  7426. * @returns All the textures that will be used during the rendering
  7427. */
  7428. getActiveTextures(): BaseTexture[];
  7429. /**
  7430. * Gets the current class name of the material e.g. "MultiMaterial"
  7431. * Mainly use in serialization.
  7432. * @returns the class name
  7433. */
  7434. getClassName(): string;
  7435. /**
  7436. * Checks if the material is ready to render the requested sub mesh
  7437. * @param mesh Define the mesh the submesh belongs to
  7438. * @param subMesh Define the sub mesh to look readyness for
  7439. * @param useInstances Define whether or not the material is used with instances
  7440. * @returns true if ready, otherwise false
  7441. */
  7442. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7443. /**
  7444. * Clones the current material and its related sub materials
  7445. * @param name Define the name of the newly cloned material
  7446. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7447. * @returns the cloned material
  7448. */
  7449. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7450. /**
  7451. * Serializes the materials into a JSON representation.
  7452. * @returns the JSON representation
  7453. */
  7454. serialize(): any;
  7455. /**
  7456. * Dispose the material and release its associated resources
  7457. * @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)
  7458. * @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)
  7459. * @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)
  7460. */
  7461. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7462. /**
  7463. * Creates a MultiMaterial from parsed MultiMaterial data.
  7464. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7465. * @param scene defines the hosting scene
  7466. * @returns a new MultiMaterial
  7467. */
  7468. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7469. }
  7470. }
  7471. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7472. /**
  7473. * Class used to represent data loading progression
  7474. */
  7475. export class SceneLoaderFlags {
  7476. private static _ForceFullSceneLoadingForIncremental;
  7477. private static _ShowLoadingScreen;
  7478. private static _CleanBoneMatrixWeights;
  7479. private static _loggingLevel;
  7480. /**
  7481. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7482. */
  7483. static ForceFullSceneLoadingForIncremental: boolean;
  7484. /**
  7485. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7486. */
  7487. static ShowLoadingScreen: boolean;
  7488. /**
  7489. * Defines the current logging level (while loading the scene)
  7490. * @ignorenaming
  7491. */
  7492. static loggingLevel: number;
  7493. /**
  7494. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7495. */
  7496. static CleanBoneMatrixWeights: boolean;
  7497. }
  7498. }
  7499. declare module "babylonjs/Meshes/transformNode" {
  7500. import { DeepImmutable } from "babylonjs/types";
  7501. import { Observable } from "babylonjs/Misc/observable";
  7502. import { Nullable } from "babylonjs/types";
  7503. import { Camera } from "babylonjs/Cameras/camera";
  7504. import { Scene } from "babylonjs/scene";
  7505. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7506. import { Node } from "babylonjs/node";
  7507. import { Bone } from "babylonjs/Bones/bone";
  7508. /**
  7509. * 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.
  7510. * @see https://doc.babylonjs.com/how_to/transformnode
  7511. */
  7512. export class TransformNode extends Node {
  7513. /**
  7514. * Object will not rotate to face the camera
  7515. */
  7516. static BILLBOARDMODE_NONE: number;
  7517. /**
  7518. * Object will rotate to face the camera but only on the x axis
  7519. */
  7520. static BILLBOARDMODE_X: number;
  7521. /**
  7522. * Object will rotate to face the camera but only on the y axis
  7523. */
  7524. static BILLBOARDMODE_Y: number;
  7525. /**
  7526. * Object will rotate to face the camera but only on the z axis
  7527. */
  7528. static BILLBOARDMODE_Z: number;
  7529. /**
  7530. * Object will rotate to face the camera
  7531. */
  7532. static BILLBOARDMODE_ALL: number;
  7533. private _forward;
  7534. private _forwardInverted;
  7535. private _up;
  7536. private _right;
  7537. private _rightInverted;
  7538. private _position;
  7539. private _rotation;
  7540. private _rotationQuaternion;
  7541. protected _scaling: Vector3;
  7542. protected _isDirty: boolean;
  7543. private _transformToBoneReferal;
  7544. private _billboardMode;
  7545. /**
  7546. * Gets or sets the billboard mode. Default is 0.
  7547. *
  7548. * | Value | Type | Description |
  7549. * | --- | --- | --- |
  7550. * | 0 | BILLBOARDMODE_NONE | |
  7551. * | 1 | BILLBOARDMODE_X | |
  7552. * | 2 | BILLBOARDMODE_Y | |
  7553. * | 4 | BILLBOARDMODE_Z | |
  7554. * | 7 | BILLBOARDMODE_ALL | |
  7555. *
  7556. */
  7557. billboardMode: number;
  7558. private _preserveParentRotationForBillboard;
  7559. /**
  7560. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7561. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7562. */
  7563. preserveParentRotationForBillboard: boolean;
  7564. /**
  7565. * 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
  7566. */
  7567. scalingDeterminant: number;
  7568. private _infiniteDistance;
  7569. /**
  7570. * Gets or sets the distance of the object to max, often used by skybox
  7571. */
  7572. infiniteDistance: boolean;
  7573. /**
  7574. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7575. * By default the system will update normals to compensate
  7576. */
  7577. ignoreNonUniformScaling: boolean;
  7578. /**
  7579. * 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
  7580. */
  7581. reIntegrateRotationIntoRotationQuaternion: boolean;
  7582. /** @hidden */
  7583. _poseMatrix: Matrix;
  7584. /** @hidden */
  7585. _localMatrix: Matrix;
  7586. private _usePivotMatrix;
  7587. private _absolutePosition;
  7588. private _pivotMatrix;
  7589. private _pivotMatrixInverse;
  7590. protected _postMultiplyPivotMatrix: boolean;
  7591. protected _isWorldMatrixFrozen: boolean;
  7592. /** @hidden */
  7593. _indexInSceneTransformNodesArray: number;
  7594. /**
  7595. * An event triggered after the world matrix is updated
  7596. */
  7597. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7598. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7599. /**
  7600. * Gets a string identifying the name of the class
  7601. * @returns "TransformNode" string
  7602. */
  7603. getClassName(): string;
  7604. /**
  7605. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7606. */
  7607. position: Vector3;
  7608. /**
  7609. * 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)).
  7610. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7611. */
  7612. rotation: Vector3;
  7613. /**
  7614. * 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)).
  7615. */
  7616. scaling: Vector3;
  7617. /**
  7618. * 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).
  7619. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7620. */
  7621. rotationQuaternion: Nullable<Quaternion>;
  7622. /**
  7623. * The forward direction of that transform in world space.
  7624. */
  7625. readonly forward: Vector3;
  7626. /**
  7627. * The up direction of that transform in world space.
  7628. */
  7629. readonly up: Vector3;
  7630. /**
  7631. * The right direction of that transform in world space.
  7632. */
  7633. readonly right: Vector3;
  7634. /**
  7635. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7636. * @param matrix the matrix to copy the pose from
  7637. * @returns this TransformNode.
  7638. */
  7639. updatePoseMatrix(matrix: Matrix): TransformNode;
  7640. /**
  7641. * Returns the mesh Pose matrix.
  7642. * @returns the pose matrix
  7643. */
  7644. getPoseMatrix(): Matrix;
  7645. /** @hidden */
  7646. _isSynchronized(): boolean;
  7647. /** @hidden */
  7648. _initCache(): void;
  7649. /**
  7650. * Flag the transform node as dirty (Forcing it to update everything)
  7651. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7652. * @returns this transform node
  7653. */
  7654. markAsDirty(property: string): TransformNode;
  7655. /**
  7656. * Returns the current mesh absolute position.
  7657. * Returns a Vector3.
  7658. */
  7659. readonly absolutePosition: Vector3;
  7660. /**
  7661. * Sets a new matrix to apply before all other transformation
  7662. * @param matrix defines the transform matrix
  7663. * @returns the current TransformNode
  7664. */
  7665. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7666. /**
  7667. * Sets a new pivot matrix to the current node
  7668. * @param matrix defines the new pivot matrix to use
  7669. * @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
  7670. * @returns the current TransformNode
  7671. */
  7672. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7673. /**
  7674. * Returns the mesh pivot matrix.
  7675. * Default : Identity.
  7676. * @returns the matrix
  7677. */
  7678. getPivotMatrix(): Matrix;
  7679. /**
  7680. * Prevents the World matrix to be computed any longer.
  7681. * @returns the TransformNode.
  7682. */
  7683. freezeWorldMatrix(): TransformNode;
  7684. /**
  7685. * Allows back the World matrix computation.
  7686. * @returns the TransformNode.
  7687. */
  7688. unfreezeWorldMatrix(): this;
  7689. /**
  7690. * True if the World matrix has been frozen.
  7691. */
  7692. readonly isWorldMatrixFrozen: boolean;
  7693. /**
  7694. * Retuns the mesh absolute position in the World.
  7695. * @returns a Vector3.
  7696. */
  7697. getAbsolutePosition(): Vector3;
  7698. /**
  7699. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7700. * @param absolutePosition the absolute position to set
  7701. * @returns the TransformNode.
  7702. */
  7703. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7704. /**
  7705. * Sets the mesh position in its local space.
  7706. * @param vector3 the position to set in localspace
  7707. * @returns the TransformNode.
  7708. */
  7709. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7710. /**
  7711. * Returns the mesh position in the local space from the current World matrix values.
  7712. * @returns a new Vector3.
  7713. */
  7714. getPositionExpressedInLocalSpace(): Vector3;
  7715. /**
  7716. * Translates the mesh along the passed Vector3 in its local space.
  7717. * @param vector3 the distance to translate in localspace
  7718. * @returns the TransformNode.
  7719. */
  7720. locallyTranslate(vector3: Vector3): TransformNode;
  7721. private static _lookAtVectorCache;
  7722. /**
  7723. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7724. * @param targetPoint the position (must be in same space as current mesh) to look at
  7725. * @param yawCor optional yaw (y-axis) correction in radians
  7726. * @param pitchCor optional pitch (x-axis) correction in radians
  7727. * @param rollCor optional roll (z-axis) correction in radians
  7728. * @param space the choosen space of the target
  7729. * @returns the TransformNode.
  7730. */
  7731. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7732. /**
  7733. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7734. * This Vector3 is expressed in the World space.
  7735. * @param localAxis axis to rotate
  7736. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7737. */
  7738. getDirection(localAxis: Vector3): Vector3;
  7739. /**
  7740. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7741. * localAxis is expressed in the mesh local space.
  7742. * result is computed in the Wordl space from the mesh World matrix.
  7743. * @param localAxis axis to rotate
  7744. * @param result the resulting transformnode
  7745. * @returns this TransformNode.
  7746. */
  7747. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7748. /**
  7749. * Sets this transform node rotation to the given local axis.
  7750. * @param localAxis the axis in local space
  7751. * @param yawCor optional yaw (y-axis) correction in radians
  7752. * @param pitchCor optional pitch (x-axis) correction in radians
  7753. * @param rollCor optional roll (z-axis) correction in radians
  7754. * @returns this TransformNode
  7755. */
  7756. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7757. /**
  7758. * Sets a new pivot point to the current node
  7759. * @param point defines the new pivot point to use
  7760. * @param space defines if the point is in world or local space (local by default)
  7761. * @returns the current TransformNode
  7762. */
  7763. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7764. /**
  7765. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7766. * @returns the pivot point
  7767. */
  7768. getPivotPoint(): Vector3;
  7769. /**
  7770. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7771. * @param result the vector3 to store the result
  7772. * @returns this TransformNode.
  7773. */
  7774. getPivotPointToRef(result: Vector3): TransformNode;
  7775. /**
  7776. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7777. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7778. */
  7779. getAbsolutePivotPoint(): Vector3;
  7780. /**
  7781. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7782. * @param result vector3 to store the result
  7783. * @returns this TransformNode.
  7784. */
  7785. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7786. /**
  7787. * Defines the passed node as the parent of the current node.
  7788. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7789. * @see https://doc.babylonjs.com/how_to/parenting
  7790. * @param node the node ot set as the parent
  7791. * @returns this TransformNode.
  7792. */
  7793. setParent(node: Nullable<Node>): TransformNode;
  7794. private _nonUniformScaling;
  7795. /**
  7796. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7797. */
  7798. readonly nonUniformScaling: boolean;
  7799. /** @hidden */
  7800. _updateNonUniformScalingState(value: boolean): boolean;
  7801. /**
  7802. * Attach the current TransformNode to another TransformNode associated with a bone
  7803. * @param bone Bone affecting the TransformNode
  7804. * @param affectedTransformNode TransformNode associated with the bone
  7805. * @returns this object
  7806. */
  7807. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7808. /**
  7809. * Detach the transform node if its associated with a bone
  7810. * @returns this object
  7811. */
  7812. detachFromBone(): TransformNode;
  7813. private static _rotationAxisCache;
  7814. /**
  7815. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7816. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7817. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7818. * The passed axis is also normalized.
  7819. * @param axis the axis to rotate around
  7820. * @param amount the amount to rotate in radians
  7821. * @param space Space to rotate in (Default: local)
  7822. * @returns the TransformNode.
  7823. */
  7824. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7825. /**
  7826. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7827. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7828. * The passed axis is also normalized. .
  7829. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7830. * @param point the point to rotate around
  7831. * @param axis the axis to rotate around
  7832. * @param amount the amount to rotate in radians
  7833. * @returns the TransformNode
  7834. */
  7835. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7836. /**
  7837. * Translates the mesh along the axis vector for the passed distance in the given space.
  7838. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7839. * @param axis the axis to translate in
  7840. * @param distance the distance to translate
  7841. * @param space Space to rotate in (Default: local)
  7842. * @returns the TransformNode.
  7843. */
  7844. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7845. /**
  7846. * Adds a rotation step to the mesh current rotation.
  7847. * x, y, z are Euler angles expressed in radians.
  7848. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7849. * This means this rotation is made in the mesh local space only.
  7850. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7851. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7852. * ```javascript
  7853. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7854. * ```
  7855. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7856. * 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.
  7857. * @param x Rotation to add
  7858. * @param y Rotation to add
  7859. * @param z Rotation to add
  7860. * @returns the TransformNode.
  7861. */
  7862. addRotation(x: number, y: number, z: number): TransformNode;
  7863. /**
  7864. * @hidden
  7865. */
  7866. protected _getEffectiveParent(): Nullable<Node>;
  7867. /**
  7868. * Computes the world matrix of the node
  7869. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7870. * @returns the world matrix
  7871. */
  7872. computeWorldMatrix(force?: boolean): Matrix;
  7873. protected _afterComputeWorldMatrix(): void;
  7874. /**
  7875. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7876. * @param func callback function to add
  7877. *
  7878. * @returns the TransformNode.
  7879. */
  7880. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7881. /**
  7882. * Removes a registered callback function.
  7883. * @param func callback function to remove
  7884. * @returns the TransformNode.
  7885. */
  7886. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7887. /**
  7888. * Gets the position of the current mesh in camera space
  7889. * @param camera defines the camera to use
  7890. * @returns a position
  7891. */
  7892. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7893. /**
  7894. * Returns the distance from the mesh to the active camera
  7895. * @param camera defines the camera to use
  7896. * @returns the distance
  7897. */
  7898. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7899. /**
  7900. * Clone the current transform node
  7901. * @param name Name of the new clone
  7902. * @param newParent New parent for the clone
  7903. * @param doNotCloneChildren Do not clone children hierarchy
  7904. * @returns the new transform node
  7905. */
  7906. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7907. /**
  7908. * Serializes the objects information.
  7909. * @param currentSerializationObject defines the object to serialize in
  7910. * @returns the serialized object
  7911. */
  7912. serialize(currentSerializationObject?: any): any;
  7913. /**
  7914. * Returns a new TransformNode object parsed from the source provided.
  7915. * @param parsedTransformNode is the source.
  7916. * @param scene the scne the object belongs to
  7917. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7918. * @returns a new TransformNode object parsed from the source provided.
  7919. */
  7920. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7921. /**
  7922. * Get all child-transformNodes of this node
  7923. * @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
  7924. * @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
  7925. * @returns an array of TransformNode
  7926. */
  7927. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7928. /**
  7929. * Releases resources associated with this transform node.
  7930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7932. */
  7933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7934. }
  7935. }
  7936. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7937. /**
  7938. * Class used to override all child animations of a given target
  7939. */
  7940. export class AnimationPropertiesOverride {
  7941. /**
  7942. * Gets or sets a value indicating if animation blending must be used
  7943. */
  7944. enableBlending: boolean;
  7945. /**
  7946. * Gets or sets the blending speed to use when enableBlending is true
  7947. */
  7948. blendingSpeed: number;
  7949. /**
  7950. * Gets or sets the default loop mode to use
  7951. */
  7952. loopMode: number;
  7953. }
  7954. }
  7955. declare module "babylonjs/Bones/bone" {
  7956. import { Skeleton } from "babylonjs/Bones/skeleton";
  7957. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7958. import { Nullable } from "babylonjs/types";
  7959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7960. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7961. import { Node } from "babylonjs/node";
  7962. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7963. /**
  7964. * Class used to store bone information
  7965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7966. */
  7967. export class Bone extends Node {
  7968. /**
  7969. * defines the bone name
  7970. */
  7971. name: string;
  7972. private static _tmpVecs;
  7973. private static _tmpQuat;
  7974. private static _tmpMats;
  7975. /**
  7976. * Gets the list of child bones
  7977. */
  7978. children: Bone[];
  7979. /** Gets the animations associated with this bone */
  7980. animations: import("babylonjs/Animations/animation").Animation[];
  7981. /**
  7982. * Gets or sets bone length
  7983. */
  7984. length: number;
  7985. /**
  7986. * @hidden Internal only
  7987. * Set this value to map this bone to a different index in the transform matrices
  7988. * Set this value to -1 to exclude the bone from the transform matrices
  7989. */
  7990. _index: Nullable<number>;
  7991. private _skeleton;
  7992. private _localMatrix;
  7993. private _restPose;
  7994. private _baseMatrix;
  7995. private _absoluteTransform;
  7996. private _invertedAbsoluteTransform;
  7997. private _parent;
  7998. private _scalingDeterminant;
  7999. private _worldTransform;
  8000. private _localScaling;
  8001. private _localRotation;
  8002. private _localPosition;
  8003. private _needToDecompose;
  8004. private _needToCompose;
  8005. /** @hidden */
  8006. _linkedTransformNode: Nullable<TransformNode>;
  8007. /** @hidden */
  8008. /** @hidden */
  8009. _matrix: Matrix;
  8010. /**
  8011. * Create a new bone
  8012. * @param name defines the bone name
  8013. * @param skeleton defines the parent skeleton
  8014. * @param parentBone defines the parent (can be null if the bone is the root)
  8015. * @param localMatrix defines the local matrix
  8016. * @param restPose defines the rest pose matrix
  8017. * @param baseMatrix defines the base matrix
  8018. * @param index defines index of the bone in the hiearchy
  8019. */
  8020. constructor(
  8021. /**
  8022. * defines the bone name
  8023. */
  8024. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8025. /**
  8026. * Gets the current object class name.
  8027. * @return the class name
  8028. */
  8029. getClassName(): string;
  8030. /**
  8031. * Gets the parent skeleton
  8032. * @returns a skeleton
  8033. */
  8034. getSkeleton(): Skeleton;
  8035. /**
  8036. * Gets parent bone
  8037. * @returns a bone or null if the bone is the root of the bone hierarchy
  8038. */
  8039. getParent(): Nullable<Bone>;
  8040. /**
  8041. * Returns an array containing the root bones
  8042. * @returns an array containing the root bones
  8043. */
  8044. getChildren(): Array<Bone>;
  8045. /**
  8046. * Sets the parent bone
  8047. * @param parent defines the parent (can be null if the bone is the root)
  8048. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8049. */
  8050. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8051. /**
  8052. * Gets the local matrix
  8053. * @returns a matrix
  8054. */
  8055. getLocalMatrix(): Matrix;
  8056. /**
  8057. * Gets the base matrix (initial matrix which remains unchanged)
  8058. * @returns a matrix
  8059. */
  8060. getBaseMatrix(): Matrix;
  8061. /**
  8062. * Gets the rest pose matrix
  8063. * @returns a matrix
  8064. */
  8065. getRestPose(): Matrix;
  8066. /**
  8067. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8068. */
  8069. getWorldMatrix(): Matrix;
  8070. /**
  8071. * Sets the local matrix to rest pose matrix
  8072. */
  8073. returnToRest(): void;
  8074. /**
  8075. * Gets the inverse of the absolute transform matrix.
  8076. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8077. * @returns a matrix
  8078. */
  8079. getInvertedAbsoluteTransform(): Matrix;
  8080. /**
  8081. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8082. * @returns a matrix
  8083. */
  8084. getAbsoluteTransform(): Matrix;
  8085. /**
  8086. * Links with the given transform node.
  8087. * The local matrix of this bone is copied from the transform node every frame.
  8088. * @param transformNode defines the transform node to link to
  8089. */
  8090. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8091. /** Gets or sets current position (in local space) */
  8092. position: Vector3;
  8093. /** Gets or sets current rotation (in local space) */
  8094. rotation: Vector3;
  8095. /** Gets or sets current rotation quaternion (in local space) */
  8096. rotationQuaternion: Quaternion;
  8097. /** Gets or sets current scaling (in local space) */
  8098. scaling: Vector3;
  8099. /**
  8100. * Gets the animation properties override
  8101. */
  8102. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8103. private _decompose;
  8104. private _compose;
  8105. /**
  8106. * Update the base and local matrices
  8107. * @param matrix defines the new base or local matrix
  8108. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8109. * @param updateLocalMatrix defines if the local matrix should be updated
  8110. */
  8111. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8112. /** @hidden */
  8113. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8114. /**
  8115. * Flag the bone as dirty (Forcing it to update everything)
  8116. */
  8117. markAsDirty(): void;
  8118. private _markAsDirtyAndCompose;
  8119. private _markAsDirtyAndDecompose;
  8120. /**
  8121. * Translate the bone in local or world space
  8122. * @param vec The amount to translate the bone
  8123. * @param space The space that the translation is in
  8124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8125. */
  8126. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8127. /**
  8128. * Set the postion of the bone in local or world space
  8129. * @param position The position to set the bone
  8130. * @param space The space that the position is in
  8131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8132. */
  8133. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8134. /**
  8135. * Set the absolute position of the bone (world space)
  8136. * @param position The position to set the bone
  8137. * @param mesh The mesh that this bone is attached to
  8138. */
  8139. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8140. /**
  8141. * Scale the bone on the x, y and z axes (in local space)
  8142. * @param x The amount to scale the bone on the x axis
  8143. * @param y The amount to scale the bone on the y axis
  8144. * @param z The amount to scale the bone on the z axis
  8145. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8146. */
  8147. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8148. /**
  8149. * Set the bone scaling in local space
  8150. * @param scale defines the scaling vector
  8151. */
  8152. setScale(scale: Vector3): void;
  8153. /**
  8154. * Gets the current scaling in local space
  8155. * @returns the current scaling vector
  8156. */
  8157. getScale(): Vector3;
  8158. /**
  8159. * Gets the current scaling in local space and stores it in a target vector
  8160. * @param result defines the target vector
  8161. */
  8162. getScaleToRef(result: Vector3): void;
  8163. /**
  8164. * Set the yaw, pitch, and roll of the bone in local or world space
  8165. * @param yaw The rotation of the bone on the y axis
  8166. * @param pitch The rotation of the bone on the x axis
  8167. * @param roll The rotation of the bone on the z axis
  8168. * @param space The space that the axes of rotation are in
  8169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8170. */
  8171. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8172. /**
  8173. * Add a rotation to the bone on an axis in local or world space
  8174. * @param axis The axis to rotate the bone on
  8175. * @param amount The amount to rotate the bone
  8176. * @param space The space that the axis is in
  8177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8178. */
  8179. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8180. /**
  8181. * Set the rotation of the bone to a particular axis angle in local or world space
  8182. * @param axis The axis to rotate the bone on
  8183. * @param angle The angle that the bone should be rotated to
  8184. * @param space The space that the axis is in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. */
  8187. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8188. /**
  8189. * Set the euler rotation of the bone in local of world space
  8190. * @param rotation The euler rotation that the bone should be set to
  8191. * @param space The space that the rotation is in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. */
  8194. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8195. /**
  8196. * Set the quaternion rotation of the bone in local of world space
  8197. * @param quat The quaternion rotation that the bone should be set to
  8198. * @param space The space that the rotation is in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. */
  8201. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8202. /**
  8203. * Set the rotation matrix of the bone in local of world space
  8204. * @param rotMat The rotation matrix that the bone should be set to
  8205. * @param space The space that the rotation is in
  8206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8207. */
  8208. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8209. private _rotateWithMatrix;
  8210. private _getNegativeRotationToRef;
  8211. /**
  8212. * Get the position of the bone in local or world space
  8213. * @param space The space that the returned position is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. * @returns The position of the bone
  8216. */
  8217. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8218. /**
  8219. * Copy the position of the bone to a vector3 in local or world space
  8220. * @param space The space that the returned position is in
  8221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8222. * @param result The vector3 to copy the position to
  8223. */
  8224. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8225. /**
  8226. * Get the absolute position of the bone (world space)
  8227. * @param mesh The mesh that this bone is attached to
  8228. * @returns The absolute position of the bone
  8229. */
  8230. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8231. /**
  8232. * Copy the absolute position of the bone (world space) to the result param
  8233. * @param mesh The mesh that this bone is attached to
  8234. * @param result The vector3 to copy the absolute position to
  8235. */
  8236. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8237. /**
  8238. * Compute the absolute transforms of this bone and its children
  8239. */
  8240. computeAbsoluteTransforms(): void;
  8241. /**
  8242. * Get the world direction from an axis that is in the local space of the bone
  8243. * @param localAxis The local direction that is used to compute the world direction
  8244. * @param mesh The mesh that this bone is attached to
  8245. * @returns The world direction
  8246. */
  8247. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8248. /**
  8249. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8250. * @param localAxis The local direction that is used to compute the world direction
  8251. * @param mesh The mesh that this bone is attached to
  8252. * @param result The vector3 that the world direction will be copied to
  8253. */
  8254. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8255. /**
  8256. * Get the euler rotation of the bone in local or world space
  8257. * @param space The space that the rotation should be in
  8258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8259. * @returns The euler rotation
  8260. */
  8261. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8262. /**
  8263. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8264. * @param space The space that the rotation should be in
  8265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8266. * @param result The vector3 that the rotation should be copied to
  8267. */
  8268. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8269. /**
  8270. * Get the quaternion rotation of the bone in either local or world space
  8271. * @param space The space that the rotation should be in
  8272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8273. * @returns The quaternion rotation
  8274. */
  8275. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8276. /**
  8277. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8278. * @param space The space that the rotation should be in
  8279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8280. * @param result The quaternion that the rotation should be copied to
  8281. */
  8282. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8283. /**
  8284. * Get the rotation matrix of the bone in local or world space
  8285. * @param space The space that the rotation should be in
  8286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8287. * @returns The rotation matrix
  8288. */
  8289. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8290. /**
  8291. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8292. * @param space The space that the rotation should be in
  8293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8294. * @param result The quaternion that the rotation should be copied to
  8295. */
  8296. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8297. /**
  8298. * Get the world position of a point that is in the local space of the bone
  8299. * @param position The local position
  8300. * @param mesh The mesh that this bone is attached to
  8301. * @returns The world position
  8302. */
  8303. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8304. /**
  8305. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8306. * @param position The local position
  8307. * @param mesh The mesh that this bone is attached to
  8308. * @param result The vector3 that the world position should be copied to
  8309. */
  8310. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8311. /**
  8312. * Get the local position of a point that is in world space
  8313. * @param position The world position
  8314. * @param mesh The mesh that this bone is attached to
  8315. * @returns The local position
  8316. */
  8317. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8318. /**
  8319. * Get the local position of a point that is in world space and copy it to the result param
  8320. * @param position The world position
  8321. * @param mesh The mesh that this bone is attached to
  8322. * @param result The vector3 that the local position should be copied to
  8323. */
  8324. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8325. }
  8326. }
  8327. declare module "babylonjs/Misc/iInspectable" {
  8328. /**
  8329. * Enum that determines the text-wrapping mode to use.
  8330. */
  8331. export enum InspectableType {
  8332. /**
  8333. * Checkbox for booleans
  8334. */
  8335. Checkbox = 0,
  8336. /**
  8337. * Sliders for numbers
  8338. */
  8339. Slider = 1,
  8340. /**
  8341. * Vector3
  8342. */
  8343. Vector3 = 2,
  8344. /**
  8345. * Quaternions
  8346. */
  8347. Quaternion = 3,
  8348. /**
  8349. * Color3
  8350. */
  8351. Color3 = 4
  8352. }
  8353. /**
  8354. * Interface used to define custom inspectable properties.
  8355. * This interface is used by the inspector to display custom property grids
  8356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8357. */
  8358. export interface IInspectable {
  8359. /**
  8360. * Gets the label to display
  8361. */
  8362. label: string;
  8363. /**
  8364. * Gets the name of the property to edit
  8365. */
  8366. propertyName: string;
  8367. /**
  8368. * Gets the type of the editor to use
  8369. */
  8370. type: InspectableType;
  8371. /**
  8372. * Gets the minimum value of the property when using in "slider" mode
  8373. */
  8374. min?: number;
  8375. /**
  8376. * Gets the maximum value of the property when using in "slider" mode
  8377. */
  8378. max?: number;
  8379. /**
  8380. * Gets the setp to use when using in "slider" mode
  8381. */
  8382. step?: number;
  8383. }
  8384. }
  8385. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8386. import { Nullable } from "babylonjs/types";
  8387. import { Scene } from "babylonjs/scene";
  8388. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. /**
  8391. * Class for creating a cube texture
  8392. */
  8393. export class CubeTexture extends BaseTexture {
  8394. private _delayedOnLoad;
  8395. /**
  8396. * The url of the texture
  8397. */
  8398. url: string;
  8399. /**
  8400. * Gets or sets the center of the bounding box associated with the cube texture.
  8401. * It must define where the camera used to render the texture was set
  8402. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8403. */
  8404. boundingBoxPosition: Vector3;
  8405. private _boundingBoxSize;
  8406. /**
  8407. * Gets or sets the size of the bounding box associated with the cube texture
  8408. * When defined, the cubemap will switch to local mode
  8409. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8410. * @example https://www.babylonjs-playground.com/#RNASML
  8411. */
  8412. /**
  8413. * Returns the bounding box size
  8414. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8415. */
  8416. boundingBoxSize: Vector3;
  8417. protected _rotationY: number;
  8418. /**
  8419. * Sets texture matrix rotation angle around Y axis in radians.
  8420. */
  8421. /**
  8422. * Gets texture matrix rotation angle around Y axis radians.
  8423. */
  8424. rotationY: number;
  8425. /**
  8426. * Are mip maps generated for this texture or not.
  8427. */
  8428. readonly noMipmap: boolean;
  8429. private _noMipmap;
  8430. private _files;
  8431. private _extensions;
  8432. private _textureMatrix;
  8433. private _format;
  8434. private _createPolynomials;
  8435. /** @hidden */
  8436. _prefiltered: boolean;
  8437. /**
  8438. * Creates a cube texture from an array of image urls
  8439. * @param files defines an array of image urls
  8440. * @param scene defines the hosting scene
  8441. * @param noMipmap specifies if mip maps are not used
  8442. * @returns a cube texture
  8443. */
  8444. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8445. /**
  8446. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8447. * @param url defines the url of the prefiltered texture
  8448. * @param scene defines the scene the texture is attached to
  8449. * @param forcedExtension defines the extension of the file if different from the url
  8450. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8451. * @return the prefiltered texture
  8452. */
  8453. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8454. /**
  8455. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8456. * as prefiltered data.
  8457. * @param rootUrl defines the url of the texture or the root name of the six images
  8458. * @param scene defines the scene the texture is attached to
  8459. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8460. * @param noMipmap defines if mipmaps should be created or not
  8461. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8462. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8463. * @param onError defines a callback triggered in case of error during load
  8464. * @param format defines the internal format to use for the texture once loaded
  8465. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8466. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8467. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8468. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8469. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8470. * @return the cube texture
  8471. */
  8472. 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);
  8473. /**
  8474. * Get the current class name of the texture useful for serialization or dynamic coding.
  8475. * @returns "CubeTexture"
  8476. */
  8477. getClassName(): string;
  8478. /**
  8479. * Update the url (and optional buffer) of this texture if url was null during construction.
  8480. * @param url the url of the texture
  8481. * @param forcedExtension defines the extension to use
  8482. * @param onLoad callback called when the texture is loaded (defaults to null)
  8483. */
  8484. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8485. /**
  8486. * Delays loading of the cube texture
  8487. * @param forcedExtension defines the extension to use
  8488. */
  8489. delayLoad(forcedExtension?: string): void;
  8490. /**
  8491. * Returns the reflection texture matrix
  8492. * @returns the reflection texture matrix
  8493. */
  8494. getReflectionTextureMatrix(): Matrix;
  8495. /**
  8496. * Sets the reflection texture matrix
  8497. * @param value Reflection texture matrix
  8498. */
  8499. setReflectionTextureMatrix(value: Matrix): void;
  8500. /**
  8501. * Parses text to create a cube texture
  8502. * @param parsedTexture define the serialized text to read from
  8503. * @param scene defines the hosting scene
  8504. * @param rootUrl defines the root url of the cube texture
  8505. * @returns a cube texture
  8506. */
  8507. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8508. /**
  8509. * Makes a clone, or deep copy, of the cube texture
  8510. * @returns a new cube texture
  8511. */
  8512. clone(): CubeTexture;
  8513. }
  8514. }
  8515. declare module "babylonjs/Shaders/postprocess.vertex" {
  8516. /** @hidden */
  8517. export var postprocessVertexShader: {
  8518. name: string;
  8519. shader: string;
  8520. };
  8521. }
  8522. declare module "babylonjs/Cameras/targetCamera" {
  8523. import { Nullable } from "babylonjs/types";
  8524. import { Camera } from "babylonjs/Cameras/camera";
  8525. import { Scene } from "babylonjs/scene";
  8526. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8527. /**
  8528. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8529. * This is the base of the follow, arc rotate cameras and Free camera
  8530. * @see http://doc.babylonjs.com/features/cameras
  8531. */
  8532. export class TargetCamera extends Camera {
  8533. private static _RigCamTransformMatrix;
  8534. private static _TargetTransformMatrix;
  8535. private static _TargetFocalPoint;
  8536. /**
  8537. * Define the current direction the camera is moving to
  8538. */
  8539. cameraDirection: Vector3;
  8540. /**
  8541. * Define the current rotation the camera is rotating to
  8542. */
  8543. cameraRotation: Vector2;
  8544. /**
  8545. * When set, the up vector of the camera will be updated by the rotation of the camera
  8546. */
  8547. updateUpVectorFromRotation: boolean;
  8548. private _tmpQuaternion;
  8549. /**
  8550. * Define the current rotation of the camera
  8551. */
  8552. rotation: Vector3;
  8553. /**
  8554. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8555. */
  8556. rotationQuaternion: Quaternion;
  8557. /**
  8558. * Define the current speed of the camera
  8559. */
  8560. speed: number;
  8561. /**
  8562. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8563. * around all axis.
  8564. */
  8565. noRotationConstraint: boolean;
  8566. /**
  8567. * Define the current target of the camera as an object or a position.
  8568. */
  8569. lockedTarget: any;
  8570. /** @hidden */
  8571. _currentTarget: Vector3;
  8572. /** @hidden */
  8573. _initialFocalDistance: number;
  8574. /** @hidden */
  8575. _viewMatrix: Matrix;
  8576. /** @hidden */
  8577. _camMatrix: Matrix;
  8578. /** @hidden */
  8579. _cameraTransformMatrix: Matrix;
  8580. /** @hidden */
  8581. _cameraRotationMatrix: Matrix;
  8582. /** @hidden */
  8583. _referencePoint: Vector3;
  8584. /** @hidden */
  8585. _transformedReferencePoint: Vector3;
  8586. protected _globalCurrentTarget: Vector3;
  8587. protected _globalCurrentUpVector: Vector3;
  8588. /** @hidden */
  8589. _reset: () => void;
  8590. private _defaultUp;
  8591. /**
  8592. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8593. * This is the base of the follow, arc rotate cameras and Free camera
  8594. * @see http://doc.babylonjs.com/features/cameras
  8595. * @param name Defines the name of the camera in the scene
  8596. * @param position Defines the start position of the camera in the scene
  8597. * @param scene Defines the scene the camera belongs to
  8598. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8599. */
  8600. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8601. /**
  8602. * Gets the position in front of the camera at a given distance.
  8603. * @param distance The distance from the camera we want the position to be
  8604. * @returns the position
  8605. */
  8606. getFrontPosition(distance: number): Vector3;
  8607. /** @hidden */
  8608. _getLockedTargetPosition(): Nullable<Vector3>;
  8609. private _storedPosition;
  8610. private _storedRotation;
  8611. private _storedRotationQuaternion;
  8612. /**
  8613. * Store current camera state of the camera (fov, position, rotation, etc..)
  8614. * @returns the camera
  8615. */
  8616. storeState(): Camera;
  8617. /**
  8618. * Restored camera state. You must call storeState() first
  8619. * @returns whether it was successful or not
  8620. * @hidden
  8621. */
  8622. _restoreStateValues(): boolean;
  8623. /** @hidden */
  8624. _initCache(): void;
  8625. /** @hidden */
  8626. _updateCache(ignoreParentClass?: boolean): void;
  8627. /** @hidden */
  8628. _isSynchronizedViewMatrix(): boolean;
  8629. /** @hidden */
  8630. _computeLocalCameraSpeed(): number;
  8631. /**
  8632. * Defines the target the camera should look at.
  8633. * This will automatically adapt alpha beta and radius to fit within the new target.
  8634. * @param target Defines the new target as a Vector or a mesh
  8635. */
  8636. setTarget(target: Vector3): void;
  8637. /**
  8638. * Return the current target position of the camera. This value is expressed in local space.
  8639. * @returns the target position
  8640. */
  8641. getTarget(): Vector3;
  8642. /** @hidden */
  8643. _decideIfNeedsToMove(): boolean;
  8644. /** @hidden */
  8645. _updatePosition(): void;
  8646. /** @hidden */
  8647. _checkInputs(): void;
  8648. protected _updateCameraRotationMatrix(): void;
  8649. /**
  8650. * 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)
  8651. * @returns the current camera
  8652. */
  8653. private _rotateUpVectorWithCameraRotationMatrix;
  8654. private _cachedRotationZ;
  8655. private _cachedQuaternionRotationZ;
  8656. /** @hidden */
  8657. _getViewMatrix(): Matrix;
  8658. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8659. /**
  8660. * @hidden
  8661. */
  8662. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8663. /**
  8664. * @hidden
  8665. */
  8666. _updateRigCameras(): void;
  8667. private _getRigCamPositionAndTarget;
  8668. /**
  8669. * Gets the current object class name.
  8670. * @return the class name
  8671. */
  8672. getClassName(): string;
  8673. }
  8674. }
  8675. declare module "babylonjs/Cameras/cameraInputsManager" {
  8676. import { Nullable } from "babylonjs/types";
  8677. import { Camera } from "babylonjs/Cameras/camera";
  8678. /**
  8679. * @ignore
  8680. * This is a list of all the different input types that are available in the application.
  8681. * Fo instance: ArcRotateCameraGamepadInput...
  8682. */
  8683. export var CameraInputTypes: {};
  8684. /**
  8685. * This is the contract to implement in order to create a new input class.
  8686. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8687. */
  8688. export interface ICameraInput<TCamera extends Camera> {
  8689. /**
  8690. * Defines the camera the input is attached to.
  8691. */
  8692. camera: Nullable<TCamera>;
  8693. /**
  8694. * Gets the class name of the current intput.
  8695. * @returns the class name
  8696. */
  8697. getClassName(): string;
  8698. /**
  8699. * Get the friendly name associated with the input class.
  8700. * @returns the input friendly name
  8701. */
  8702. getSimpleName(): string;
  8703. /**
  8704. * Attach the input controls to a specific dom element to get the input from.
  8705. * @param element Defines the element the controls should be listened from
  8706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8707. */
  8708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8709. /**
  8710. * Detach the current controls from the specified dom element.
  8711. * @param element Defines the element to stop listening the inputs from
  8712. */
  8713. detachControl(element: Nullable<HTMLElement>): void;
  8714. /**
  8715. * Update the current camera state depending on the inputs that have been used this frame.
  8716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8717. */
  8718. checkInputs?: () => void;
  8719. }
  8720. /**
  8721. * Represents a map of input types to input instance or input index to input instance.
  8722. */
  8723. export interface CameraInputsMap<TCamera extends Camera> {
  8724. /**
  8725. * Accessor to the input by input type.
  8726. */
  8727. [name: string]: ICameraInput<TCamera>;
  8728. /**
  8729. * Accessor to the input by input index.
  8730. */
  8731. [idx: number]: ICameraInput<TCamera>;
  8732. }
  8733. /**
  8734. * This represents the input manager used within a camera.
  8735. * It helps dealing with all the different kind of input attached to a camera.
  8736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8737. */
  8738. export class CameraInputsManager<TCamera extends Camera> {
  8739. /**
  8740. * Defines the list of inputs attahed to the camera.
  8741. */
  8742. attached: CameraInputsMap<TCamera>;
  8743. /**
  8744. * Defines the dom element the camera is collecting inputs from.
  8745. * This is null if the controls have not been attached.
  8746. */
  8747. attachedElement: Nullable<HTMLElement>;
  8748. /**
  8749. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8750. */
  8751. noPreventDefault: boolean;
  8752. /**
  8753. * Defined the camera the input manager belongs to.
  8754. */
  8755. camera: TCamera;
  8756. /**
  8757. * Update the current camera state depending on the inputs that have been used this frame.
  8758. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8759. */
  8760. checkInputs: () => void;
  8761. /**
  8762. * Instantiate a new Camera Input Manager.
  8763. * @param camera Defines the camera the input manager blongs to
  8764. */
  8765. constructor(camera: TCamera);
  8766. /**
  8767. * Add an input method to a camera
  8768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8769. * @param input camera input method
  8770. */
  8771. add(input: ICameraInput<TCamera>): void;
  8772. /**
  8773. * Remove a specific input method from a camera
  8774. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8775. * @param inputToRemove camera input method
  8776. */
  8777. remove(inputToRemove: ICameraInput<TCamera>): void;
  8778. /**
  8779. * Remove a specific input type from a camera
  8780. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8781. * @param inputType the type of the input to remove
  8782. */
  8783. removeByType(inputType: string): void;
  8784. private _addCheckInputs;
  8785. /**
  8786. * Attach the input controls to the currently attached dom element to listen the events from.
  8787. * @param input Defines the input to attach
  8788. */
  8789. attachInput(input: ICameraInput<TCamera>): void;
  8790. /**
  8791. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8792. * @param element Defines the dom element to collect the events from
  8793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8794. */
  8795. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8796. /**
  8797. * Detach the current manager inputs controls from a specific dom element.
  8798. * @param element Defines the dom element to collect the events from
  8799. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8800. */
  8801. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8802. /**
  8803. * Rebuild the dynamic inputCheck function from the current list of
  8804. * defined inputs in the manager.
  8805. */
  8806. rebuildInputCheck(): void;
  8807. /**
  8808. * Remove all attached input methods from a camera
  8809. */
  8810. clear(): void;
  8811. /**
  8812. * Serialize the current input manager attached to a camera.
  8813. * This ensures than once parsed,
  8814. * the input associated to the camera will be identical to the current ones
  8815. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8816. */
  8817. serialize(serializedCamera: any): void;
  8818. /**
  8819. * Parses an input manager serialized JSON to restore the previous list of inputs
  8820. * and states associated to a camera.
  8821. * @param parsedCamera Defines the JSON to parse
  8822. */
  8823. parse(parsedCamera: any): void;
  8824. }
  8825. }
  8826. declare module "babylonjs/Events/keyboardEvents" {
  8827. /**
  8828. * Gather the list of keyboard event types as constants.
  8829. */
  8830. export class KeyboardEventTypes {
  8831. /**
  8832. * The keydown event is fired when a key becomes active (pressed).
  8833. */
  8834. static readonly KEYDOWN: number;
  8835. /**
  8836. * The keyup event is fired when a key has been released.
  8837. */
  8838. static readonly KEYUP: number;
  8839. }
  8840. /**
  8841. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8842. */
  8843. export class KeyboardInfo {
  8844. /**
  8845. * Defines the type of event (KeyboardEventTypes)
  8846. */
  8847. type: number;
  8848. /**
  8849. * Defines the related dom event
  8850. */
  8851. event: KeyboardEvent;
  8852. /**
  8853. * Instantiates a new keyboard info.
  8854. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8855. * @param type Defines the type of event (KeyboardEventTypes)
  8856. * @param event Defines the related dom event
  8857. */
  8858. constructor(
  8859. /**
  8860. * Defines the type of event (KeyboardEventTypes)
  8861. */
  8862. type: number,
  8863. /**
  8864. * Defines the related dom event
  8865. */
  8866. event: KeyboardEvent);
  8867. }
  8868. /**
  8869. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8870. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8871. */
  8872. export class KeyboardInfoPre extends KeyboardInfo {
  8873. /**
  8874. * Defines the type of event (KeyboardEventTypes)
  8875. */
  8876. type: number;
  8877. /**
  8878. * Defines the related dom event
  8879. */
  8880. event: KeyboardEvent;
  8881. /**
  8882. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8883. */
  8884. skipOnPointerObservable: boolean;
  8885. /**
  8886. * Instantiates a new keyboard pre info.
  8887. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8888. * @param type Defines the type of event (KeyboardEventTypes)
  8889. * @param event Defines the related dom event
  8890. */
  8891. constructor(
  8892. /**
  8893. * Defines the type of event (KeyboardEventTypes)
  8894. */
  8895. type: number,
  8896. /**
  8897. * Defines the related dom event
  8898. */
  8899. event: KeyboardEvent);
  8900. }
  8901. }
  8902. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8903. import { Nullable } from "babylonjs/types";
  8904. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8905. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8906. /**
  8907. * Manage the keyboard inputs to control the movement of a free camera.
  8908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8909. */
  8910. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8911. /**
  8912. * Defines the camera the input is attached to.
  8913. */
  8914. camera: FreeCamera;
  8915. /**
  8916. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8917. */
  8918. keysUp: number[];
  8919. /**
  8920. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8921. */
  8922. keysDown: number[];
  8923. /**
  8924. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8925. */
  8926. keysLeft: number[];
  8927. /**
  8928. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8929. */
  8930. keysRight: number[];
  8931. private _keys;
  8932. private _onCanvasBlurObserver;
  8933. private _onKeyboardObserver;
  8934. private _engine;
  8935. private _scene;
  8936. /**
  8937. * Attach the input controls to a specific dom element to get the input from.
  8938. * @param element Defines the element the controls should be listened from
  8939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8940. */
  8941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8942. /**
  8943. * Detach the current controls from the specified dom element.
  8944. * @param element Defines the element to stop listening the inputs from
  8945. */
  8946. detachControl(element: Nullable<HTMLElement>): void;
  8947. /**
  8948. * Update the current camera state depending on the inputs that have been used this frame.
  8949. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8950. */
  8951. checkInputs(): void;
  8952. /**
  8953. * Gets the class name of the current intput.
  8954. * @returns the class name
  8955. */
  8956. getClassName(): string;
  8957. /** @hidden */
  8958. _onLostFocus(): void;
  8959. /**
  8960. * Get the friendly name associated with the input class.
  8961. * @returns the input friendly name
  8962. */
  8963. getSimpleName(): string;
  8964. }
  8965. }
  8966. declare module "babylonjs/Lights/shadowLight" {
  8967. import { Camera } from "babylonjs/Cameras/camera";
  8968. import { Scene } from "babylonjs/scene";
  8969. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8971. import { Light } from "babylonjs/Lights/light";
  8972. /**
  8973. * Interface describing all the common properties and methods a shadow light needs to implement.
  8974. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8975. * as well as binding the different shadow properties to the effects.
  8976. */
  8977. export interface IShadowLight extends Light {
  8978. /**
  8979. * The light id in the scene (used in scene.findLighById for instance)
  8980. */
  8981. id: string;
  8982. /**
  8983. * The position the shdow will be casted from.
  8984. */
  8985. position: Vector3;
  8986. /**
  8987. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8988. */
  8989. direction: Vector3;
  8990. /**
  8991. * The transformed position. Position of the light in world space taking parenting in account.
  8992. */
  8993. transformedPosition: Vector3;
  8994. /**
  8995. * The transformed direction. Direction of the light in world space taking parenting in account.
  8996. */
  8997. transformedDirection: Vector3;
  8998. /**
  8999. * The friendly name of the light in the scene.
  9000. */
  9001. name: string;
  9002. /**
  9003. * Defines the shadow projection clipping minimum z value.
  9004. */
  9005. shadowMinZ: number;
  9006. /**
  9007. * Defines the shadow projection clipping maximum z value.
  9008. */
  9009. shadowMaxZ: number;
  9010. /**
  9011. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9012. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9013. */
  9014. computeTransformedInformation(): boolean;
  9015. /**
  9016. * Gets the scene the light belongs to.
  9017. * @returns The scene
  9018. */
  9019. getScene(): Scene;
  9020. /**
  9021. * Callback defining a custom Projection Matrix Builder.
  9022. * This can be used to override the default projection matrix computation.
  9023. */
  9024. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9025. /**
  9026. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9027. * @param matrix The materix to updated with the projection information
  9028. * @param viewMatrix The transform matrix of the light
  9029. * @param renderList The list of mesh to render in the map
  9030. * @returns The current light
  9031. */
  9032. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9033. /**
  9034. * Gets the current depth scale used in ESM.
  9035. * @returns The scale
  9036. */
  9037. getDepthScale(): number;
  9038. /**
  9039. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9040. * @returns true if a cube texture needs to be use
  9041. */
  9042. needCube(): boolean;
  9043. /**
  9044. * Detects if the projection matrix requires to be recomputed this frame.
  9045. * @returns true if it requires to be recomputed otherwise, false.
  9046. */
  9047. needProjectionMatrixCompute(): boolean;
  9048. /**
  9049. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9050. */
  9051. forceProjectionMatrixCompute(): void;
  9052. /**
  9053. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9054. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9055. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9056. */
  9057. getShadowDirection(faceIndex?: number): Vector3;
  9058. /**
  9059. * Gets the minZ used for shadow according to both the scene and the light.
  9060. * @param activeCamera The camera we are returning the min for
  9061. * @returns the depth min z
  9062. */
  9063. getDepthMinZ(activeCamera: Camera): number;
  9064. /**
  9065. * Gets the maxZ used for shadow according to both the scene and the light.
  9066. * @param activeCamera The camera we are returning the max for
  9067. * @returns the depth max z
  9068. */
  9069. getDepthMaxZ(activeCamera: Camera): number;
  9070. }
  9071. /**
  9072. * Base implementation IShadowLight
  9073. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9074. */
  9075. export abstract class ShadowLight extends Light implements IShadowLight {
  9076. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9077. protected _position: Vector3;
  9078. protected _setPosition(value: Vector3): void;
  9079. /**
  9080. * Sets the position the shadow will be casted from. Also use as the light position for both
  9081. * point and spot lights.
  9082. */
  9083. /**
  9084. * Sets the position the shadow will be casted from. Also use as the light position for both
  9085. * point and spot lights.
  9086. */
  9087. position: Vector3;
  9088. protected _direction: Vector3;
  9089. protected _setDirection(value: Vector3): void;
  9090. /**
  9091. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9092. * Also use as the light direction on spot and directional lights.
  9093. */
  9094. /**
  9095. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9096. * Also use as the light direction on spot and directional lights.
  9097. */
  9098. direction: Vector3;
  9099. private _shadowMinZ;
  9100. /**
  9101. * Gets the shadow projection clipping minimum z value.
  9102. */
  9103. /**
  9104. * Sets the shadow projection clipping minimum z value.
  9105. */
  9106. shadowMinZ: number;
  9107. private _shadowMaxZ;
  9108. /**
  9109. * Sets the shadow projection clipping maximum z value.
  9110. */
  9111. /**
  9112. * Gets the shadow projection clipping maximum z value.
  9113. */
  9114. shadowMaxZ: number;
  9115. /**
  9116. * Callback defining a custom Projection Matrix Builder.
  9117. * This can be used to override the default projection matrix computation.
  9118. */
  9119. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9120. /**
  9121. * The transformed position. Position of the light in world space taking parenting in account.
  9122. */
  9123. transformedPosition: Vector3;
  9124. /**
  9125. * The transformed direction. Direction of the light in world space taking parenting in account.
  9126. */
  9127. transformedDirection: Vector3;
  9128. private _needProjectionMatrixCompute;
  9129. /**
  9130. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9131. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9132. */
  9133. computeTransformedInformation(): boolean;
  9134. /**
  9135. * Return the depth scale used for the shadow map.
  9136. * @returns the depth scale.
  9137. */
  9138. getDepthScale(): number;
  9139. /**
  9140. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9141. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9142. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9143. */
  9144. getShadowDirection(faceIndex?: number): Vector3;
  9145. /**
  9146. * Returns the ShadowLight absolute position in the World.
  9147. * @returns the position vector in world space
  9148. */
  9149. getAbsolutePosition(): Vector3;
  9150. /**
  9151. * Sets the ShadowLight direction toward the passed target.
  9152. * @param target The point to target in local space
  9153. * @returns the updated ShadowLight direction
  9154. */
  9155. setDirectionToTarget(target: Vector3): Vector3;
  9156. /**
  9157. * Returns the light rotation in euler definition.
  9158. * @returns the x y z rotation in local space.
  9159. */
  9160. getRotation(): Vector3;
  9161. /**
  9162. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9163. * @returns true if a cube texture needs to be use
  9164. */
  9165. needCube(): boolean;
  9166. /**
  9167. * Detects if the projection matrix requires to be recomputed this frame.
  9168. * @returns true if it requires to be recomputed otherwise, false.
  9169. */
  9170. needProjectionMatrixCompute(): boolean;
  9171. /**
  9172. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9173. */
  9174. forceProjectionMatrixCompute(): void;
  9175. /** @hidden */
  9176. _initCache(): void;
  9177. /** @hidden */
  9178. _isSynchronized(): boolean;
  9179. /**
  9180. * Computes the world matrix of the node
  9181. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9182. * @returns the world matrix
  9183. */
  9184. computeWorldMatrix(force?: boolean): Matrix;
  9185. /**
  9186. * Gets the minZ used for shadow according to both the scene and the light.
  9187. * @param activeCamera The camera we are returning the min for
  9188. * @returns the depth min z
  9189. */
  9190. getDepthMinZ(activeCamera: Camera): number;
  9191. /**
  9192. * Gets the maxZ used for shadow according to both the scene and the light.
  9193. * @param activeCamera The camera we are returning the max for
  9194. * @returns the depth max z
  9195. */
  9196. getDepthMaxZ(activeCamera: Camera): number;
  9197. /**
  9198. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9199. * @param matrix The materix to updated with the projection information
  9200. * @param viewMatrix The transform matrix of the light
  9201. * @param renderList The list of mesh to render in the map
  9202. * @returns The current light
  9203. */
  9204. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9205. }
  9206. }
  9207. declare module "babylonjs/Materials/materialHelper" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Engine } from "babylonjs/Engines/engine";
  9211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9212. import { Light } from "babylonjs/Lights/light";
  9213. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9214. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9215. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9216. /**
  9217. * "Static Class" containing the most commonly used helper while dealing with material for
  9218. * rendering purpose.
  9219. *
  9220. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9221. *
  9222. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9223. */
  9224. export class MaterialHelper {
  9225. /**
  9226. * Bind the current view position to an effect.
  9227. * @param effect The effect to be bound
  9228. * @param scene The scene the eyes position is used from
  9229. */
  9230. static BindEyePosition(effect: Effect, scene: Scene): void;
  9231. /**
  9232. * Helps preparing the defines values about the UVs in used in the effect.
  9233. * UVs are shared as much as we can accross channels in the shaders.
  9234. * @param texture The texture we are preparing the UVs for
  9235. * @param defines The defines to update
  9236. * @param key The channel key "diffuse", "specular"... used in the shader
  9237. */
  9238. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9239. /**
  9240. * Binds a texture matrix value to its corrsponding uniform
  9241. * @param texture The texture to bind the matrix for
  9242. * @param uniformBuffer The uniform buffer receivin the data
  9243. * @param key The channel key "diffuse", "specular"... used in the shader
  9244. */
  9245. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9246. /**
  9247. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9248. * @param mesh defines the current mesh
  9249. * @param scene defines the current scene
  9250. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9251. * @param pointsCloud defines if point cloud rendering has to be turned on
  9252. * @param fogEnabled defines if fog has to be turned on
  9253. * @param alphaTest defines if alpha testing has to be turned on
  9254. * @param defines defines the current list of defines
  9255. */
  9256. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9257. /**
  9258. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9259. * @param scene defines the current scene
  9260. * @param engine defines the current engine
  9261. * @param defines specifies the list of active defines
  9262. * @param useInstances defines if instances have to be turned on
  9263. * @param useClipPlane defines if clip plane have to be turned on
  9264. */
  9265. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9266. /**
  9267. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9268. * @param mesh The mesh containing the geometry data we will draw
  9269. * @param defines The defines to update
  9270. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9271. * @param useBones Precise whether bones should be used or not (override mesh info)
  9272. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9273. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9274. * @returns false if defines are considered not dirty and have not been checked
  9275. */
  9276. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9277. /**
  9278. * Prepares the defines related to multiview
  9279. * @param scene The scene we are intending to draw
  9280. * @param defines The defines to update
  9281. */
  9282. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9283. /**
  9284. * Prepares the defines related to the light information passed in parameter
  9285. * @param scene The scene we are intending to draw
  9286. * @param mesh The mesh the effect is compiling for
  9287. * @param defines The defines to update
  9288. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9289. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9290. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9291. * @returns true if normals will be required for the rest of the effect
  9292. */
  9293. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9294. /**
  9295. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9296. * that won t be acctive due to defines being turned off.
  9297. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9298. * @param samplersList The samplers list
  9299. * @param defines The defines helping in the list generation
  9300. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9301. */
  9302. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9303. /**
  9304. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9305. * @param defines The defines to update while falling back
  9306. * @param fallbacks The authorized effect fallbacks
  9307. * @param maxSimultaneousLights The maximum number of lights allowed
  9308. * @param rank the current rank of the Effect
  9309. * @returns The newly affected rank
  9310. */
  9311. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9312. /**
  9313. * Prepares the list of attributes required for morph targets according to the effect defines.
  9314. * @param attribs The current list of supported attribs
  9315. * @param mesh The mesh to prepare the morph targets attributes for
  9316. * @param defines The current Defines of the effect
  9317. */
  9318. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9319. /**
  9320. * Prepares the list of attributes required for bones according to the effect defines.
  9321. * @param attribs The current list of supported attribs
  9322. * @param mesh The mesh to prepare the bones attributes for
  9323. * @param defines The current Defines of the effect
  9324. * @param fallbacks The current efffect fallback strategy
  9325. */
  9326. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9327. /**
  9328. * Prepares the list of attributes required for instances according to the effect defines.
  9329. * @param attribs The current list of supported attribs
  9330. * @param defines The current Defines of the effect
  9331. */
  9332. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9333. /**
  9334. * Binds the light shadow information to the effect for the given mesh.
  9335. * @param light The light containing the generator
  9336. * @param scene The scene the lights belongs to
  9337. * @param mesh The mesh we are binding the information to render
  9338. * @param lightIndex The light index in the effect used to render the mesh
  9339. * @param effect The effect we are binding the data to
  9340. */
  9341. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9342. /**
  9343. * Binds the light information to the effect.
  9344. * @param light The light containing the generator
  9345. * @param effect The effect we are binding the data to
  9346. * @param lightIndex The light index in the effect used to render
  9347. */
  9348. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9349. /**
  9350. * Binds the lights information from the scene to the effect for the given mesh.
  9351. * @param scene The scene the lights belongs to
  9352. * @param mesh The mesh we are binding the information to render
  9353. * @param effect The effect we are binding the data to
  9354. * @param defines The generated defines for the effect
  9355. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9356. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9357. */
  9358. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9359. private static _tempFogColor;
  9360. /**
  9361. * Binds the fog information from the scene to the effect for the given mesh.
  9362. * @param scene The scene the lights belongs to
  9363. * @param mesh The mesh we are binding the information to render
  9364. * @param effect The effect we are binding the data to
  9365. * @param linearSpace Defines if the fog effect is applied in linear space
  9366. */
  9367. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9368. /**
  9369. * Binds the bones information from the mesh to the effect.
  9370. * @param mesh The mesh we are binding the information to render
  9371. * @param effect The effect we are binding the data to
  9372. */
  9373. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9374. /**
  9375. * Binds the morph targets information from the mesh to the effect.
  9376. * @param abstractMesh The mesh we are binding the information to render
  9377. * @param effect The effect we are binding the data to
  9378. */
  9379. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9380. /**
  9381. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9382. * @param defines The generated defines used in the effect
  9383. * @param effect The effect we are binding the data to
  9384. * @param scene The scene we are willing to render with logarithmic scale for
  9385. */
  9386. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9387. /**
  9388. * Binds the clip plane information from the scene to the effect.
  9389. * @param scene The scene the clip plane information are extracted from
  9390. * @param effect The effect we are binding the data to
  9391. */
  9392. static BindClipPlane(effect: Effect, scene: Scene): void;
  9393. }
  9394. }
  9395. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9396. /** @hidden */
  9397. export var kernelBlurVaryingDeclaration: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9403. /** @hidden */
  9404. export var kernelBlurFragment: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9410. /** @hidden */
  9411. export var kernelBlurFragment2: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9417. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9418. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9419. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9420. /** @hidden */
  9421. export var kernelBlurPixelShader: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9427. /** @hidden */
  9428. export var kernelBlurVertex: {
  9429. name: string;
  9430. shader: string;
  9431. };
  9432. }
  9433. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9434. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9435. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9436. /** @hidden */
  9437. export var kernelBlurVertexShader: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9443. import { Vector2 } from "babylonjs/Maths/math";
  9444. import { Nullable } from "babylonjs/types";
  9445. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9446. import { Camera } from "babylonjs/Cameras/camera";
  9447. import { Effect } from "babylonjs/Materials/effect";
  9448. import { Engine } from "babylonjs/Engines/engine";
  9449. import "babylonjs/Shaders/kernelBlur.fragment";
  9450. import "babylonjs/Shaders/kernelBlur.vertex";
  9451. /**
  9452. * The Blur Post Process which blurs an image based on a kernel and direction.
  9453. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9454. */
  9455. export class BlurPostProcess extends PostProcess {
  9456. /** The direction in which to blur the image. */
  9457. direction: Vector2;
  9458. private blockCompilation;
  9459. protected _kernel: number;
  9460. protected _idealKernel: number;
  9461. protected _packedFloat: boolean;
  9462. private _staticDefines;
  9463. /**
  9464. * Sets the length in pixels of the blur sample region
  9465. */
  9466. /**
  9467. * Gets the length in pixels of the blur sample region
  9468. */
  9469. kernel: number;
  9470. /**
  9471. * Sets wether or not the blur needs to unpack/repack floats
  9472. */
  9473. /**
  9474. * Gets wether or not the blur is unpacking/repacking floats
  9475. */
  9476. packedFloat: boolean;
  9477. /**
  9478. * Creates a new instance BlurPostProcess
  9479. * @param name The name of the effect.
  9480. * @param direction The direction in which to blur the image.
  9481. * @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.
  9482. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9483. * @param camera The camera to apply the render pass to.
  9484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9485. * @param engine The engine which the post process will be applied. (default: current engine)
  9486. * @param reusable If the post process can be reused on the same frame. (default: false)
  9487. * @param textureType Type of textures used when performing the post process. (default: 0)
  9488. * @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)
  9489. */
  9490. constructor(name: string,
  9491. /** The direction in which to blur the image. */
  9492. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9493. /**
  9494. * Updates the effect with the current post process compile time values and recompiles the shader.
  9495. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9496. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9497. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9498. * @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
  9499. * @param onCompiled Called when the shader has been compiled.
  9500. * @param onError Called if there is an error when compiling a shader.
  9501. */
  9502. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9503. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9504. /**
  9505. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9506. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9507. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9508. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9509. * The gaps between physical kernels are compensated for in the weighting of the samples
  9510. * @param idealKernel Ideal blur kernel.
  9511. * @return Nearest best kernel.
  9512. */
  9513. protected _nearestBestKernel(idealKernel: number): number;
  9514. /**
  9515. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9516. * @param x The point on the Gaussian distribution to sample.
  9517. * @return the value of the Gaussian function at x.
  9518. */
  9519. protected _gaussianWeight(x: number): number;
  9520. /**
  9521. * Generates a string that can be used as a floating point number in GLSL.
  9522. * @param x Value to print.
  9523. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9524. * @return GLSL float string.
  9525. */
  9526. protected _glslFloat(x: number, decimalFigures?: number): string;
  9527. }
  9528. }
  9529. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9530. /** @hidden */
  9531. export var shadowMapPixelShader: {
  9532. name: string;
  9533. shader: string;
  9534. };
  9535. }
  9536. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9537. /** @hidden */
  9538. export var bonesDeclaration: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9544. /** @hidden */
  9545. export var morphTargetsVertexGlobalDeclaration: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9551. /** @hidden */
  9552. export var morphTargetsVertexDeclaration: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9558. /** @hidden */
  9559. export var instancesDeclaration: {
  9560. name: string;
  9561. shader: string;
  9562. };
  9563. }
  9564. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9565. /** @hidden */
  9566. export var helperFunctions: {
  9567. name: string;
  9568. shader: string;
  9569. };
  9570. }
  9571. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9572. /** @hidden */
  9573. export var morphTargetsVertex: {
  9574. name: string;
  9575. shader: string;
  9576. };
  9577. }
  9578. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9579. /** @hidden */
  9580. export var instancesVertex: {
  9581. name: string;
  9582. shader: string;
  9583. };
  9584. }
  9585. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9586. /** @hidden */
  9587. export var bonesVertex: {
  9588. name: string;
  9589. shader: string;
  9590. };
  9591. }
  9592. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9593. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9594. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9595. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9596. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9597. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9598. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9599. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9600. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9601. /** @hidden */
  9602. export var shadowMapVertexShader: {
  9603. name: string;
  9604. shader: string;
  9605. };
  9606. }
  9607. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9608. /** @hidden */
  9609. export var depthBoxBlurPixelShader: {
  9610. name: string;
  9611. shader: string;
  9612. };
  9613. }
  9614. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9615. import { Nullable } from "babylonjs/types";
  9616. import { Scene } from "babylonjs/scene";
  9617. import { Matrix } from "babylonjs/Maths/math";
  9618. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9620. import { Mesh } from "babylonjs/Meshes/mesh";
  9621. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9622. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9623. import { Effect } from "babylonjs/Materials/effect";
  9624. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9625. import "babylonjs/Shaders/shadowMap.fragment";
  9626. import "babylonjs/Shaders/shadowMap.vertex";
  9627. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9628. import { Observable } from "babylonjs/Misc/observable";
  9629. /**
  9630. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9631. */
  9632. export interface ICustomShaderOptions {
  9633. /**
  9634. * Gets or sets the custom shader name to use
  9635. */
  9636. shaderName: string;
  9637. /**
  9638. * The list of attribute names used in the shader
  9639. */
  9640. attributes?: string[];
  9641. /**
  9642. * The list of unifrom names used in the shader
  9643. */
  9644. uniforms?: string[];
  9645. /**
  9646. * The list of sampler names used in the shader
  9647. */
  9648. samplers?: string[];
  9649. /**
  9650. * The list of defines used in the shader
  9651. */
  9652. defines?: string[];
  9653. }
  9654. /**
  9655. * Interface to implement to create a shadow generator compatible with BJS.
  9656. */
  9657. export interface IShadowGenerator {
  9658. /**
  9659. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9660. * @returns The render target texture if present otherwise, null
  9661. */
  9662. getShadowMap(): Nullable<RenderTargetTexture>;
  9663. /**
  9664. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9665. * @returns The render target texture if the shadow map is present otherwise, null
  9666. */
  9667. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9668. /**
  9669. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9670. * @param subMesh The submesh we want to render in the shadow map
  9671. * @param useInstances Defines wether will draw in the map using instances
  9672. * @returns true if ready otherwise, false
  9673. */
  9674. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9675. /**
  9676. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9677. * @param defines Defines of the material we want to update
  9678. * @param lightIndex Index of the light in the enabled light list of the material
  9679. */
  9680. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9681. /**
  9682. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9683. * defined in the generator but impacting the effect).
  9684. * It implies the unifroms available on the materials are the standard BJS ones.
  9685. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9686. * @param effect The effect we are binfing the information for
  9687. */
  9688. bindShadowLight(lightIndex: string, effect: Effect): void;
  9689. /**
  9690. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9691. * (eq to shadow prjection matrix * light transform matrix)
  9692. * @returns The transform matrix used to create the shadow map
  9693. */
  9694. getTransformMatrix(): Matrix;
  9695. /**
  9696. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9697. * Cube and 2D textures for instance.
  9698. */
  9699. recreateShadowMap(): void;
  9700. /**
  9701. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9702. * @param onCompiled Callback triggered at the and of the effects compilation
  9703. * @param options Sets of optional options forcing the compilation with different modes
  9704. */
  9705. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9706. useInstances: boolean;
  9707. }>): void;
  9708. /**
  9709. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9710. * @param options Sets of optional options forcing the compilation with different modes
  9711. * @returns A promise that resolves when the compilation completes
  9712. */
  9713. forceCompilationAsync(options?: Partial<{
  9714. useInstances: boolean;
  9715. }>): Promise<void>;
  9716. /**
  9717. * Serializes the shadow generator setup to a json object.
  9718. * @returns The serialized JSON object
  9719. */
  9720. serialize(): any;
  9721. /**
  9722. * Disposes the Shadow map and related Textures and effects.
  9723. */
  9724. dispose(): void;
  9725. }
  9726. /**
  9727. * Default implementation IShadowGenerator.
  9728. * This is the main object responsible of generating shadows in the framework.
  9729. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9730. */
  9731. export class ShadowGenerator implements IShadowGenerator {
  9732. /**
  9733. * Shadow generator mode None: no filtering applied.
  9734. */
  9735. static readonly FILTER_NONE: number;
  9736. /**
  9737. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9738. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9739. */
  9740. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9741. /**
  9742. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9743. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9744. */
  9745. static readonly FILTER_POISSONSAMPLING: number;
  9746. /**
  9747. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9748. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9749. */
  9750. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9751. /**
  9752. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9753. * edge artifacts on steep falloff.
  9754. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9755. */
  9756. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9757. /**
  9758. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9759. * edge artifacts on steep falloff.
  9760. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9761. */
  9762. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9763. /**
  9764. * Shadow generator mode PCF: Percentage Closer Filtering
  9765. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9766. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9767. */
  9768. static readonly FILTER_PCF: number;
  9769. /**
  9770. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9771. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9772. * Contact Hardening
  9773. */
  9774. static readonly FILTER_PCSS: number;
  9775. /**
  9776. * Reserved for PCF and PCSS
  9777. * Highest Quality.
  9778. *
  9779. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9780. *
  9781. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9782. */
  9783. static readonly QUALITY_HIGH: number;
  9784. /**
  9785. * Reserved for PCF and PCSS
  9786. * Good tradeoff for quality/perf cross devices
  9787. *
  9788. * Execute PCF on a 3*3 kernel.
  9789. *
  9790. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9791. */
  9792. static readonly QUALITY_MEDIUM: number;
  9793. /**
  9794. * Reserved for PCF and PCSS
  9795. * The lowest quality but the fastest.
  9796. *
  9797. * Execute PCF on a 1*1 kernel.
  9798. *
  9799. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9800. */
  9801. static readonly QUALITY_LOW: number;
  9802. /** Gets or sets the custom shader name to use */
  9803. customShaderOptions: ICustomShaderOptions;
  9804. /**
  9805. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9806. */
  9807. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9808. /**
  9809. * Observable triggered before a mesh is rendered in the shadow map.
  9810. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9811. */
  9812. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9813. private _bias;
  9814. /**
  9815. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9816. */
  9817. /**
  9818. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9819. */
  9820. bias: number;
  9821. private _normalBias;
  9822. /**
  9823. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9824. */
  9825. /**
  9826. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9827. */
  9828. normalBias: number;
  9829. private _blurBoxOffset;
  9830. /**
  9831. * Gets the blur box offset: offset applied during the blur pass.
  9832. * Only useful if useKernelBlur = false
  9833. */
  9834. /**
  9835. * Sets the blur box offset: offset applied during the blur pass.
  9836. * Only useful if useKernelBlur = false
  9837. */
  9838. blurBoxOffset: number;
  9839. private _blurScale;
  9840. /**
  9841. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9842. * 2 means half of the size.
  9843. */
  9844. /**
  9845. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9846. * 2 means half of the size.
  9847. */
  9848. blurScale: number;
  9849. private _blurKernel;
  9850. /**
  9851. * Gets the blur kernel: kernel size of the blur pass.
  9852. * Only useful if useKernelBlur = true
  9853. */
  9854. /**
  9855. * Sets the blur kernel: kernel size of the blur pass.
  9856. * Only useful if useKernelBlur = true
  9857. */
  9858. blurKernel: number;
  9859. private _useKernelBlur;
  9860. /**
  9861. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9862. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9863. */
  9864. /**
  9865. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9866. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9867. */
  9868. useKernelBlur: boolean;
  9869. private _depthScale;
  9870. /**
  9871. * Gets the depth scale used in ESM mode.
  9872. */
  9873. /**
  9874. * Sets the depth scale used in ESM mode.
  9875. * This can override the scale stored on the light.
  9876. */
  9877. depthScale: number;
  9878. private _filter;
  9879. /**
  9880. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9881. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9882. */
  9883. /**
  9884. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9885. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9886. */
  9887. filter: number;
  9888. /**
  9889. * Gets if the current filter is set to Poisson Sampling.
  9890. */
  9891. /**
  9892. * Sets the current filter to Poisson Sampling.
  9893. */
  9894. usePoissonSampling: boolean;
  9895. /**
  9896. * Gets if the current filter is set to ESM.
  9897. */
  9898. /**
  9899. * Sets the current filter is to ESM.
  9900. */
  9901. useExponentialShadowMap: boolean;
  9902. /**
  9903. * Gets if the current filter is set to filtered ESM.
  9904. */
  9905. /**
  9906. * Gets if the current filter is set to filtered ESM.
  9907. */
  9908. useBlurExponentialShadowMap: boolean;
  9909. /**
  9910. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9911. * exponential to prevent steep falloff artifacts).
  9912. */
  9913. /**
  9914. * Sets the current filter to "close ESM" (using the inverse of the
  9915. * exponential to prevent steep falloff artifacts).
  9916. */
  9917. useCloseExponentialShadowMap: boolean;
  9918. /**
  9919. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9920. * exponential to prevent steep falloff artifacts).
  9921. */
  9922. /**
  9923. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9924. * exponential to prevent steep falloff artifacts).
  9925. */
  9926. useBlurCloseExponentialShadowMap: boolean;
  9927. /**
  9928. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9929. */
  9930. /**
  9931. * Sets the current filter to "PCF" (percentage closer filtering).
  9932. */
  9933. usePercentageCloserFiltering: boolean;
  9934. private _filteringQuality;
  9935. /**
  9936. * Gets the PCF or PCSS Quality.
  9937. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9938. */
  9939. /**
  9940. * Sets the PCF or PCSS Quality.
  9941. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9942. */
  9943. filteringQuality: number;
  9944. /**
  9945. * Gets if the current filter is set to "PCSS" (contact hardening).
  9946. */
  9947. /**
  9948. * Sets the current filter to "PCSS" (contact hardening).
  9949. */
  9950. useContactHardeningShadow: boolean;
  9951. private _contactHardeningLightSizeUVRatio;
  9952. /**
  9953. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9954. * Using a ratio helps keeping shape stability independently of the map size.
  9955. *
  9956. * It does not account for the light projection as it was having too much
  9957. * instability during the light setup or during light position changes.
  9958. *
  9959. * Only valid if useContactHardeningShadow is true.
  9960. */
  9961. /**
  9962. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9963. * Using a ratio helps keeping shape stability independently of the map size.
  9964. *
  9965. * It does not account for the light projection as it was having too much
  9966. * instability during the light setup or during light position changes.
  9967. *
  9968. * Only valid if useContactHardeningShadow is true.
  9969. */
  9970. contactHardeningLightSizeUVRatio: number;
  9971. private _darkness;
  9972. /**
  9973. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9974. * 0 means strongest and 1 would means no shadow.
  9975. * @returns the darkness.
  9976. */
  9977. getDarkness(): number;
  9978. /**
  9979. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9980. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9981. * @returns the shadow generator allowing fluent coding.
  9982. */
  9983. setDarkness(darkness: number): ShadowGenerator;
  9984. private _transparencyShadow;
  9985. /**
  9986. * Sets the ability to have transparent shadow (boolean).
  9987. * @param transparent True if transparent else False
  9988. * @returns the shadow generator allowing fluent coding
  9989. */
  9990. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9991. private _shadowMap;
  9992. private _shadowMap2;
  9993. /**
  9994. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9995. * @returns The render target texture if present otherwise, null
  9996. */
  9997. getShadowMap(): Nullable<RenderTargetTexture>;
  9998. /**
  9999. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10000. * @returns The render target texture if the shadow map is present otherwise, null
  10001. */
  10002. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10003. /**
  10004. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10005. * @param mesh Mesh to add
  10006. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10007. * @returns the Shadow Generator itself
  10008. */
  10009. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10010. /**
  10011. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10012. * @param mesh Mesh to remove
  10013. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10014. * @returns the Shadow Generator itself
  10015. */
  10016. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10017. /**
  10018. * Controls the extent to which the shadows fade out at the edge of the frustum
  10019. * Used only by directionals and spots
  10020. */
  10021. frustumEdgeFalloff: number;
  10022. private _light;
  10023. /**
  10024. * Returns the associated light object.
  10025. * @returns the light generating the shadow
  10026. */
  10027. getLight(): IShadowLight;
  10028. /**
  10029. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10030. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10031. * It might on the other hand introduce peter panning.
  10032. */
  10033. forceBackFacesOnly: boolean;
  10034. private _scene;
  10035. private _lightDirection;
  10036. private _effect;
  10037. private _viewMatrix;
  10038. private _projectionMatrix;
  10039. private _transformMatrix;
  10040. private _cachedPosition;
  10041. private _cachedDirection;
  10042. private _cachedDefines;
  10043. private _currentRenderID;
  10044. private _boxBlurPostprocess;
  10045. private _kernelBlurXPostprocess;
  10046. private _kernelBlurYPostprocess;
  10047. private _blurPostProcesses;
  10048. private _mapSize;
  10049. private _currentFaceIndex;
  10050. private _currentFaceIndexCache;
  10051. private _textureType;
  10052. private _defaultTextureMatrix;
  10053. /** @hidden */
  10054. static _SceneComponentInitialization: (scene: Scene) => void;
  10055. /**
  10056. * Creates a ShadowGenerator object.
  10057. * A ShadowGenerator is the required tool to use the shadows.
  10058. * Each light casting shadows needs to use its own ShadowGenerator.
  10059. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10060. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10061. * @param light The light object generating the shadows.
  10062. * @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.
  10063. */
  10064. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10065. private _initializeGenerator;
  10066. private _initializeShadowMap;
  10067. private _initializeBlurRTTAndPostProcesses;
  10068. private _renderForShadowMap;
  10069. private _renderSubMeshForShadowMap;
  10070. private _applyFilterValues;
  10071. /**
  10072. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10073. * @param onCompiled Callback triggered at the and of the effects compilation
  10074. * @param options Sets of optional options forcing the compilation with different modes
  10075. */
  10076. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10077. useInstances: boolean;
  10078. }>): void;
  10079. /**
  10080. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10081. * @param options Sets of optional options forcing the compilation with different modes
  10082. * @returns A promise that resolves when the compilation completes
  10083. */
  10084. forceCompilationAsync(options?: Partial<{
  10085. useInstances: boolean;
  10086. }>): Promise<void>;
  10087. /**
  10088. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10089. * @param subMesh The submesh we want to render in the shadow map
  10090. * @param useInstances Defines wether will draw in the map using instances
  10091. * @returns true if ready otherwise, false
  10092. */
  10093. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10094. /**
  10095. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10096. * @param defines Defines of the material we want to update
  10097. * @param lightIndex Index of the light in the enabled light list of the material
  10098. */
  10099. prepareDefines(defines: any, lightIndex: number): void;
  10100. /**
  10101. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10102. * defined in the generator but impacting the effect).
  10103. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10104. * @param effect The effect we are binfing the information for
  10105. */
  10106. bindShadowLight(lightIndex: string, effect: Effect): void;
  10107. /**
  10108. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10109. * (eq to shadow prjection matrix * light transform matrix)
  10110. * @returns The transform matrix used to create the shadow map
  10111. */
  10112. getTransformMatrix(): Matrix;
  10113. /**
  10114. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10115. * Cube and 2D textures for instance.
  10116. */
  10117. recreateShadowMap(): void;
  10118. private _disposeBlurPostProcesses;
  10119. private _disposeRTTandPostProcesses;
  10120. /**
  10121. * Disposes the ShadowGenerator.
  10122. * Returns nothing.
  10123. */
  10124. dispose(): void;
  10125. /**
  10126. * Serializes the shadow generator setup to a json object.
  10127. * @returns The serialized JSON object
  10128. */
  10129. serialize(): any;
  10130. /**
  10131. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10132. * @param parsedShadowGenerator The JSON object to parse
  10133. * @param scene The scene to create the shadow map for
  10134. * @returns The parsed shadow generator
  10135. */
  10136. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10137. }
  10138. }
  10139. declare module "babylonjs/Lights/light" {
  10140. import { Nullable } from "babylonjs/types";
  10141. import { Scene } from "babylonjs/scene";
  10142. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10143. import { Node } from "babylonjs/node";
  10144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10145. import { Effect } from "babylonjs/Materials/effect";
  10146. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10147. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10148. /**
  10149. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10150. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10151. * 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.
  10152. */
  10153. export abstract class Light extends Node {
  10154. /**
  10155. * Falloff Default: light is falling off following the material specification:
  10156. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10157. */
  10158. static readonly FALLOFF_DEFAULT: number;
  10159. /**
  10160. * Falloff Physical: light is falling off following the inverse squared distance law.
  10161. */
  10162. static readonly FALLOFF_PHYSICAL: number;
  10163. /**
  10164. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10165. * to enhance interoperability with other engines.
  10166. */
  10167. static readonly FALLOFF_GLTF: number;
  10168. /**
  10169. * Falloff Standard: light is falling off like in the standard material
  10170. * to enhance interoperability with other materials.
  10171. */
  10172. static readonly FALLOFF_STANDARD: number;
  10173. /**
  10174. * If every light affecting the material is in this lightmapMode,
  10175. * material.lightmapTexture adds or multiplies
  10176. * (depends on material.useLightmapAsShadowmap)
  10177. * after every other light calculations.
  10178. */
  10179. static readonly LIGHTMAP_DEFAULT: number;
  10180. /**
  10181. * material.lightmapTexture as only diffuse lighting from this light
  10182. * adds only specular lighting from this light
  10183. * adds dynamic shadows
  10184. */
  10185. static readonly LIGHTMAP_SPECULAR: number;
  10186. /**
  10187. * material.lightmapTexture as only lighting
  10188. * no light calculation from this light
  10189. * only adds dynamic shadows from this light
  10190. */
  10191. static readonly LIGHTMAP_SHADOWSONLY: number;
  10192. /**
  10193. * Each light type uses the default quantity according to its type:
  10194. * point/spot lights use luminous intensity
  10195. * directional lights use illuminance
  10196. */
  10197. static readonly INTENSITYMODE_AUTOMATIC: number;
  10198. /**
  10199. * lumen (lm)
  10200. */
  10201. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10202. /**
  10203. * candela (lm/sr)
  10204. */
  10205. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10206. /**
  10207. * lux (lm/m^2)
  10208. */
  10209. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10210. /**
  10211. * nit (cd/m^2)
  10212. */
  10213. static readonly INTENSITYMODE_LUMINANCE: number;
  10214. /**
  10215. * Light type const id of the point light.
  10216. */
  10217. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10218. /**
  10219. * Light type const id of the directional light.
  10220. */
  10221. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10222. /**
  10223. * Light type const id of the spot light.
  10224. */
  10225. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10226. /**
  10227. * Light type const id of the hemispheric light.
  10228. */
  10229. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10230. /**
  10231. * Diffuse gives the basic color to an object.
  10232. */
  10233. diffuse: Color3;
  10234. /**
  10235. * Specular produces a highlight color on an object.
  10236. * Note: This is note affecting PBR materials.
  10237. */
  10238. specular: Color3;
  10239. /**
  10240. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10241. * falling off base on range or angle.
  10242. * This can be set to any values in Light.FALLOFF_x.
  10243. *
  10244. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10245. * other types of materials.
  10246. */
  10247. falloffType: number;
  10248. /**
  10249. * Strength of the light.
  10250. * Note: By default it is define in the framework own unit.
  10251. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10252. */
  10253. intensity: number;
  10254. private _range;
  10255. protected _inverseSquaredRange: number;
  10256. /**
  10257. * Defines how far from the source the light is impacting in scene units.
  10258. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10259. */
  10260. /**
  10261. * Defines how far from the source the light is impacting in scene units.
  10262. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10263. */
  10264. range: number;
  10265. /**
  10266. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10267. * of light.
  10268. */
  10269. private _photometricScale;
  10270. private _intensityMode;
  10271. /**
  10272. * Gets the photometric scale used to interpret the intensity.
  10273. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10274. */
  10275. /**
  10276. * Sets the photometric scale used to interpret the intensity.
  10277. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10278. */
  10279. intensityMode: number;
  10280. private _radius;
  10281. /**
  10282. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10283. */
  10284. /**
  10285. * sets the light radius used by PBR Materials to simulate soft area lights.
  10286. */
  10287. radius: number;
  10288. private _renderPriority;
  10289. /**
  10290. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10291. * exceeding the number allowed of the materials.
  10292. */
  10293. renderPriority: number;
  10294. private _shadowEnabled;
  10295. /**
  10296. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10297. * the current shadow generator.
  10298. */
  10299. /**
  10300. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10301. * the current shadow generator.
  10302. */
  10303. shadowEnabled: boolean;
  10304. private _includedOnlyMeshes;
  10305. /**
  10306. * Gets the only meshes impacted by this light.
  10307. */
  10308. /**
  10309. * Sets the only meshes impacted by this light.
  10310. */
  10311. includedOnlyMeshes: AbstractMesh[];
  10312. private _excludedMeshes;
  10313. /**
  10314. * Gets the meshes not impacted by this light.
  10315. */
  10316. /**
  10317. * Sets the meshes not impacted by this light.
  10318. */
  10319. excludedMeshes: AbstractMesh[];
  10320. private _excludeWithLayerMask;
  10321. /**
  10322. * Gets the layer id use to find what meshes are not impacted by the light.
  10323. * Inactive if 0
  10324. */
  10325. /**
  10326. * Sets the layer id use to find what meshes are not impacted by the light.
  10327. * Inactive if 0
  10328. */
  10329. excludeWithLayerMask: number;
  10330. private _includeOnlyWithLayerMask;
  10331. /**
  10332. * Gets the layer id use to find what meshes are impacted by the light.
  10333. * Inactive if 0
  10334. */
  10335. /**
  10336. * Sets the layer id use to find what meshes are impacted by the light.
  10337. * Inactive if 0
  10338. */
  10339. includeOnlyWithLayerMask: number;
  10340. private _lightmapMode;
  10341. /**
  10342. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10343. */
  10344. /**
  10345. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10346. */
  10347. lightmapMode: number;
  10348. /**
  10349. * Shadow generator associted to the light.
  10350. * @hidden Internal use only.
  10351. */
  10352. _shadowGenerator: Nullable<IShadowGenerator>;
  10353. /**
  10354. * @hidden Internal use only.
  10355. */
  10356. _excludedMeshesIds: string[];
  10357. /**
  10358. * @hidden Internal use only.
  10359. */
  10360. _includedOnlyMeshesIds: string[];
  10361. /**
  10362. * The current light unifom buffer.
  10363. * @hidden Internal use only.
  10364. */
  10365. _uniformBuffer: UniformBuffer;
  10366. /**
  10367. * Creates a Light object in the scene.
  10368. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10369. * @param name The firendly name of the light
  10370. * @param scene The scene the light belongs too
  10371. */
  10372. constructor(name: string, scene: Scene);
  10373. protected abstract _buildUniformLayout(): void;
  10374. /**
  10375. * Sets the passed Effect "effect" with the Light information.
  10376. * @param effect The effect to update
  10377. * @param lightIndex The index of the light in the effect to update
  10378. * @returns The light
  10379. */
  10380. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10381. /**
  10382. * Returns the string "Light".
  10383. * @returns the class name
  10384. */
  10385. getClassName(): string;
  10386. /** @hidden */
  10387. readonly _isLight: boolean;
  10388. /**
  10389. * Converts the light information to a readable string for debug purpose.
  10390. * @param fullDetails Supports for multiple levels of logging within scene loading
  10391. * @returns the human readable light info
  10392. */
  10393. toString(fullDetails?: boolean): string;
  10394. /** @hidden */
  10395. protected _syncParentEnabledState(): void;
  10396. /**
  10397. * Set the enabled state of this node.
  10398. * @param value - the new enabled state
  10399. */
  10400. setEnabled(value: boolean): void;
  10401. /**
  10402. * Returns the Light associated shadow generator if any.
  10403. * @return the associated shadow generator.
  10404. */
  10405. getShadowGenerator(): Nullable<IShadowGenerator>;
  10406. /**
  10407. * Returns a Vector3, the absolute light position in the World.
  10408. * @returns the world space position of the light
  10409. */
  10410. getAbsolutePosition(): Vector3;
  10411. /**
  10412. * Specifies if the light will affect the passed mesh.
  10413. * @param mesh The mesh to test against the light
  10414. * @return true the mesh is affected otherwise, false.
  10415. */
  10416. canAffectMesh(mesh: AbstractMesh): boolean;
  10417. /**
  10418. * Sort function to order lights for rendering.
  10419. * @param a First Light object to compare to second.
  10420. * @param b Second Light object to compare first.
  10421. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10422. */
  10423. static CompareLightsPriority(a: Light, b: Light): number;
  10424. /**
  10425. * Releases resources associated with this node.
  10426. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10427. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10428. */
  10429. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10430. /**
  10431. * Returns the light type ID (integer).
  10432. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10433. */
  10434. getTypeID(): number;
  10435. /**
  10436. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10437. * @returns the scaled intensity in intensity mode unit
  10438. */
  10439. getScaledIntensity(): number;
  10440. /**
  10441. * Returns a new Light object, named "name", from the current one.
  10442. * @param name The name of the cloned light
  10443. * @returns the new created light
  10444. */
  10445. clone(name: string): Nullable<Light>;
  10446. /**
  10447. * Serializes the current light into a Serialization object.
  10448. * @returns the serialized object.
  10449. */
  10450. serialize(): any;
  10451. /**
  10452. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10453. * This new light is named "name" and added to the passed scene.
  10454. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10455. * @param name The friendly name of the light
  10456. * @param scene The scene the new light will belong to
  10457. * @returns the constructor function
  10458. */
  10459. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10460. /**
  10461. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10462. * @param parsedLight The JSON representation of the light
  10463. * @param scene The scene to create the parsed light in
  10464. * @returns the created light after parsing
  10465. */
  10466. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10467. private _hookArrayForExcluded;
  10468. private _hookArrayForIncludedOnly;
  10469. private _resyncMeshes;
  10470. /**
  10471. * Forces the meshes to update their light related information in their rendering used effects
  10472. * @hidden Internal Use Only
  10473. */
  10474. _markMeshesAsLightDirty(): void;
  10475. /**
  10476. * Recomputes the cached photometric scale if needed.
  10477. */
  10478. private _computePhotometricScale;
  10479. /**
  10480. * Returns the Photometric Scale according to the light type and intensity mode.
  10481. */
  10482. private _getPhotometricScale;
  10483. /**
  10484. * Reorder the light in the scene according to their defined priority.
  10485. * @hidden Internal Use Only
  10486. */
  10487. _reorderLightsInScene(): void;
  10488. /**
  10489. * Prepares the list of defines specific to the light type.
  10490. * @param defines the list of defines
  10491. * @param lightIndex defines the index of the light for the effect
  10492. */
  10493. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10494. }
  10495. }
  10496. declare module "babylonjs/Actions/action" {
  10497. import { Observable } from "babylonjs/Misc/observable";
  10498. import { Condition } from "babylonjs/Actions/condition";
  10499. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10500. import { ActionManager } from "babylonjs/Actions/actionManager";
  10501. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10502. /**
  10503. * Interface used to define Action
  10504. */
  10505. export interface IAction {
  10506. /**
  10507. * Trigger for the action
  10508. */
  10509. trigger: number;
  10510. /** Options of the trigger */
  10511. triggerOptions: any;
  10512. /**
  10513. * Gets the trigger parameters
  10514. * @returns the trigger parameters
  10515. */
  10516. getTriggerParameter(): any;
  10517. /**
  10518. * Internal only - executes current action event
  10519. * @hidden
  10520. */
  10521. _executeCurrent(evt?: ActionEvent): void;
  10522. /**
  10523. * Serialize placeholder for child classes
  10524. * @param parent of child
  10525. * @returns the serialized object
  10526. */
  10527. serialize(parent: any): any;
  10528. /**
  10529. * Internal only
  10530. * @hidden
  10531. */
  10532. _prepare(): void;
  10533. /**
  10534. * Internal only - manager for action
  10535. * @hidden
  10536. */
  10537. _actionManager: AbstractActionManager;
  10538. }
  10539. /**
  10540. * The action to be carried out following a trigger
  10541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10542. */
  10543. export class Action implements IAction {
  10544. /** the trigger, with or without parameters, for the action */
  10545. triggerOptions: any;
  10546. /**
  10547. * Trigger for the action
  10548. */
  10549. trigger: number;
  10550. /**
  10551. * Internal only - manager for action
  10552. * @hidden
  10553. */
  10554. _actionManager: ActionManager;
  10555. private _nextActiveAction;
  10556. private _child;
  10557. private _condition?;
  10558. private _triggerParameter;
  10559. /**
  10560. * An event triggered prior to action being executed.
  10561. */
  10562. onBeforeExecuteObservable: Observable<Action>;
  10563. /**
  10564. * Creates a new Action
  10565. * @param triggerOptions the trigger, with or without parameters, for the action
  10566. * @param condition an optional determinant of action
  10567. */
  10568. constructor(
  10569. /** the trigger, with or without parameters, for the action */
  10570. triggerOptions: any, condition?: Condition);
  10571. /**
  10572. * Internal only
  10573. * @hidden
  10574. */
  10575. _prepare(): void;
  10576. /**
  10577. * Gets the trigger parameters
  10578. * @returns the trigger parameters
  10579. */
  10580. getTriggerParameter(): any;
  10581. /**
  10582. * Internal only - executes current action event
  10583. * @hidden
  10584. */
  10585. _executeCurrent(evt?: ActionEvent): void;
  10586. /**
  10587. * Execute placeholder for child classes
  10588. * @param evt optional action event
  10589. */
  10590. execute(evt?: ActionEvent): void;
  10591. /**
  10592. * Skips to next active action
  10593. */
  10594. skipToNextActiveAction(): void;
  10595. /**
  10596. * Adds action to chain of actions, may be a DoNothingAction
  10597. * @param action defines the next action to execute
  10598. * @returns The action passed in
  10599. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10600. */
  10601. then(action: Action): Action;
  10602. /**
  10603. * Internal only
  10604. * @hidden
  10605. */
  10606. _getProperty(propertyPath: string): string;
  10607. /**
  10608. * Internal only
  10609. * @hidden
  10610. */
  10611. _getEffectiveTarget(target: any, propertyPath: string): any;
  10612. /**
  10613. * Serialize placeholder for child classes
  10614. * @param parent of child
  10615. * @returns the serialized object
  10616. */
  10617. serialize(parent: any): any;
  10618. /**
  10619. * Internal only called by serialize
  10620. * @hidden
  10621. */
  10622. protected _serialize(serializedAction: any, parent?: any): any;
  10623. /**
  10624. * Internal only
  10625. * @hidden
  10626. */
  10627. static _SerializeValueAsString: (value: any) => string;
  10628. /**
  10629. * Internal only
  10630. * @hidden
  10631. */
  10632. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10633. name: string;
  10634. targetType: string;
  10635. value: string;
  10636. };
  10637. }
  10638. }
  10639. declare module "babylonjs/Actions/condition" {
  10640. import { ActionManager } from "babylonjs/Actions/actionManager";
  10641. /**
  10642. * A Condition applied to an Action
  10643. */
  10644. export class Condition {
  10645. /**
  10646. * Internal only - manager for action
  10647. * @hidden
  10648. */
  10649. _actionManager: ActionManager;
  10650. /**
  10651. * Internal only
  10652. * @hidden
  10653. */
  10654. _evaluationId: number;
  10655. /**
  10656. * Internal only
  10657. * @hidden
  10658. */
  10659. _currentResult: boolean;
  10660. /**
  10661. * Creates a new Condition
  10662. * @param actionManager the manager of the action the condition is applied to
  10663. */
  10664. constructor(actionManager: ActionManager);
  10665. /**
  10666. * Check if the current condition is valid
  10667. * @returns a boolean
  10668. */
  10669. isValid(): boolean;
  10670. /**
  10671. * Internal only
  10672. * @hidden
  10673. */
  10674. _getProperty(propertyPath: string): string;
  10675. /**
  10676. * Internal only
  10677. * @hidden
  10678. */
  10679. _getEffectiveTarget(target: any, propertyPath: string): any;
  10680. /**
  10681. * Serialize placeholder for child classes
  10682. * @returns the serialized object
  10683. */
  10684. serialize(): any;
  10685. /**
  10686. * Internal only
  10687. * @hidden
  10688. */
  10689. protected _serialize(serializedCondition: any): any;
  10690. }
  10691. /**
  10692. * Defines specific conditional operators as extensions of Condition
  10693. */
  10694. export class ValueCondition extends Condition {
  10695. /** path to specify the property of the target the conditional operator uses */
  10696. propertyPath: string;
  10697. /** the value compared by the conditional operator against the current value of the property */
  10698. value: any;
  10699. /** the conditional operator, default ValueCondition.IsEqual */
  10700. operator: number;
  10701. /**
  10702. * Internal only
  10703. * @hidden
  10704. */
  10705. private static _IsEqual;
  10706. /**
  10707. * Internal only
  10708. * @hidden
  10709. */
  10710. private static _IsDifferent;
  10711. /**
  10712. * Internal only
  10713. * @hidden
  10714. */
  10715. private static _IsGreater;
  10716. /**
  10717. * Internal only
  10718. * @hidden
  10719. */
  10720. private static _IsLesser;
  10721. /**
  10722. * returns the number for IsEqual
  10723. */
  10724. static readonly IsEqual: number;
  10725. /**
  10726. * Returns the number for IsDifferent
  10727. */
  10728. static readonly IsDifferent: number;
  10729. /**
  10730. * Returns the number for IsGreater
  10731. */
  10732. static readonly IsGreater: number;
  10733. /**
  10734. * Returns the number for IsLesser
  10735. */
  10736. static readonly IsLesser: number;
  10737. /**
  10738. * Internal only The action manager for the condition
  10739. * @hidden
  10740. */
  10741. _actionManager: ActionManager;
  10742. /**
  10743. * Internal only
  10744. * @hidden
  10745. */
  10746. private _target;
  10747. /**
  10748. * Internal only
  10749. * @hidden
  10750. */
  10751. private _effectiveTarget;
  10752. /**
  10753. * Internal only
  10754. * @hidden
  10755. */
  10756. private _property;
  10757. /**
  10758. * Creates a new ValueCondition
  10759. * @param actionManager manager for the action the condition applies to
  10760. * @param target for the action
  10761. * @param propertyPath path to specify the property of the target the conditional operator uses
  10762. * @param value the value compared by the conditional operator against the current value of the property
  10763. * @param operator the conditional operator, default ValueCondition.IsEqual
  10764. */
  10765. constructor(actionManager: ActionManager, target: any,
  10766. /** path to specify the property of the target the conditional operator uses */
  10767. propertyPath: string,
  10768. /** the value compared by the conditional operator against the current value of the property */
  10769. value: any,
  10770. /** the conditional operator, default ValueCondition.IsEqual */
  10771. operator?: number);
  10772. /**
  10773. * Compares the given value with the property value for the specified conditional operator
  10774. * @returns the result of the comparison
  10775. */
  10776. isValid(): boolean;
  10777. /**
  10778. * Serialize the ValueCondition into a JSON compatible object
  10779. * @returns serialization object
  10780. */
  10781. serialize(): any;
  10782. /**
  10783. * Gets the name of the conditional operator for the ValueCondition
  10784. * @param operator the conditional operator
  10785. * @returns the name
  10786. */
  10787. static GetOperatorName(operator: number): string;
  10788. }
  10789. /**
  10790. * Defines a predicate condition as an extension of Condition
  10791. */
  10792. export class PredicateCondition extends Condition {
  10793. /** defines the predicate function used to validate the condition */
  10794. predicate: () => boolean;
  10795. /**
  10796. * Internal only - manager for action
  10797. * @hidden
  10798. */
  10799. _actionManager: ActionManager;
  10800. /**
  10801. * Creates a new PredicateCondition
  10802. * @param actionManager manager for the action the condition applies to
  10803. * @param predicate defines the predicate function used to validate the condition
  10804. */
  10805. constructor(actionManager: ActionManager,
  10806. /** defines the predicate function used to validate the condition */
  10807. predicate: () => boolean);
  10808. /**
  10809. * @returns the validity of the predicate condition
  10810. */
  10811. isValid(): boolean;
  10812. }
  10813. /**
  10814. * Defines a state condition as an extension of Condition
  10815. */
  10816. export class StateCondition extends Condition {
  10817. /** Value to compare with target state */
  10818. value: string;
  10819. /**
  10820. * Internal only - manager for action
  10821. * @hidden
  10822. */
  10823. _actionManager: ActionManager;
  10824. /**
  10825. * Internal only
  10826. * @hidden
  10827. */
  10828. private _target;
  10829. /**
  10830. * Creates a new StateCondition
  10831. * @param actionManager manager for the action the condition applies to
  10832. * @param target of the condition
  10833. * @param value to compare with target state
  10834. */
  10835. constructor(actionManager: ActionManager, target: any,
  10836. /** Value to compare with target state */
  10837. value: string);
  10838. /**
  10839. * Gets a boolean indicating if the current condition is met
  10840. * @returns the validity of the state
  10841. */
  10842. isValid(): boolean;
  10843. /**
  10844. * Serialize the StateCondition into a JSON compatible object
  10845. * @returns serialization object
  10846. */
  10847. serialize(): any;
  10848. }
  10849. }
  10850. declare module "babylonjs/Actions/directActions" {
  10851. import { Action } from "babylonjs/Actions/action";
  10852. import { Condition } from "babylonjs/Actions/condition";
  10853. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10854. /**
  10855. * This defines an action responsible to toggle a boolean once triggered.
  10856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10857. */
  10858. export class SwitchBooleanAction extends Action {
  10859. /**
  10860. * The path to the boolean property in the target object
  10861. */
  10862. propertyPath: string;
  10863. private _target;
  10864. private _effectiveTarget;
  10865. private _property;
  10866. /**
  10867. * Instantiate the action
  10868. * @param triggerOptions defines the trigger options
  10869. * @param target defines the object containing the boolean
  10870. * @param propertyPath defines the path to the boolean property in the target object
  10871. * @param condition defines the trigger related conditions
  10872. */
  10873. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10874. /** @hidden */
  10875. _prepare(): void;
  10876. /**
  10877. * Execute the action toggle the boolean value.
  10878. */
  10879. execute(): void;
  10880. /**
  10881. * Serializes the actions and its related information.
  10882. * @param parent defines the object to serialize in
  10883. * @returns the serialized object
  10884. */
  10885. serialize(parent: any): any;
  10886. }
  10887. /**
  10888. * This defines an action responsible to set a the state field of the target
  10889. * to a desired value once triggered.
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10891. */
  10892. export class SetStateAction extends Action {
  10893. /**
  10894. * The value to store in the state field.
  10895. */
  10896. value: string;
  10897. private _target;
  10898. /**
  10899. * Instantiate the action
  10900. * @param triggerOptions defines the trigger options
  10901. * @param target defines the object containing the state property
  10902. * @param value defines the value to store in the state field
  10903. * @param condition defines the trigger related conditions
  10904. */
  10905. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10906. /**
  10907. * Execute the action and store the value on the target state property.
  10908. */
  10909. execute(): void;
  10910. /**
  10911. * Serializes the actions and its related information.
  10912. * @param parent defines the object to serialize in
  10913. * @returns the serialized object
  10914. */
  10915. serialize(parent: any): any;
  10916. }
  10917. /**
  10918. * This defines an action responsible to set a property of the target
  10919. * to a desired value once triggered.
  10920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10921. */
  10922. export class SetValueAction extends Action {
  10923. /**
  10924. * The path of the property to set in the target.
  10925. */
  10926. propertyPath: string;
  10927. /**
  10928. * The value to set in the property
  10929. */
  10930. value: any;
  10931. private _target;
  10932. private _effectiveTarget;
  10933. private _property;
  10934. /**
  10935. * Instantiate the action
  10936. * @param triggerOptions defines the trigger options
  10937. * @param target defines the object containing the property
  10938. * @param propertyPath defines the path of the property to set in the target
  10939. * @param value defines the value to set in the property
  10940. * @param condition defines the trigger related conditions
  10941. */
  10942. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10943. /** @hidden */
  10944. _prepare(): void;
  10945. /**
  10946. * Execute the action and set the targetted property to the desired value.
  10947. */
  10948. execute(): void;
  10949. /**
  10950. * Serializes the actions and its related information.
  10951. * @param parent defines the object to serialize in
  10952. * @returns the serialized object
  10953. */
  10954. serialize(parent: any): any;
  10955. }
  10956. /**
  10957. * This defines an action responsible to increment the target value
  10958. * to a desired value once triggered.
  10959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10960. */
  10961. export class IncrementValueAction extends Action {
  10962. /**
  10963. * The path of the property to increment in the target.
  10964. */
  10965. propertyPath: string;
  10966. /**
  10967. * The value we should increment the property by.
  10968. */
  10969. value: any;
  10970. private _target;
  10971. private _effectiveTarget;
  10972. private _property;
  10973. /**
  10974. * Instantiate the action
  10975. * @param triggerOptions defines the trigger options
  10976. * @param target defines the object containing the property
  10977. * @param propertyPath defines the path of the property to increment in the target
  10978. * @param value defines the value value we should increment the property by
  10979. * @param condition defines the trigger related conditions
  10980. */
  10981. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10982. /** @hidden */
  10983. _prepare(): void;
  10984. /**
  10985. * Execute the action and increment the target of the value amount.
  10986. */
  10987. execute(): void;
  10988. /**
  10989. * Serializes the actions and its related information.
  10990. * @param parent defines the object to serialize in
  10991. * @returns the serialized object
  10992. */
  10993. serialize(parent: any): any;
  10994. }
  10995. /**
  10996. * This defines an action responsible to start an animation once triggered.
  10997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10998. */
  10999. export class PlayAnimationAction extends Action {
  11000. /**
  11001. * Where the animation should start (animation frame)
  11002. */
  11003. from: number;
  11004. /**
  11005. * Where the animation should stop (animation frame)
  11006. */
  11007. to: number;
  11008. /**
  11009. * Define if the animation should loop or stop after the first play.
  11010. */
  11011. loop?: boolean;
  11012. private _target;
  11013. /**
  11014. * Instantiate the action
  11015. * @param triggerOptions defines the trigger options
  11016. * @param target defines the target animation or animation name
  11017. * @param from defines from where the animation should start (animation frame)
  11018. * @param end defines where the animation should stop (animation frame)
  11019. * @param loop defines if the animation should loop or stop after the first play
  11020. * @param condition defines the trigger related conditions
  11021. */
  11022. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11023. /** @hidden */
  11024. _prepare(): void;
  11025. /**
  11026. * Execute the action and play the animation.
  11027. */
  11028. execute(): void;
  11029. /**
  11030. * Serializes the actions and its related information.
  11031. * @param parent defines the object to serialize in
  11032. * @returns the serialized object
  11033. */
  11034. serialize(parent: any): any;
  11035. }
  11036. /**
  11037. * This defines an action responsible to stop an animation once triggered.
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11039. */
  11040. export class StopAnimationAction extends Action {
  11041. private _target;
  11042. /**
  11043. * Instantiate the action
  11044. * @param triggerOptions defines the trigger options
  11045. * @param target defines the target animation or animation name
  11046. * @param condition defines the trigger related conditions
  11047. */
  11048. constructor(triggerOptions: any, target: any, condition?: Condition);
  11049. /** @hidden */
  11050. _prepare(): void;
  11051. /**
  11052. * Execute the action and stop the animation.
  11053. */
  11054. execute(): void;
  11055. /**
  11056. * Serializes the actions and its related information.
  11057. * @param parent defines the object to serialize in
  11058. * @returns the serialized object
  11059. */
  11060. serialize(parent: any): any;
  11061. }
  11062. /**
  11063. * This defines an action responsible that does nothing once triggered.
  11064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11065. */
  11066. export class DoNothingAction extends Action {
  11067. /**
  11068. * Instantiate the action
  11069. * @param triggerOptions defines the trigger options
  11070. * @param condition defines the trigger related conditions
  11071. */
  11072. constructor(triggerOptions?: any, condition?: Condition);
  11073. /**
  11074. * Execute the action and do nothing.
  11075. */
  11076. execute(): void;
  11077. /**
  11078. * Serializes the actions and its related information.
  11079. * @param parent defines the object to serialize in
  11080. * @returns the serialized object
  11081. */
  11082. serialize(parent: any): any;
  11083. }
  11084. /**
  11085. * This defines an action responsible to trigger several actions once triggered.
  11086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11087. */
  11088. export class CombineAction extends Action {
  11089. /**
  11090. * The list of aggregated animations to run.
  11091. */
  11092. children: Action[];
  11093. /**
  11094. * Instantiate the action
  11095. * @param triggerOptions defines the trigger options
  11096. * @param children defines the list of aggregated animations to run
  11097. * @param condition defines the trigger related conditions
  11098. */
  11099. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11100. /** @hidden */
  11101. _prepare(): void;
  11102. /**
  11103. * Execute the action and executes all the aggregated actions.
  11104. */
  11105. execute(evt: ActionEvent): void;
  11106. /**
  11107. * Serializes the actions and its related information.
  11108. * @param parent defines the object to serialize in
  11109. * @returns the serialized object
  11110. */
  11111. serialize(parent: any): any;
  11112. }
  11113. /**
  11114. * This defines an action responsible to run code (external event) once triggered.
  11115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11116. */
  11117. export class ExecuteCodeAction extends Action {
  11118. /**
  11119. * The callback function to run.
  11120. */
  11121. func: (evt: ActionEvent) => void;
  11122. /**
  11123. * Instantiate the action
  11124. * @param triggerOptions defines the trigger options
  11125. * @param func defines the callback function to run
  11126. * @param condition defines the trigger related conditions
  11127. */
  11128. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11129. /**
  11130. * Execute the action and run the attached code.
  11131. */
  11132. execute(evt: ActionEvent): void;
  11133. }
  11134. /**
  11135. * This defines an action responsible to set the parent property of the target once triggered.
  11136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11137. */
  11138. export class SetParentAction extends Action {
  11139. private _parent;
  11140. private _target;
  11141. /**
  11142. * Instantiate the action
  11143. * @param triggerOptions defines the trigger options
  11144. * @param target defines the target containing the parent property
  11145. * @param parent defines from where the animation should start (animation frame)
  11146. * @param condition defines the trigger related conditions
  11147. */
  11148. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11149. /** @hidden */
  11150. _prepare(): void;
  11151. /**
  11152. * Execute the action and set the parent property.
  11153. */
  11154. execute(): void;
  11155. /**
  11156. * Serializes the actions and its related information.
  11157. * @param parent defines the object to serialize in
  11158. * @returns the serialized object
  11159. */
  11160. serialize(parent: any): any;
  11161. }
  11162. }
  11163. declare module "babylonjs/Actions/actionManager" {
  11164. import { Nullable } from "babylonjs/types";
  11165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11166. import { Scene } from "babylonjs/scene";
  11167. import { IAction } from "babylonjs/Actions/action";
  11168. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11169. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11170. /**
  11171. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11172. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11174. */
  11175. export class ActionManager extends AbstractActionManager {
  11176. /**
  11177. * Nothing
  11178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11179. */
  11180. static readonly NothingTrigger: number;
  11181. /**
  11182. * On pick
  11183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11184. */
  11185. static readonly OnPickTrigger: number;
  11186. /**
  11187. * On left pick
  11188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11189. */
  11190. static readonly OnLeftPickTrigger: number;
  11191. /**
  11192. * On right pick
  11193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11194. */
  11195. static readonly OnRightPickTrigger: number;
  11196. /**
  11197. * On center pick
  11198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11199. */
  11200. static readonly OnCenterPickTrigger: number;
  11201. /**
  11202. * On pick down
  11203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11204. */
  11205. static readonly OnPickDownTrigger: number;
  11206. /**
  11207. * On double pick
  11208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11209. */
  11210. static readonly OnDoublePickTrigger: number;
  11211. /**
  11212. * On pick up
  11213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11214. */
  11215. static readonly OnPickUpTrigger: number;
  11216. /**
  11217. * On pick out.
  11218. * This trigger will only be raised if you also declared a OnPickDown
  11219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11220. */
  11221. static readonly OnPickOutTrigger: number;
  11222. /**
  11223. * On long press
  11224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11225. */
  11226. static readonly OnLongPressTrigger: number;
  11227. /**
  11228. * On pointer over
  11229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11230. */
  11231. static readonly OnPointerOverTrigger: number;
  11232. /**
  11233. * On pointer out
  11234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11235. */
  11236. static readonly OnPointerOutTrigger: number;
  11237. /**
  11238. * On every frame
  11239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11240. */
  11241. static readonly OnEveryFrameTrigger: number;
  11242. /**
  11243. * On intersection enter
  11244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11245. */
  11246. static readonly OnIntersectionEnterTrigger: number;
  11247. /**
  11248. * On intersection exit
  11249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11250. */
  11251. static readonly OnIntersectionExitTrigger: number;
  11252. /**
  11253. * On key down
  11254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11255. */
  11256. static readonly OnKeyDownTrigger: number;
  11257. /**
  11258. * On key up
  11259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11260. */
  11261. static readonly OnKeyUpTrigger: number;
  11262. private _scene;
  11263. /**
  11264. * Creates a new action manager
  11265. * @param scene defines the hosting scene
  11266. */
  11267. constructor(scene: Scene);
  11268. /**
  11269. * Releases all associated resources
  11270. */
  11271. dispose(): void;
  11272. /**
  11273. * Gets hosting scene
  11274. * @returns the hosting scene
  11275. */
  11276. getScene(): Scene;
  11277. /**
  11278. * Does this action manager handles actions of any of the given triggers
  11279. * @param triggers defines the triggers to be tested
  11280. * @return a boolean indicating whether one (or more) of the triggers is handled
  11281. */
  11282. hasSpecificTriggers(triggers: number[]): boolean;
  11283. /**
  11284. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11285. * speed.
  11286. * @param triggerA defines the trigger to be tested
  11287. * @param triggerB defines the trigger to be tested
  11288. * @return a boolean indicating whether one (or more) of the triggers is handled
  11289. */
  11290. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11291. /**
  11292. * Does this action manager handles actions of a given trigger
  11293. * @param trigger defines the trigger to be tested
  11294. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11295. * @return whether the trigger is handled
  11296. */
  11297. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11298. /**
  11299. * Does this action manager has pointer triggers
  11300. */
  11301. readonly hasPointerTriggers: boolean;
  11302. /**
  11303. * Does this action manager has pick triggers
  11304. */
  11305. readonly hasPickTriggers: boolean;
  11306. /**
  11307. * Registers an action to this action manager
  11308. * @param action defines the action to be registered
  11309. * @return the action amended (prepared) after registration
  11310. */
  11311. registerAction(action: IAction): Nullable<IAction>;
  11312. /**
  11313. * Unregisters an action to this action manager
  11314. * @param action defines the action to be unregistered
  11315. * @return a boolean indicating whether the action has been unregistered
  11316. */
  11317. unregisterAction(action: IAction): Boolean;
  11318. /**
  11319. * Process a specific trigger
  11320. * @param trigger defines the trigger to process
  11321. * @param evt defines the event details to be processed
  11322. */
  11323. processTrigger(trigger: number, evt?: IActionEvent): void;
  11324. /** @hidden */
  11325. _getEffectiveTarget(target: any, propertyPath: string): any;
  11326. /** @hidden */
  11327. _getProperty(propertyPath: string): string;
  11328. /**
  11329. * Serialize this manager to a JSON object
  11330. * @param name defines the property name to store this manager
  11331. * @returns a JSON representation of this manager
  11332. */
  11333. serialize(name: string): any;
  11334. /**
  11335. * Creates a new ActionManager from a JSON data
  11336. * @param parsedActions defines the JSON data to read from
  11337. * @param object defines the hosting mesh
  11338. * @param scene defines the hosting scene
  11339. */
  11340. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11341. /**
  11342. * Get a trigger name by index
  11343. * @param trigger defines the trigger index
  11344. * @returns a trigger name
  11345. */
  11346. static GetTriggerName(trigger: number): string;
  11347. }
  11348. }
  11349. declare module "babylonjs/Culling/ray" {
  11350. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11351. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11353. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11354. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11355. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11356. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11357. /**
  11358. * Class representing a ray with position and direction
  11359. */
  11360. export class Ray {
  11361. /** origin point */
  11362. origin: Vector3;
  11363. /** direction */
  11364. direction: Vector3;
  11365. /** length of the ray */
  11366. length: number;
  11367. private static readonly TmpVector3;
  11368. private _tmpRay;
  11369. /**
  11370. * Creates a new ray
  11371. * @param origin origin point
  11372. * @param direction direction
  11373. * @param length length of the ray
  11374. */
  11375. constructor(
  11376. /** origin point */
  11377. origin: Vector3,
  11378. /** direction */
  11379. direction: Vector3,
  11380. /** length of the ray */
  11381. length?: number);
  11382. /**
  11383. * Checks if the ray intersects a box
  11384. * @param minimum bound of the box
  11385. * @param maximum bound of the box
  11386. * @param intersectionTreshold extra extend to be added to the box in all direction
  11387. * @returns if the box was hit
  11388. */
  11389. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11390. /**
  11391. * Checks if the ray intersects a box
  11392. * @param box the bounding box to check
  11393. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11394. * @returns if the box was hit
  11395. */
  11396. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11397. /**
  11398. * If the ray hits a sphere
  11399. * @param sphere the bounding sphere to check
  11400. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11401. * @returns true if it hits the sphere
  11402. */
  11403. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11404. /**
  11405. * If the ray hits a triange
  11406. * @param vertex0 triangle vertex
  11407. * @param vertex1 triangle vertex
  11408. * @param vertex2 triangle vertex
  11409. * @returns intersection information if hit
  11410. */
  11411. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11412. /**
  11413. * Checks if ray intersects a plane
  11414. * @param plane the plane to check
  11415. * @returns the distance away it was hit
  11416. */
  11417. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11418. /**
  11419. * Checks if ray intersects a mesh
  11420. * @param mesh the mesh to check
  11421. * @param fastCheck if only the bounding box should checked
  11422. * @returns picking info of the intersecton
  11423. */
  11424. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11425. /**
  11426. * Checks if ray intersects a mesh
  11427. * @param meshes the meshes to check
  11428. * @param fastCheck if only the bounding box should checked
  11429. * @param results array to store result in
  11430. * @returns Array of picking infos
  11431. */
  11432. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11433. private _comparePickingInfo;
  11434. private static smallnum;
  11435. private static rayl;
  11436. /**
  11437. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11438. * @param sega the first point of the segment to test the intersection against
  11439. * @param segb the second point of the segment to test the intersection against
  11440. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11441. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11442. */
  11443. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11444. /**
  11445. * Update the ray from viewport position
  11446. * @param x position
  11447. * @param y y position
  11448. * @param viewportWidth viewport width
  11449. * @param viewportHeight viewport height
  11450. * @param world world matrix
  11451. * @param view view matrix
  11452. * @param projection projection matrix
  11453. * @returns this ray updated
  11454. */
  11455. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11456. /**
  11457. * Creates a ray with origin and direction of 0,0,0
  11458. * @returns the new ray
  11459. */
  11460. static Zero(): Ray;
  11461. /**
  11462. * Creates a new ray from screen space and viewport
  11463. * @param x position
  11464. * @param y y position
  11465. * @param viewportWidth viewport width
  11466. * @param viewportHeight viewport height
  11467. * @param world world matrix
  11468. * @param view view matrix
  11469. * @param projection projection matrix
  11470. * @returns new ray
  11471. */
  11472. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11473. /**
  11474. * 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
  11475. * transformed to the given world matrix.
  11476. * @param origin The origin point
  11477. * @param end The end point
  11478. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11479. * @returns the new ray
  11480. */
  11481. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11482. /**
  11483. * Transforms a ray by a matrix
  11484. * @param ray ray to transform
  11485. * @param matrix matrix to apply
  11486. * @returns the resulting new ray
  11487. */
  11488. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11489. /**
  11490. * Transforms a ray by a matrix
  11491. * @param ray ray to transform
  11492. * @param matrix matrix to apply
  11493. * @param result ray to store result in
  11494. */
  11495. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11496. /**
  11497. * Unproject a ray from screen space to object space
  11498. * @param sourceX defines the screen space x coordinate to use
  11499. * @param sourceY defines the screen space y coordinate to use
  11500. * @param viewportWidth defines the current width of the viewport
  11501. * @param viewportHeight defines the current height of the viewport
  11502. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11503. * @param view defines the view matrix to use
  11504. * @param projection defines the projection matrix to use
  11505. */
  11506. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11507. }
  11508. /**
  11509. * Type used to define predicate used to select faces when a mesh intersection is detected
  11510. */
  11511. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11512. module "babylonjs/scene" {
  11513. interface Scene {
  11514. /** @hidden */
  11515. _tempPickingRay: Nullable<Ray>;
  11516. /** @hidden */
  11517. _cachedRayForTransform: Ray;
  11518. /** @hidden */
  11519. _pickWithRayInverseMatrix: Matrix;
  11520. /** @hidden */
  11521. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11522. /** @hidden */
  11523. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11524. }
  11525. }
  11526. }
  11527. declare module "babylonjs/sceneComponent" {
  11528. import { Scene } from "babylonjs/scene";
  11529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11530. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11531. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11532. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11533. import { Nullable } from "babylonjs/types";
  11534. import { Camera } from "babylonjs/Cameras/camera";
  11535. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11536. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11537. import { AbstractScene } from "babylonjs/abstractScene";
  11538. /**
  11539. * Groups all the scene component constants in one place to ease maintenance.
  11540. * @hidden
  11541. */
  11542. export class SceneComponentConstants {
  11543. static readonly NAME_EFFECTLAYER: string;
  11544. static readonly NAME_LAYER: string;
  11545. static readonly NAME_LENSFLARESYSTEM: string;
  11546. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11547. static readonly NAME_PARTICLESYSTEM: string;
  11548. static readonly NAME_GAMEPAD: string;
  11549. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11550. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11551. static readonly NAME_DEPTHRENDERER: string;
  11552. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11553. static readonly NAME_SPRITE: string;
  11554. static readonly NAME_OUTLINERENDERER: string;
  11555. static readonly NAME_PROCEDURALTEXTURE: string;
  11556. static readonly NAME_SHADOWGENERATOR: string;
  11557. static readonly NAME_OCTREE: string;
  11558. static readonly NAME_PHYSICSENGINE: string;
  11559. static readonly NAME_AUDIO: string;
  11560. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11561. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11562. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11563. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11564. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11565. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11566. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11567. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11568. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11569. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11570. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11571. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11572. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11573. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11574. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11575. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11576. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11577. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11578. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11579. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11580. static readonly STEP_AFTERRENDER_AUDIO: number;
  11581. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11582. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11583. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11584. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11585. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11586. static readonly STEP_POINTERMOVE_SPRITE: number;
  11587. static readonly STEP_POINTERDOWN_SPRITE: number;
  11588. static readonly STEP_POINTERUP_SPRITE: number;
  11589. }
  11590. /**
  11591. * This represents a scene component.
  11592. *
  11593. * This is used to decouple the dependency the scene is having on the different workloads like
  11594. * layers, post processes...
  11595. */
  11596. export interface ISceneComponent {
  11597. /**
  11598. * The name of the component. Each component must have a unique name.
  11599. */
  11600. name: string;
  11601. /**
  11602. * The scene the component belongs to.
  11603. */
  11604. scene: Scene;
  11605. /**
  11606. * Register the component to one instance of a scene.
  11607. */
  11608. register(): void;
  11609. /**
  11610. * Rebuilds the elements related to this component in case of
  11611. * context lost for instance.
  11612. */
  11613. rebuild(): void;
  11614. /**
  11615. * Disposes the component and the associated ressources.
  11616. */
  11617. dispose(): void;
  11618. }
  11619. /**
  11620. * This represents a SERIALIZABLE scene component.
  11621. *
  11622. * This extends Scene Component to add Serialization methods on top.
  11623. */
  11624. export interface ISceneSerializableComponent extends ISceneComponent {
  11625. /**
  11626. * Adds all the element from the container to the scene
  11627. * @param container the container holding the elements
  11628. */
  11629. addFromContainer(container: AbstractScene): void;
  11630. /**
  11631. * Removes all the elements in the container from the scene
  11632. * @param container contains the elements to remove
  11633. * @param dispose if the removed element should be disposed (default: false)
  11634. */
  11635. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11636. /**
  11637. * Serializes the component data to the specified json object
  11638. * @param serializationObject The object to serialize to
  11639. */
  11640. serialize(serializationObject: any): void;
  11641. }
  11642. /**
  11643. * Strong typing of a Mesh related stage step action
  11644. */
  11645. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11646. /**
  11647. * Strong typing of a Evaluate Sub Mesh related stage step action
  11648. */
  11649. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11650. /**
  11651. * Strong typing of a Active Mesh related stage step action
  11652. */
  11653. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11654. /**
  11655. * Strong typing of a Camera related stage step action
  11656. */
  11657. export type CameraStageAction = (camera: Camera) => void;
  11658. /**
  11659. * Strong typing of a Camera Frame buffer related stage step action
  11660. */
  11661. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11662. /**
  11663. * Strong typing of a Render Target related stage step action
  11664. */
  11665. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11666. /**
  11667. * Strong typing of a RenderingGroup related stage step action
  11668. */
  11669. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11670. /**
  11671. * Strong typing of a Mesh Render related stage step action
  11672. */
  11673. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11674. /**
  11675. * Strong typing of a simple stage step action
  11676. */
  11677. export type SimpleStageAction = () => void;
  11678. /**
  11679. * Strong typing of a render target action.
  11680. */
  11681. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11682. /**
  11683. * Strong typing of a pointer move action.
  11684. */
  11685. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11686. /**
  11687. * Strong typing of a pointer up/down action.
  11688. */
  11689. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11690. /**
  11691. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11692. * @hidden
  11693. */
  11694. export class Stage<T extends Function> extends Array<{
  11695. index: number;
  11696. component: ISceneComponent;
  11697. action: T;
  11698. }> {
  11699. /**
  11700. * Hide ctor from the rest of the world.
  11701. * @param items The items to add.
  11702. */
  11703. private constructor();
  11704. /**
  11705. * Creates a new Stage.
  11706. * @returns A new instance of a Stage
  11707. */
  11708. static Create<T extends Function>(): Stage<T>;
  11709. /**
  11710. * Registers a step in an ordered way in the targeted stage.
  11711. * @param index Defines the position to register the step in
  11712. * @param component Defines the component attached to the step
  11713. * @param action Defines the action to launch during the step
  11714. */
  11715. registerStep(index: number, component: ISceneComponent, action: T): void;
  11716. /**
  11717. * Clears all the steps from the stage.
  11718. */
  11719. clear(): void;
  11720. }
  11721. }
  11722. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11723. import { Nullable } from "babylonjs/types";
  11724. import { Observable } from "babylonjs/Misc/observable";
  11725. import { Scene } from "babylonjs/scene";
  11726. import { Sprite } from "babylonjs/Sprites/sprite";
  11727. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11728. import { Ray } from "babylonjs/Culling/ray";
  11729. import { Camera } from "babylonjs/Cameras/camera";
  11730. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11731. import { ISceneComponent } from "babylonjs/sceneComponent";
  11732. module "babylonjs/scene" {
  11733. interface Scene {
  11734. /** @hidden */
  11735. _pointerOverSprite: Nullable<Sprite>;
  11736. /** @hidden */
  11737. _pickedDownSprite: Nullable<Sprite>;
  11738. /** @hidden */
  11739. _tempSpritePickingRay: Nullable<Ray>;
  11740. /**
  11741. * All of the sprite managers added to this scene
  11742. * @see http://doc.babylonjs.com/babylon101/sprites
  11743. */
  11744. spriteManagers: Array<ISpriteManager>;
  11745. /**
  11746. * An event triggered when sprites rendering is about to start
  11747. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11748. */
  11749. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11750. /**
  11751. * An event triggered when sprites rendering is done
  11752. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11753. */
  11754. onAfterSpritesRenderingObservable: Observable<Scene>;
  11755. /** @hidden */
  11756. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11757. /** Launch a ray to try to pick a sprite in the scene
  11758. * @param x position on screen
  11759. * @param y position on screen
  11760. * @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
  11761. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11762. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11763. * @returns a PickingInfo
  11764. */
  11765. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11766. /** Use the given ray to pick a sprite in the scene
  11767. * @param ray The ray (in world space) to use to pick meshes
  11768. * @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
  11769. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11770. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11771. * @returns a PickingInfo
  11772. */
  11773. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11774. /**
  11775. * Force the sprite under the pointer
  11776. * @param sprite defines the sprite to use
  11777. */
  11778. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11779. /**
  11780. * Gets the sprite under the pointer
  11781. * @returns a Sprite or null if no sprite is under the pointer
  11782. */
  11783. getPointerOverSprite(): Nullable<Sprite>;
  11784. }
  11785. }
  11786. /**
  11787. * Defines the sprite scene component responsible to manage sprites
  11788. * in a given scene.
  11789. */
  11790. export class SpriteSceneComponent implements ISceneComponent {
  11791. /**
  11792. * The component name helpfull to identify the component in the list of scene components.
  11793. */
  11794. readonly name: string;
  11795. /**
  11796. * The scene the component belongs to.
  11797. */
  11798. scene: Scene;
  11799. /** @hidden */
  11800. private _spritePredicate;
  11801. /**
  11802. * Creates a new instance of the component for the given scene
  11803. * @param scene Defines the scene to register the component in
  11804. */
  11805. constructor(scene: Scene);
  11806. /**
  11807. * Registers the component in a given scene
  11808. */
  11809. register(): void;
  11810. /**
  11811. * Rebuilds the elements related to this component in case of
  11812. * context lost for instance.
  11813. */
  11814. rebuild(): void;
  11815. /**
  11816. * Disposes the component and the associated ressources.
  11817. */
  11818. dispose(): void;
  11819. private _pickSpriteButKeepRay;
  11820. private _pointerMove;
  11821. private _pointerDown;
  11822. private _pointerUp;
  11823. }
  11824. }
  11825. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11826. /** @hidden */
  11827. export var fogFragmentDeclaration: {
  11828. name: string;
  11829. shader: string;
  11830. };
  11831. }
  11832. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11833. /** @hidden */
  11834. export var fogFragment: {
  11835. name: string;
  11836. shader: string;
  11837. };
  11838. }
  11839. declare module "babylonjs/Shaders/sprites.fragment" {
  11840. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11841. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11842. /** @hidden */
  11843. export var spritesPixelShader: {
  11844. name: string;
  11845. shader: string;
  11846. };
  11847. }
  11848. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11849. /** @hidden */
  11850. export var fogVertexDeclaration: {
  11851. name: string;
  11852. shader: string;
  11853. };
  11854. }
  11855. declare module "babylonjs/Shaders/sprites.vertex" {
  11856. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11857. /** @hidden */
  11858. export var spritesVertexShader: {
  11859. name: string;
  11860. shader: string;
  11861. };
  11862. }
  11863. declare module "babylonjs/Sprites/spriteManager" {
  11864. import { IDisposable, Scene } from "babylonjs/scene";
  11865. import { Nullable } from "babylonjs/types";
  11866. import { Observable } from "babylonjs/Misc/observable";
  11867. import { Sprite } from "babylonjs/Sprites/sprite";
  11868. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11869. import { Camera } from "babylonjs/Cameras/camera";
  11870. import { Texture } from "babylonjs/Materials/Textures/texture";
  11871. import "babylonjs/Shaders/sprites.fragment";
  11872. import "babylonjs/Shaders/sprites.vertex";
  11873. import { Ray } from "babylonjs/Culling/ray";
  11874. /**
  11875. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11876. */
  11877. export interface ISpriteManager extends IDisposable {
  11878. /**
  11879. * Restricts the camera to viewing objects with the same layerMask.
  11880. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11881. */
  11882. layerMask: number;
  11883. /**
  11884. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11885. */
  11886. isPickable: boolean;
  11887. /**
  11888. * Specifies the rendering group id for this mesh (0 by default)
  11889. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11890. */
  11891. renderingGroupId: number;
  11892. /**
  11893. * Defines the list of sprites managed by the manager.
  11894. */
  11895. sprites: Array<Sprite>;
  11896. /**
  11897. * Tests the intersection of a sprite with a specific ray.
  11898. * @param ray The ray we are sending to test the collision
  11899. * @param camera The camera space we are sending rays in
  11900. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11901. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11902. * @returns picking info or null.
  11903. */
  11904. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11905. /**
  11906. * Renders the list of sprites on screen.
  11907. */
  11908. render(): void;
  11909. }
  11910. /**
  11911. * Class used to manage multiple sprites on the same spritesheet
  11912. * @see http://doc.babylonjs.com/babylon101/sprites
  11913. */
  11914. export class SpriteManager implements ISpriteManager {
  11915. /** defines the manager's name */
  11916. name: string;
  11917. /** Gets the list of sprites */
  11918. sprites: Sprite[];
  11919. /** Gets or sets the rendering group id (0 by default) */
  11920. renderingGroupId: number;
  11921. /** Gets or sets camera layer mask */
  11922. layerMask: number;
  11923. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11924. fogEnabled: boolean;
  11925. /** Gets or sets a boolean indicating if the sprites are pickable */
  11926. isPickable: boolean;
  11927. /** Defines the default width of a cell in the spritesheet */
  11928. cellWidth: number;
  11929. /** Defines the default height of a cell in the spritesheet */
  11930. cellHeight: number;
  11931. /**
  11932. * An event triggered when the manager is disposed.
  11933. */
  11934. onDisposeObservable: Observable<SpriteManager>;
  11935. private _onDisposeObserver;
  11936. /**
  11937. * Callback called when the manager is disposed
  11938. */
  11939. onDispose: () => void;
  11940. private _capacity;
  11941. private _spriteTexture;
  11942. private _epsilon;
  11943. private _scene;
  11944. private _vertexData;
  11945. private _buffer;
  11946. private _vertexBuffers;
  11947. private _indexBuffer;
  11948. private _effectBase;
  11949. private _effectFog;
  11950. /**
  11951. * Gets or sets the spritesheet texture
  11952. */
  11953. texture: Texture;
  11954. /**
  11955. * Creates a new sprite manager
  11956. * @param name defines the manager's name
  11957. * @param imgUrl defines the sprite sheet url
  11958. * @param capacity defines the maximum allowed number of sprites
  11959. * @param cellSize defines the size of a sprite cell
  11960. * @param scene defines the hosting scene
  11961. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11962. * @param samplingMode defines the smapling mode to use with spritesheet
  11963. */
  11964. constructor(
  11965. /** defines the manager's name */
  11966. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11967. private _appendSpriteVertex;
  11968. /**
  11969. * Intersects the sprites with a ray
  11970. * @param ray defines the ray to intersect with
  11971. * @param camera defines the current active camera
  11972. * @param predicate defines a predicate used to select candidate sprites
  11973. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11974. * @returns null if no hit or a PickingInfo
  11975. */
  11976. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11977. /**
  11978. * Render all child sprites
  11979. */
  11980. render(): void;
  11981. /**
  11982. * Release associated resources
  11983. */
  11984. dispose(): void;
  11985. }
  11986. }
  11987. declare module "babylonjs/Sprites/sprite" {
  11988. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11989. import { Nullable } from "babylonjs/types";
  11990. import { ActionManager } from "babylonjs/Actions/actionManager";
  11991. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11992. /**
  11993. * Class used to represent a sprite
  11994. * @see http://doc.babylonjs.com/babylon101/sprites
  11995. */
  11996. export class Sprite {
  11997. /** defines the name */
  11998. name: string;
  11999. /** Gets or sets the current world position */
  12000. position: Vector3;
  12001. /** Gets or sets the main color */
  12002. color: Color4;
  12003. /** Gets or sets the width */
  12004. width: number;
  12005. /** Gets or sets the height */
  12006. height: number;
  12007. /** Gets or sets rotation angle */
  12008. angle: number;
  12009. /** Gets or sets the cell index in the sprite sheet */
  12010. cellIndex: number;
  12011. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12012. invertU: number;
  12013. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12014. invertV: number;
  12015. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12016. disposeWhenFinishedAnimating: boolean;
  12017. /** Gets the list of attached animations */
  12018. animations: Animation[];
  12019. /** Gets or sets a boolean indicating if the sprite can be picked */
  12020. isPickable: boolean;
  12021. /**
  12022. * Gets or sets the associated action manager
  12023. */
  12024. actionManager: Nullable<ActionManager>;
  12025. private _animationStarted;
  12026. private _loopAnimation;
  12027. private _fromIndex;
  12028. private _toIndex;
  12029. private _delay;
  12030. private _direction;
  12031. private _manager;
  12032. private _time;
  12033. private _onAnimationEnd;
  12034. /**
  12035. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12036. */
  12037. isVisible: boolean;
  12038. /**
  12039. * Gets or sets the sprite size
  12040. */
  12041. size: number;
  12042. /**
  12043. * Creates a new Sprite
  12044. * @param name defines the name
  12045. * @param manager defines the manager
  12046. */
  12047. constructor(
  12048. /** defines the name */
  12049. name: string, manager: ISpriteManager);
  12050. /**
  12051. * Starts an animation
  12052. * @param from defines the initial key
  12053. * @param to defines the end key
  12054. * @param loop defines if the animation must loop
  12055. * @param delay defines the start delay (in ms)
  12056. * @param onAnimationEnd defines a callback to call when animation ends
  12057. */
  12058. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12059. /** Stops current animation (if any) */
  12060. stopAnimation(): void;
  12061. /** @hidden */
  12062. _animate(deltaTime: number): void;
  12063. /** Release associated resources */
  12064. dispose(): void;
  12065. }
  12066. }
  12067. declare module "babylonjs/Collisions/pickingInfo" {
  12068. import { Nullable } from "babylonjs/types";
  12069. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12071. import { Sprite } from "babylonjs/Sprites/sprite";
  12072. import { Ray } from "babylonjs/Culling/ray";
  12073. /**
  12074. * Information about the result of picking within a scene
  12075. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12076. */
  12077. export class PickingInfo {
  12078. /** @hidden */
  12079. _pickingUnavailable: boolean;
  12080. /**
  12081. * If the pick collided with an object
  12082. */
  12083. hit: boolean;
  12084. /**
  12085. * Distance away where the pick collided
  12086. */
  12087. distance: number;
  12088. /**
  12089. * The location of pick collision
  12090. */
  12091. pickedPoint: Nullable<Vector3>;
  12092. /**
  12093. * The mesh corresponding the the pick collision
  12094. */
  12095. pickedMesh: Nullable<AbstractMesh>;
  12096. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12097. bu: number;
  12098. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12099. bv: number;
  12100. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12101. faceId: number;
  12102. /** Id of the the submesh that was picked */
  12103. subMeshId: number;
  12104. /** If a sprite was picked, this will be the sprite the pick collided with */
  12105. pickedSprite: Nullable<Sprite>;
  12106. /**
  12107. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12108. */
  12109. originMesh: Nullable<AbstractMesh>;
  12110. /**
  12111. * The ray that was used to perform the picking.
  12112. */
  12113. ray: Nullable<Ray>;
  12114. /**
  12115. * Gets the normal correspodning to the face the pick collided with
  12116. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12117. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12118. * @returns The normal correspodning to the face the pick collided with
  12119. */
  12120. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12121. /**
  12122. * Gets the texture coordinates of where the pick occured
  12123. * @returns the vector containing the coordnates of the texture
  12124. */
  12125. getTextureCoordinates(): Nullable<Vector2>;
  12126. }
  12127. }
  12128. declare module "babylonjs/Events/pointerEvents" {
  12129. import { Nullable } from "babylonjs/types";
  12130. import { Vector2 } from "babylonjs/Maths/math";
  12131. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12132. import { Ray } from "babylonjs/Culling/ray";
  12133. /**
  12134. * Gather the list of pointer event types as constants.
  12135. */
  12136. export class PointerEventTypes {
  12137. /**
  12138. * 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.
  12139. */
  12140. static readonly POINTERDOWN: number;
  12141. /**
  12142. * The pointerup event is fired when a pointer is no longer active.
  12143. */
  12144. static readonly POINTERUP: number;
  12145. /**
  12146. * The pointermove event is fired when a pointer changes coordinates.
  12147. */
  12148. static readonly POINTERMOVE: number;
  12149. /**
  12150. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12151. */
  12152. static readonly POINTERWHEEL: number;
  12153. /**
  12154. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12155. */
  12156. static readonly POINTERPICK: number;
  12157. /**
  12158. * The pointertap event is fired when a the object has been touched and released without drag.
  12159. */
  12160. static readonly POINTERTAP: number;
  12161. /**
  12162. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12163. */
  12164. static readonly POINTERDOUBLETAP: number;
  12165. }
  12166. /**
  12167. * Base class of pointer info types.
  12168. */
  12169. export class PointerInfoBase {
  12170. /**
  12171. * Defines the type of event (PointerEventTypes)
  12172. */
  12173. type: number;
  12174. /**
  12175. * Defines the related dom event
  12176. */
  12177. event: PointerEvent | MouseWheelEvent;
  12178. /**
  12179. * Instantiates the base class of pointers info.
  12180. * @param type Defines the type of event (PointerEventTypes)
  12181. * @param event Defines the related dom event
  12182. */
  12183. constructor(
  12184. /**
  12185. * Defines the type of event (PointerEventTypes)
  12186. */
  12187. type: number,
  12188. /**
  12189. * Defines the related dom event
  12190. */
  12191. event: PointerEvent | MouseWheelEvent);
  12192. }
  12193. /**
  12194. * This class is used to store pointer related info for the onPrePointerObservable event.
  12195. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12196. */
  12197. export class PointerInfoPre extends PointerInfoBase {
  12198. /**
  12199. * Ray from a pointer if availible (eg. 6dof controller)
  12200. */
  12201. ray: Nullable<Ray>;
  12202. /**
  12203. * Defines the local position of the pointer on the canvas.
  12204. */
  12205. localPosition: Vector2;
  12206. /**
  12207. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12208. */
  12209. skipOnPointerObservable: boolean;
  12210. /**
  12211. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12212. * @param type Defines the type of event (PointerEventTypes)
  12213. * @param event Defines the related dom event
  12214. * @param localX Defines the local x coordinates of the pointer when the event occured
  12215. * @param localY Defines the local y coordinates of the pointer when the event occured
  12216. */
  12217. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12218. }
  12219. /**
  12220. * This type contains all the data related to a pointer event in Babylon.js.
  12221. * 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.
  12222. */
  12223. export class PointerInfo extends PointerInfoBase {
  12224. /**
  12225. * Defines the picking info associated to the info (if any)\
  12226. */
  12227. pickInfo: Nullable<PickingInfo>;
  12228. /**
  12229. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12230. * @param type Defines the type of event (PointerEventTypes)
  12231. * @param event Defines the related dom event
  12232. * @param pickInfo Defines the picking info associated to the info (if any)\
  12233. */
  12234. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12235. /**
  12236. * Defines the picking info associated to the info (if any)\
  12237. */
  12238. pickInfo: Nullable<PickingInfo>);
  12239. }
  12240. /**
  12241. * Data relating to a touch event on the screen.
  12242. */
  12243. export interface PointerTouch {
  12244. /**
  12245. * X coordinate of touch.
  12246. */
  12247. x: number;
  12248. /**
  12249. * Y coordinate of touch.
  12250. */
  12251. y: number;
  12252. /**
  12253. * Id of touch. Unique for each finger.
  12254. */
  12255. pointerId: number;
  12256. /**
  12257. * Event type passed from DOM.
  12258. */
  12259. type: any;
  12260. }
  12261. }
  12262. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12263. import { Observable } from "babylonjs/Misc/observable";
  12264. import { Nullable } from "babylonjs/types";
  12265. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12266. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12267. /**
  12268. * Manage the mouse inputs to control the movement of a free camera.
  12269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12270. */
  12271. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12272. /**
  12273. * Define if touch is enabled in the mouse input
  12274. */
  12275. touchEnabled: boolean;
  12276. /**
  12277. * Defines the camera the input is attached to.
  12278. */
  12279. camera: FreeCamera;
  12280. /**
  12281. * Defines the buttons associated with the input to handle camera move.
  12282. */
  12283. buttons: number[];
  12284. /**
  12285. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12286. */
  12287. angularSensibility: number;
  12288. private _pointerInput;
  12289. private _onMouseMove;
  12290. private _observer;
  12291. private previousPosition;
  12292. /**
  12293. * Observable for when a pointer move event occurs containing the move offset
  12294. */
  12295. onPointerMovedObservable: Observable<{
  12296. offsetX: number;
  12297. offsetY: number;
  12298. }>;
  12299. /**
  12300. * @hidden
  12301. * If the camera should be rotated automatically based on pointer movement
  12302. */
  12303. _allowCameraRotation: boolean;
  12304. /**
  12305. * Manage the mouse inputs to control the movement of a free camera.
  12306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12307. * @param touchEnabled Defines if touch is enabled or not
  12308. */
  12309. constructor(
  12310. /**
  12311. * Define if touch is enabled in the mouse input
  12312. */
  12313. touchEnabled?: boolean);
  12314. /**
  12315. * Attach the input controls to a specific dom element to get the input from.
  12316. * @param element Defines the element the controls should be listened from
  12317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12318. */
  12319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12320. /**
  12321. * Called on JS contextmenu event.
  12322. * Override this method to provide functionality.
  12323. */
  12324. protected onContextMenu(evt: PointerEvent): void;
  12325. /**
  12326. * Detach the current controls from the specified dom element.
  12327. * @param element Defines the element to stop listening the inputs from
  12328. */
  12329. detachControl(element: Nullable<HTMLElement>): void;
  12330. /**
  12331. * Gets the class name of the current intput.
  12332. * @returns the class name
  12333. */
  12334. getClassName(): string;
  12335. /**
  12336. * Get the friendly name associated with the input class.
  12337. * @returns the input friendly name
  12338. */
  12339. getSimpleName(): string;
  12340. }
  12341. }
  12342. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12343. import { Nullable } from "babylonjs/types";
  12344. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12345. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12346. /**
  12347. * Manage the touch inputs to control the movement of a free camera.
  12348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12349. */
  12350. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12351. /**
  12352. * Defines the camera the input is attached to.
  12353. */
  12354. camera: FreeCamera;
  12355. /**
  12356. * Defines the touch sensibility for rotation.
  12357. * The higher the faster.
  12358. */
  12359. touchAngularSensibility: number;
  12360. /**
  12361. * Defines the touch sensibility for move.
  12362. * The higher the faster.
  12363. */
  12364. touchMoveSensibility: number;
  12365. private _offsetX;
  12366. private _offsetY;
  12367. private _pointerPressed;
  12368. private _pointerInput;
  12369. private _observer;
  12370. private _onLostFocus;
  12371. /**
  12372. * Attach the input controls to a specific dom element to get the input from.
  12373. * @param element Defines the element the controls should be listened from
  12374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12375. */
  12376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12377. /**
  12378. * Detach the current controls from the specified dom element.
  12379. * @param element Defines the element to stop listening the inputs from
  12380. */
  12381. detachControl(element: Nullable<HTMLElement>): void;
  12382. /**
  12383. * Update the current camera state depending on the inputs that have been used this frame.
  12384. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12385. */
  12386. checkInputs(): void;
  12387. /**
  12388. * Gets the class name of the current intput.
  12389. * @returns the class name
  12390. */
  12391. getClassName(): string;
  12392. /**
  12393. * Get the friendly name associated with the input class.
  12394. * @returns the input friendly name
  12395. */
  12396. getSimpleName(): string;
  12397. }
  12398. }
  12399. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12400. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12401. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12402. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12403. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12404. import { Nullable } from "babylonjs/types";
  12405. /**
  12406. * Default Inputs manager for the FreeCamera.
  12407. * It groups all the default supported inputs for ease of use.
  12408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12409. */
  12410. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12411. /**
  12412. * @hidden
  12413. */
  12414. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12415. /**
  12416. * @hidden
  12417. */
  12418. _mouseInput: Nullable<FreeCameraMouseInput>;
  12419. /**
  12420. * Instantiates a new FreeCameraInputsManager.
  12421. * @param camera Defines the camera the inputs belong to
  12422. */
  12423. constructor(camera: FreeCamera);
  12424. /**
  12425. * Add keyboard input support to the input manager.
  12426. * @returns the current input manager
  12427. */
  12428. addKeyboard(): FreeCameraInputsManager;
  12429. /**
  12430. * Add mouse input support to the input manager.
  12431. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12432. * @returns the current input manager
  12433. */
  12434. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12435. /**
  12436. * Removes the mouse input support from the manager
  12437. * @returns the current input manager
  12438. */
  12439. removeMouse(): FreeCameraInputsManager;
  12440. /**
  12441. * Add touch input support to the input manager.
  12442. * @returns the current input manager
  12443. */
  12444. addTouch(): FreeCameraInputsManager;
  12445. }
  12446. }
  12447. declare module "babylonjs/Cameras/freeCamera" {
  12448. import { Vector3 } from "babylonjs/Maths/math";
  12449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12450. import { Scene } from "babylonjs/scene";
  12451. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12452. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12453. /**
  12454. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12455. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12456. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12457. */
  12458. export class FreeCamera extends TargetCamera {
  12459. /**
  12460. * Define the collision ellipsoid of the camera.
  12461. * This is helpful to simulate a camera body like the player body around the camera
  12462. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12463. */
  12464. ellipsoid: Vector3;
  12465. /**
  12466. * Define an offset for the position of the ellipsoid around the camera.
  12467. * This can be helpful to determine the center of the body near the gravity center of the body
  12468. * instead of its head.
  12469. */
  12470. ellipsoidOffset: Vector3;
  12471. /**
  12472. * Enable or disable collisions of the camera with the rest of the scene objects.
  12473. */
  12474. checkCollisions: boolean;
  12475. /**
  12476. * Enable or disable gravity on the camera.
  12477. */
  12478. applyGravity: boolean;
  12479. /**
  12480. * Define the input manager associated to the camera.
  12481. */
  12482. inputs: FreeCameraInputsManager;
  12483. /**
  12484. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12485. * Higher values reduce sensitivity.
  12486. */
  12487. /**
  12488. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12489. * Higher values reduce sensitivity.
  12490. */
  12491. angularSensibility: number;
  12492. /**
  12493. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12494. */
  12495. keysUp: number[];
  12496. /**
  12497. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12498. */
  12499. keysDown: number[];
  12500. /**
  12501. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12502. */
  12503. keysLeft: number[];
  12504. /**
  12505. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12506. */
  12507. keysRight: number[];
  12508. /**
  12509. * Event raised when the camera collide with a mesh in the scene.
  12510. */
  12511. onCollide: (collidedMesh: AbstractMesh) => void;
  12512. private _collider;
  12513. private _needMoveForGravity;
  12514. private _oldPosition;
  12515. private _diffPosition;
  12516. private _newPosition;
  12517. /** @hidden */
  12518. _localDirection: Vector3;
  12519. /** @hidden */
  12520. _transformedDirection: Vector3;
  12521. /**
  12522. * Instantiates a Free Camera.
  12523. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12524. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12525. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12526. * @param name Define the name of the camera in the scene
  12527. * @param position Define the start position of the camera in the scene
  12528. * @param scene Define the scene the camera belongs to
  12529. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12530. */
  12531. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12532. /**
  12533. * Attached controls to the current camera.
  12534. * @param element Defines the element the controls should be listened from
  12535. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12536. */
  12537. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12538. /**
  12539. * Detach the current controls from the camera.
  12540. * The camera will stop reacting to inputs.
  12541. * @param element Defines the element to stop listening the inputs from
  12542. */
  12543. detachControl(element: HTMLElement): void;
  12544. private _collisionMask;
  12545. /**
  12546. * Define a collision mask to limit the list of object the camera can collide with
  12547. */
  12548. collisionMask: number;
  12549. /** @hidden */
  12550. _collideWithWorld(displacement: Vector3): void;
  12551. private _onCollisionPositionChange;
  12552. /** @hidden */
  12553. _checkInputs(): void;
  12554. /** @hidden */
  12555. _decideIfNeedsToMove(): boolean;
  12556. /** @hidden */
  12557. _updatePosition(): void;
  12558. /**
  12559. * Destroy the camera and release the current resources hold by it.
  12560. */
  12561. dispose(): void;
  12562. /**
  12563. * Gets the current object class name.
  12564. * @return the class name
  12565. */
  12566. getClassName(): string;
  12567. }
  12568. }
  12569. declare module "babylonjs/Gamepads/gamepad" {
  12570. import { Observable } from "babylonjs/Misc/observable";
  12571. /**
  12572. * Represents a gamepad control stick position
  12573. */
  12574. export class StickValues {
  12575. /**
  12576. * The x component of the control stick
  12577. */
  12578. x: number;
  12579. /**
  12580. * The y component of the control stick
  12581. */
  12582. y: number;
  12583. /**
  12584. * Initializes the gamepad x and y control stick values
  12585. * @param x The x component of the gamepad control stick value
  12586. * @param y The y component of the gamepad control stick value
  12587. */
  12588. constructor(
  12589. /**
  12590. * The x component of the control stick
  12591. */
  12592. x: number,
  12593. /**
  12594. * The y component of the control stick
  12595. */
  12596. y: number);
  12597. }
  12598. /**
  12599. * An interface which manages callbacks for gamepad button changes
  12600. */
  12601. export interface GamepadButtonChanges {
  12602. /**
  12603. * Called when a gamepad has been changed
  12604. */
  12605. changed: boolean;
  12606. /**
  12607. * Called when a gamepad press event has been triggered
  12608. */
  12609. pressChanged: boolean;
  12610. /**
  12611. * Called when a touch event has been triggered
  12612. */
  12613. touchChanged: boolean;
  12614. /**
  12615. * Called when a value has changed
  12616. */
  12617. valueChanged: boolean;
  12618. }
  12619. /**
  12620. * Represents a gamepad
  12621. */
  12622. export class Gamepad {
  12623. /**
  12624. * The id of the gamepad
  12625. */
  12626. id: string;
  12627. /**
  12628. * The index of the gamepad
  12629. */
  12630. index: number;
  12631. /**
  12632. * The browser gamepad
  12633. */
  12634. browserGamepad: any;
  12635. /**
  12636. * Specifies what type of gamepad this represents
  12637. */
  12638. type: number;
  12639. private _leftStick;
  12640. private _rightStick;
  12641. /** @hidden */
  12642. _isConnected: boolean;
  12643. private _leftStickAxisX;
  12644. private _leftStickAxisY;
  12645. private _rightStickAxisX;
  12646. private _rightStickAxisY;
  12647. /**
  12648. * Triggered when the left control stick has been changed
  12649. */
  12650. private _onleftstickchanged;
  12651. /**
  12652. * Triggered when the right control stick has been changed
  12653. */
  12654. private _onrightstickchanged;
  12655. /**
  12656. * Represents a gamepad controller
  12657. */
  12658. static GAMEPAD: number;
  12659. /**
  12660. * Represents a generic controller
  12661. */
  12662. static GENERIC: number;
  12663. /**
  12664. * Represents an XBox controller
  12665. */
  12666. static XBOX: number;
  12667. /**
  12668. * Represents a pose-enabled controller
  12669. */
  12670. static POSE_ENABLED: number;
  12671. /**
  12672. * Specifies whether the left control stick should be Y-inverted
  12673. */
  12674. protected _invertLeftStickY: boolean;
  12675. /**
  12676. * Specifies if the gamepad has been connected
  12677. */
  12678. readonly isConnected: boolean;
  12679. /**
  12680. * Initializes the gamepad
  12681. * @param id The id of the gamepad
  12682. * @param index The index of the gamepad
  12683. * @param browserGamepad The browser gamepad
  12684. * @param leftStickX The x component of the left joystick
  12685. * @param leftStickY The y component of the left joystick
  12686. * @param rightStickX The x component of the right joystick
  12687. * @param rightStickY The y component of the right joystick
  12688. */
  12689. constructor(
  12690. /**
  12691. * The id of the gamepad
  12692. */
  12693. id: string,
  12694. /**
  12695. * The index of the gamepad
  12696. */
  12697. index: number,
  12698. /**
  12699. * The browser gamepad
  12700. */
  12701. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12702. /**
  12703. * Callback triggered when the left joystick has changed
  12704. * @param callback
  12705. */
  12706. onleftstickchanged(callback: (values: StickValues) => void): void;
  12707. /**
  12708. * Callback triggered when the right joystick has changed
  12709. * @param callback
  12710. */
  12711. onrightstickchanged(callback: (values: StickValues) => void): void;
  12712. /**
  12713. * Gets the left joystick
  12714. */
  12715. /**
  12716. * Sets the left joystick values
  12717. */
  12718. leftStick: StickValues;
  12719. /**
  12720. * Gets the right joystick
  12721. */
  12722. /**
  12723. * Sets the right joystick value
  12724. */
  12725. rightStick: StickValues;
  12726. /**
  12727. * Updates the gamepad joystick positions
  12728. */
  12729. update(): void;
  12730. /**
  12731. * Disposes the gamepad
  12732. */
  12733. dispose(): void;
  12734. }
  12735. /**
  12736. * Represents a generic gamepad
  12737. */
  12738. export class GenericPad extends Gamepad {
  12739. private _buttons;
  12740. private _onbuttondown;
  12741. private _onbuttonup;
  12742. /**
  12743. * Observable triggered when a button has been pressed
  12744. */
  12745. onButtonDownObservable: Observable<number>;
  12746. /**
  12747. * Observable triggered when a button has been released
  12748. */
  12749. onButtonUpObservable: Observable<number>;
  12750. /**
  12751. * Callback triggered when a button has been pressed
  12752. * @param callback Called when a button has been pressed
  12753. */
  12754. onbuttondown(callback: (buttonPressed: number) => void): void;
  12755. /**
  12756. * Callback triggered when a button has been released
  12757. * @param callback Called when a button has been released
  12758. */
  12759. onbuttonup(callback: (buttonReleased: number) => void): void;
  12760. /**
  12761. * Initializes the generic gamepad
  12762. * @param id The id of the generic gamepad
  12763. * @param index The index of the generic gamepad
  12764. * @param browserGamepad The browser gamepad
  12765. */
  12766. constructor(id: string, index: number, browserGamepad: any);
  12767. private _setButtonValue;
  12768. /**
  12769. * Updates the generic gamepad
  12770. */
  12771. update(): void;
  12772. /**
  12773. * Disposes the generic gamepad
  12774. */
  12775. dispose(): void;
  12776. }
  12777. }
  12778. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12779. import { Observable } from "babylonjs/Misc/observable";
  12780. import { Nullable } from "babylonjs/types";
  12781. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12782. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12784. import { Ray } from "babylonjs/Culling/ray";
  12785. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12786. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12787. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12788. /**
  12789. * Defines the types of pose enabled controllers that are supported
  12790. */
  12791. export enum PoseEnabledControllerType {
  12792. /**
  12793. * HTC Vive
  12794. */
  12795. VIVE = 0,
  12796. /**
  12797. * Oculus Rift
  12798. */
  12799. OCULUS = 1,
  12800. /**
  12801. * Windows mixed reality
  12802. */
  12803. WINDOWS = 2,
  12804. /**
  12805. * Samsung gear VR
  12806. */
  12807. GEAR_VR = 3,
  12808. /**
  12809. * Google Daydream
  12810. */
  12811. DAYDREAM = 4,
  12812. /**
  12813. * Generic
  12814. */
  12815. GENERIC = 5
  12816. }
  12817. /**
  12818. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12819. */
  12820. export interface MutableGamepadButton {
  12821. /**
  12822. * Value of the button/trigger
  12823. */
  12824. value: number;
  12825. /**
  12826. * If the button/trigger is currently touched
  12827. */
  12828. touched: boolean;
  12829. /**
  12830. * If the button/trigger is currently pressed
  12831. */
  12832. pressed: boolean;
  12833. }
  12834. /**
  12835. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12836. * @hidden
  12837. */
  12838. export interface ExtendedGamepadButton extends GamepadButton {
  12839. /**
  12840. * If the button/trigger is currently pressed
  12841. */
  12842. readonly pressed: boolean;
  12843. /**
  12844. * If the button/trigger is currently touched
  12845. */
  12846. readonly touched: boolean;
  12847. /**
  12848. * Value of the button/trigger
  12849. */
  12850. readonly value: number;
  12851. }
  12852. /** @hidden */
  12853. export interface _GamePadFactory {
  12854. /**
  12855. * Returns wether or not the current gamepad can be created for this type of controller.
  12856. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12857. * @returns true if it can be created, otherwise false
  12858. */
  12859. canCreate(gamepadInfo: any): boolean;
  12860. /**
  12861. * Creates a new instance of the Gamepad.
  12862. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12863. * @returns the new gamepad instance
  12864. */
  12865. create(gamepadInfo: any): Gamepad;
  12866. }
  12867. /**
  12868. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12869. */
  12870. export class PoseEnabledControllerHelper {
  12871. /** @hidden */
  12872. static _ControllerFactories: _GamePadFactory[];
  12873. /** @hidden */
  12874. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12875. /**
  12876. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12877. * @param vrGamepad the gamepad to initialized
  12878. * @returns a vr controller of the type the gamepad identified as
  12879. */
  12880. static InitiateController(vrGamepad: any): Gamepad;
  12881. }
  12882. /**
  12883. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12884. */
  12885. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12886. private _deviceRoomPosition;
  12887. private _deviceRoomRotationQuaternion;
  12888. /**
  12889. * The device position in babylon space
  12890. */
  12891. devicePosition: Vector3;
  12892. /**
  12893. * The device rotation in babylon space
  12894. */
  12895. deviceRotationQuaternion: Quaternion;
  12896. /**
  12897. * The scale factor of the device in babylon space
  12898. */
  12899. deviceScaleFactor: number;
  12900. /**
  12901. * (Likely devicePosition should be used instead) The device position in its room space
  12902. */
  12903. position: Vector3;
  12904. /**
  12905. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12906. */
  12907. rotationQuaternion: Quaternion;
  12908. /**
  12909. * The type of controller (Eg. Windows mixed reality)
  12910. */
  12911. controllerType: PoseEnabledControllerType;
  12912. protected _calculatedPosition: Vector3;
  12913. private _calculatedRotation;
  12914. /**
  12915. * The raw pose from the device
  12916. */
  12917. rawPose: DevicePose;
  12918. private _trackPosition;
  12919. private _maxRotationDistFromHeadset;
  12920. private _draggedRoomRotation;
  12921. /**
  12922. * @hidden
  12923. */
  12924. _disableTrackPosition(fixedPosition: Vector3): void;
  12925. /**
  12926. * Internal, the mesh attached to the controller
  12927. * @hidden
  12928. */
  12929. _mesh: Nullable<AbstractMesh>;
  12930. private _poseControlledCamera;
  12931. private _leftHandSystemQuaternion;
  12932. /**
  12933. * Internal, matrix used to convert room space to babylon space
  12934. * @hidden
  12935. */
  12936. _deviceToWorld: Matrix;
  12937. /**
  12938. * Node to be used when casting a ray from the controller
  12939. * @hidden
  12940. */
  12941. _pointingPoseNode: Nullable<TransformNode>;
  12942. /**
  12943. * Name of the child mesh that can be used to cast a ray from the controller
  12944. */
  12945. static readonly POINTING_POSE: string;
  12946. /**
  12947. * Creates a new PoseEnabledController from a gamepad
  12948. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12949. */
  12950. constructor(browserGamepad: any);
  12951. private _workingMatrix;
  12952. /**
  12953. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12954. */
  12955. update(): void;
  12956. /**
  12957. * Updates only the pose device and mesh without doing any button event checking
  12958. */
  12959. protected _updatePoseAndMesh(): void;
  12960. /**
  12961. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12962. * @param poseData raw pose fromthe device
  12963. */
  12964. updateFromDevice(poseData: DevicePose): void;
  12965. /**
  12966. * @hidden
  12967. */
  12968. _meshAttachedObservable: Observable<AbstractMesh>;
  12969. /**
  12970. * Attaches a mesh to the controller
  12971. * @param mesh the mesh to be attached
  12972. */
  12973. attachToMesh(mesh: AbstractMesh): void;
  12974. /**
  12975. * Attaches the controllers mesh to a camera
  12976. * @param camera the camera the mesh should be attached to
  12977. */
  12978. attachToPoseControlledCamera(camera: TargetCamera): void;
  12979. /**
  12980. * Disposes of the controller
  12981. */
  12982. dispose(): void;
  12983. /**
  12984. * The mesh that is attached to the controller
  12985. */
  12986. readonly mesh: Nullable<AbstractMesh>;
  12987. /**
  12988. * Gets the ray of the controller in the direction the controller is pointing
  12989. * @param length the length the resulting ray should be
  12990. * @returns a ray in the direction the controller is pointing
  12991. */
  12992. getForwardRay(length?: number): Ray;
  12993. }
  12994. }
  12995. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12996. import { Observable } from "babylonjs/Misc/observable";
  12997. import { Scene } from "babylonjs/scene";
  12998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12999. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13000. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13001. /**
  13002. * Defines the WebVRController object that represents controllers tracked in 3D space
  13003. */
  13004. export abstract class WebVRController extends PoseEnabledController {
  13005. /**
  13006. * Internal, the default controller model for the controller
  13007. */
  13008. protected _defaultModel: AbstractMesh;
  13009. /**
  13010. * Fired when the trigger state has changed
  13011. */
  13012. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13013. /**
  13014. * Fired when the main button state has changed
  13015. */
  13016. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13017. /**
  13018. * Fired when the secondary button state has changed
  13019. */
  13020. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13021. /**
  13022. * Fired when the pad state has changed
  13023. */
  13024. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13025. /**
  13026. * Fired when controllers stick values have changed
  13027. */
  13028. onPadValuesChangedObservable: Observable<StickValues>;
  13029. /**
  13030. * Array of button availible on the controller
  13031. */
  13032. protected _buttons: Array<MutableGamepadButton>;
  13033. private _onButtonStateChange;
  13034. /**
  13035. * Fired when a controller button's state has changed
  13036. * @param callback the callback containing the button that was modified
  13037. */
  13038. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13039. /**
  13040. * X and Y axis corrisponding to the controllers joystick
  13041. */
  13042. pad: StickValues;
  13043. /**
  13044. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13045. */
  13046. hand: string;
  13047. /**
  13048. * The default controller model for the controller
  13049. */
  13050. readonly defaultModel: AbstractMesh;
  13051. /**
  13052. * Creates a new WebVRController from a gamepad
  13053. * @param vrGamepad the gamepad that the WebVRController should be created from
  13054. */
  13055. constructor(vrGamepad: any);
  13056. /**
  13057. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13058. */
  13059. update(): void;
  13060. /**
  13061. * Function to be called when a button is modified
  13062. */
  13063. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13064. /**
  13065. * Loads a mesh and attaches it to the controller
  13066. * @param scene the scene the mesh should be added to
  13067. * @param meshLoaded callback for when the mesh has been loaded
  13068. */
  13069. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13070. private _setButtonValue;
  13071. private _changes;
  13072. private _checkChanges;
  13073. /**
  13074. * Disposes of th webVRCOntroller
  13075. */
  13076. dispose(): void;
  13077. }
  13078. }
  13079. declare module "babylonjs/Lights/hemisphericLight" {
  13080. import { Nullable } from "babylonjs/types";
  13081. import { Scene } from "babylonjs/scene";
  13082. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13083. import { Effect } from "babylonjs/Materials/effect";
  13084. import { Light } from "babylonjs/Lights/light";
  13085. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13086. /**
  13087. * The HemisphericLight simulates the ambient environment light,
  13088. * so the passed direction is the light reflection direction, not the incoming direction.
  13089. */
  13090. export class HemisphericLight extends Light {
  13091. /**
  13092. * The groundColor is the light in the opposite direction to the one specified during creation.
  13093. * 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.
  13094. */
  13095. groundColor: Color3;
  13096. /**
  13097. * The light reflection direction, not the incoming direction.
  13098. */
  13099. direction: Vector3;
  13100. /**
  13101. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13102. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13103. * The HemisphericLight can't cast shadows.
  13104. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13105. * @param name The friendly name of the light
  13106. * @param direction The direction of the light reflection
  13107. * @param scene The scene the light belongs to
  13108. */
  13109. constructor(name: string, direction: Vector3, scene: Scene);
  13110. protected _buildUniformLayout(): void;
  13111. /**
  13112. * Returns the string "HemisphericLight".
  13113. * @return The class name
  13114. */
  13115. getClassName(): string;
  13116. /**
  13117. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13118. * Returns the updated direction.
  13119. * @param target The target the direction should point to
  13120. * @return The computed direction
  13121. */
  13122. setDirectionToTarget(target: Vector3): Vector3;
  13123. /**
  13124. * Returns the shadow generator associated to the light.
  13125. * @returns Always null for hemispheric lights because it does not support shadows.
  13126. */
  13127. getShadowGenerator(): Nullable<IShadowGenerator>;
  13128. /**
  13129. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13130. * @param effect The effect to update
  13131. * @param lightIndex The index of the light in the effect to update
  13132. * @returns The hemispheric light
  13133. */
  13134. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13135. /**
  13136. * Computes the world matrix of the node
  13137. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13138. * @param useWasUpdatedFlag defines a reserved property
  13139. * @returns the world matrix
  13140. */
  13141. computeWorldMatrix(): Matrix;
  13142. /**
  13143. * Returns the integer 3.
  13144. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13145. */
  13146. getTypeID(): number;
  13147. /**
  13148. * Prepares the list of defines specific to the light type.
  13149. * @param defines the list of defines
  13150. * @param lightIndex defines the index of the light for the effect
  13151. */
  13152. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13153. }
  13154. }
  13155. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13156. /** @hidden */
  13157. export var vrMultiviewToSingleviewPixelShader: {
  13158. name: string;
  13159. shader: string;
  13160. };
  13161. }
  13162. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13163. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13164. import { Scene } from "babylonjs/scene";
  13165. /**
  13166. * Renders to multiple views with a single draw call
  13167. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13168. */
  13169. export class MultiviewRenderTarget extends RenderTargetTexture {
  13170. /**
  13171. * Creates a multiview render target
  13172. * @param scene scene used with the render target
  13173. * @param size the size of the render target (used for each view)
  13174. */
  13175. constructor(scene: Scene, size?: number | {
  13176. width: number;
  13177. height: number;
  13178. } | {
  13179. ratio: number;
  13180. });
  13181. /**
  13182. * @hidden
  13183. * @param faceIndex the face index, if its a cube texture
  13184. */
  13185. _bindFrameBuffer(faceIndex?: number): void;
  13186. /**
  13187. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13188. * @returns the view count
  13189. */
  13190. getViewCount(): number;
  13191. }
  13192. }
  13193. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13194. import { Camera } from "babylonjs/Cameras/camera";
  13195. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13196. import { Nullable } from "babylonjs/types";
  13197. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13198. import { Matrix } from "babylonjs/Maths/math";
  13199. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13200. module "babylonjs/Engines/engine" {
  13201. interface Engine {
  13202. /**
  13203. * Creates a new multiview render target
  13204. * @param width defines the width of the texture
  13205. * @param height defines the height of the texture
  13206. * @returns the created multiview texture
  13207. */
  13208. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13209. /**
  13210. * Binds a multiview framebuffer to be drawn to
  13211. * @param multiviewTexture texture to bind
  13212. */
  13213. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13214. }
  13215. }
  13216. module "babylonjs/Cameras/camera" {
  13217. interface Camera {
  13218. /**
  13219. * @hidden
  13220. * 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)
  13221. */
  13222. _useMultiviewToSingleView: boolean;
  13223. /**
  13224. * @hidden
  13225. * 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)
  13226. */
  13227. _multiviewTexture: Nullable<RenderTargetTexture>;
  13228. /**
  13229. * @hidden
  13230. * ensures the multiview texture of the camera exists and has the specified width/height
  13231. * @param width height to set on the multiview texture
  13232. * @param height width to set on the multiview texture
  13233. */
  13234. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13235. }
  13236. }
  13237. module "babylonjs/scene" {
  13238. interface Scene {
  13239. /** @hidden */
  13240. _transformMatrixR: Matrix;
  13241. /** @hidden */
  13242. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13243. /** @hidden */
  13244. _createMultiviewUbo(): void;
  13245. /** @hidden */
  13246. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13247. /** @hidden */
  13248. _renderMultiviewToSingleView(camera: Camera): void;
  13249. }
  13250. }
  13251. }
  13252. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13253. import { Camera } from "babylonjs/Cameras/camera";
  13254. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13255. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13256. import "babylonjs/Engines/Extensions/engine.multiview";
  13257. /**
  13258. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13259. * This will not be used for webXR as it supports displaying texture arrays directly
  13260. */
  13261. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13262. /**
  13263. * Initializes a VRMultiviewToSingleview
  13264. * @param name name of the post process
  13265. * @param camera camera to be applied to
  13266. * @param scaleFactor scaling factor to the size of the output texture
  13267. */
  13268. constructor(name: string, camera: Camera, scaleFactor: number);
  13269. }
  13270. }
  13271. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13272. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13273. import { Nullable } from "babylonjs/types";
  13274. import { Observable } from "babylonjs/Misc/observable";
  13275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13276. import { Scene } from "babylonjs/scene";
  13277. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13278. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13279. import { Node } from "babylonjs/node";
  13280. import { Ray } from "babylonjs/Culling/ray";
  13281. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13282. /**
  13283. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13284. * IMPORTANT!! The data is right-hand data.
  13285. * @export
  13286. * @interface DevicePose
  13287. */
  13288. export interface DevicePose {
  13289. /**
  13290. * The position of the device, values in array are [x,y,z].
  13291. */
  13292. readonly position: Nullable<Float32Array>;
  13293. /**
  13294. * The linearVelocity of the device, values in array are [x,y,z].
  13295. */
  13296. readonly linearVelocity: Nullable<Float32Array>;
  13297. /**
  13298. * The linearAcceleration of the device, values in array are [x,y,z].
  13299. */
  13300. readonly linearAcceleration: Nullable<Float32Array>;
  13301. /**
  13302. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13303. */
  13304. readonly orientation: Nullable<Float32Array>;
  13305. /**
  13306. * The angularVelocity of the device, values in array are [x,y,z].
  13307. */
  13308. readonly angularVelocity: Nullable<Float32Array>;
  13309. /**
  13310. * The angularAcceleration of the device, values in array are [x,y,z].
  13311. */
  13312. readonly angularAcceleration: Nullable<Float32Array>;
  13313. }
  13314. /**
  13315. * Interface representing a pose controlled object in Babylon.
  13316. * A pose controlled object has both regular pose values as well as pose values
  13317. * from an external device such as a VR head mounted display
  13318. */
  13319. export interface PoseControlled {
  13320. /**
  13321. * The position of the object in babylon space.
  13322. */
  13323. position: Vector3;
  13324. /**
  13325. * The rotation quaternion of the object in babylon space.
  13326. */
  13327. rotationQuaternion: Quaternion;
  13328. /**
  13329. * The position of the device in babylon space.
  13330. */
  13331. devicePosition?: Vector3;
  13332. /**
  13333. * The rotation quaternion of the device in babylon space.
  13334. */
  13335. deviceRotationQuaternion: Quaternion;
  13336. /**
  13337. * The raw pose coming from the device.
  13338. */
  13339. rawPose: Nullable<DevicePose>;
  13340. /**
  13341. * The scale of the device to be used when translating from device space to babylon space.
  13342. */
  13343. deviceScaleFactor: number;
  13344. /**
  13345. * Updates the poseControlled values based on the input device pose.
  13346. * @param poseData the pose data to update the object with
  13347. */
  13348. updateFromDevice(poseData: DevicePose): void;
  13349. }
  13350. /**
  13351. * Set of options to customize the webVRCamera
  13352. */
  13353. export interface WebVROptions {
  13354. /**
  13355. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13356. */
  13357. trackPosition?: boolean;
  13358. /**
  13359. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13360. */
  13361. positionScale?: number;
  13362. /**
  13363. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13364. */
  13365. displayName?: string;
  13366. /**
  13367. * Should the native controller meshes be initialized. (default: true)
  13368. */
  13369. controllerMeshes?: boolean;
  13370. /**
  13371. * Creating a default HemiLight only on controllers. (default: true)
  13372. */
  13373. defaultLightingOnControllers?: boolean;
  13374. /**
  13375. * If you don't want to use the default VR button of the helper. (default: false)
  13376. */
  13377. useCustomVRButton?: boolean;
  13378. /**
  13379. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13380. */
  13381. customVRButton?: HTMLButtonElement;
  13382. /**
  13383. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13384. */
  13385. rayLength?: number;
  13386. /**
  13387. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13388. */
  13389. defaultHeight?: number;
  13390. /**
  13391. * If multiview should be used if availible (default: false)
  13392. */
  13393. useMultiview?: boolean;
  13394. }
  13395. /**
  13396. * This represents a WebVR camera.
  13397. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13398. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13399. */
  13400. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13401. private webVROptions;
  13402. /**
  13403. * @hidden
  13404. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13405. */
  13406. _vrDevice: any;
  13407. /**
  13408. * The rawPose of the vrDevice.
  13409. */
  13410. rawPose: Nullable<DevicePose>;
  13411. private _onVREnabled;
  13412. private _specsVersion;
  13413. private _attached;
  13414. private _frameData;
  13415. protected _descendants: Array<Node>;
  13416. private _deviceRoomPosition;
  13417. /** @hidden */
  13418. _deviceRoomRotationQuaternion: Quaternion;
  13419. private _standingMatrix;
  13420. /**
  13421. * Represents device position in babylon space.
  13422. */
  13423. devicePosition: Vector3;
  13424. /**
  13425. * Represents device rotation in babylon space.
  13426. */
  13427. deviceRotationQuaternion: Quaternion;
  13428. /**
  13429. * The scale of the device to be used when translating from device space to babylon space.
  13430. */
  13431. deviceScaleFactor: number;
  13432. private _deviceToWorld;
  13433. private _worldToDevice;
  13434. /**
  13435. * References to the webVR controllers for the vrDevice.
  13436. */
  13437. controllers: Array<WebVRController>;
  13438. /**
  13439. * Emits an event when a controller is attached.
  13440. */
  13441. onControllersAttachedObservable: Observable<WebVRController[]>;
  13442. /**
  13443. * Emits an event when a controller's mesh has been loaded;
  13444. */
  13445. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13446. /**
  13447. * Emits an event when the HMD's pose has been updated.
  13448. */
  13449. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13450. private _poseSet;
  13451. /**
  13452. * If the rig cameras be used as parent instead of this camera.
  13453. */
  13454. rigParenting: boolean;
  13455. private _lightOnControllers;
  13456. private _defaultHeight?;
  13457. /**
  13458. * Instantiates a WebVRFreeCamera.
  13459. * @param name The name of the WebVRFreeCamera
  13460. * @param position The starting anchor position for the camera
  13461. * @param scene The scene the camera belongs to
  13462. * @param webVROptions a set of customizable options for the webVRCamera
  13463. */
  13464. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13465. /**
  13466. * Gets the device distance from the ground in meters.
  13467. * @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.
  13468. */
  13469. deviceDistanceToRoomGround(): number;
  13470. /**
  13471. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13472. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13473. */
  13474. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13475. /**
  13476. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13477. * @returns A promise with a boolean set to if the standing matrix is supported.
  13478. */
  13479. useStandingMatrixAsync(): Promise<boolean>;
  13480. /**
  13481. * Disposes the camera
  13482. */
  13483. dispose(): void;
  13484. /**
  13485. * Gets a vrController by name.
  13486. * @param name The name of the controller to retreive
  13487. * @returns the controller matching the name specified or null if not found
  13488. */
  13489. getControllerByName(name: string): Nullable<WebVRController>;
  13490. private _leftController;
  13491. /**
  13492. * The controller corrisponding to the users left hand.
  13493. */
  13494. readonly leftController: Nullable<WebVRController>;
  13495. private _rightController;
  13496. /**
  13497. * The controller corrisponding to the users right hand.
  13498. */
  13499. readonly rightController: Nullable<WebVRController>;
  13500. /**
  13501. * Casts a ray forward from the vrCamera's gaze.
  13502. * @param length Length of the ray (default: 100)
  13503. * @returns the ray corrisponding to the gaze
  13504. */
  13505. getForwardRay(length?: number): Ray;
  13506. /**
  13507. * @hidden
  13508. * Updates the camera based on device's frame data
  13509. */
  13510. _checkInputs(): void;
  13511. /**
  13512. * Updates the poseControlled values based on the input device pose.
  13513. * @param poseData Pose coming from the device
  13514. */
  13515. updateFromDevice(poseData: DevicePose): void;
  13516. private _htmlElementAttached;
  13517. private _detachIfAttached;
  13518. /**
  13519. * WebVR's attach control will start broadcasting frames to the device.
  13520. * Note that in certain browsers (chrome for example) this function must be called
  13521. * within a user-interaction callback. Example:
  13522. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13523. *
  13524. * @param element html element to attach the vrDevice to
  13525. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13526. */
  13527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13528. /**
  13529. * Detaches the camera from the html element and disables VR
  13530. *
  13531. * @param element html element to detach from
  13532. */
  13533. detachControl(element: HTMLElement): void;
  13534. /**
  13535. * @returns the name of this class
  13536. */
  13537. getClassName(): string;
  13538. /**
  13539. * Calls resetPose on the vrDisplay
  13540. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13541. */
  13542. resetToCurrentRotation(): void;
  13543. /**
  13544. * @hidden
  13545. * Updates the rig cameras (left and right eye)
  13546. */
  13547. _updateRigCameras(): void;
  13548. private _workingVector;
  13549. private _oneVector;
  13550. private _workingMatrix;
  13551. private updateCacheCalled;
  13552. private _correctPositionIfNotTrackPosition;
  13553. /**
  13554. * @hidden
  13555. * Updates the cached values of the camera
  13556. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13557. */
  13558. _updateCache(ignoreParentClass?: boolean): void;
  13559. /**
  13560. * @hidden
  13561. * Get current device position in babylon world
  13562. */
  13563. _computeDevicePosition(): void;
  13564. /**
  13565. * Updates the current device position and rotation in the babylon world
  13566. */
  13567. update(): void;
  13568. /**
  13569. * @hidden
  13570. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13571. * @returns an identity matrix
  13572. */
  13573. _getViewMatrix(): Matrix;
  13574. private _tmpMatrix;
  13575. /**
  13576. * This function is called by the two RIG cameras.
  13577. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13578. * @hidden
  13579. */
  13580. _getWebVRViewMatrix(): Matrix;
  13581. /** @hidden */
  13582. _getWebVRProjectionMatrix(): Matrix;
  13583. private _onGamepadConnectedObserver;
  13584. private _onGamepadDisconnectedObserver;
  13585. private _updateCacheWhenTrackingDisabledObserver;
  13586. /**
  13587. * Initializes the controllers and their meshes
  13588. */
  13589. initControllers(): void;
  13590. }
  13591. }
  13592. declare module "babylonjs/PostProcesses/postProcess" {
  13593. import { Nullable } from "babylonjs/types";
  13594. import { SmartArray } from "babylonjs/Misc/smartArray";
  13595. import { Observable } from "babylonjs/Misc/observable";
  13596. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13597. import { Camera } from "babylonjs/Cameras/camera";
  13598. import { Effect } from "babylonjs/Materials/effect";
  13599. import "babylonjs/Shaders/postprocess.vertex";
  13600. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13601. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13602. import { Engine } from "babylonjs/Engines/engine";
  13603. /**
  13604. * Size options for a post process
  13605. */
  13606. export type PostProcessOptions = {
  13607. width: number;
  13608. height: number;
  13609. };
  13610. /**
  13611. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13612. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13613. */
  13614. export class PostProcess {
  13615. /** Name of the PostProcess. */
  13616. name: string;
  13617. /**
  13618. * Gets or sets the unique id of the post process
  13619. */
  13620. uniqueId: number;
  13621. /**
  13622. * Width of the texture to apply the post process on
  13623. */
  13624. width: number;
  13625. /**
  13626. * Height of the texture to apply the post process on
  13627. */
  13628. height: number;
  13629. /**
  13630. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13631. * @hidden
  13632. */
  13633. _outputTexture: Nullable<InternalTexture>;
  13634. /**
  13635. * Sampling mode used by the shader
  13636. * See https://doc.babylonjs.com/classes/3.1/texture
  13637. */
  13638. renderTargetSamplingMode: number;
  13639. /**
  13640. * Clear color to use when screen clearing
  13641. */
  13642. clearColor: Color4;
  13643. /**
  13644. * If the buffer needs to be cleared before applying the post process. (default: true)
  13645. * Should be set to false if shader will overwrite all previous pixels.
  13646. */
  13647. autoClear: boolean;
  13648. /**
  13649. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13650. */
  13651. alphaMode: number;
  13652. /**
  13653. * Sets the setAlphaBlendConstants of the babylon engine
  13654. */
  13655. alphaConstants: Color4;
  13656. /**
  13657. * Animations to be used for the post processing
  13658. */
  13659. animations: import("babylonjs/Animations/animation").Animation[];
  13660. /**
  13661. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13662. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13663. */
  13664. enablePixelPerfectMode: boolean;
  13665. /**
  13666. * Force the postprocess to be applied without taking in account viewport
  13667. */
  13668. forceFullscreenViewport: boolean;
  13669. /**
  13670. * List of inspectable custom properties (used by the Inspector)
  13671. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13672. */
  13673. inspectableCustomProperties: IInspectable[];
  13674. /**
  13675. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13676. *
  13677. * | Value | Type | Description |
  13678. * | ----- | ----------------------------------- | ----------- |
  13679. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13680. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13681. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13682. *
  13683. */
  13684. scaleMode: number;
  13685. /**
  13686. * Force textures to be a power of two (default: false)
  13687. */
  13688. alwaysForcePOT: boolean;
  13689. private _samples;
  13690. /**
  13691. * Number of sample textures (default: 1)
  13692. */
  13693. samples: number;
  13694. /**
  13695. * Modify the scale of the post process to be the same as the viewport (default: false)
  13696. */
  13697. adaptScaleToCurrentViewport: boolean;
  13698. private _camera;
  13699. private _scene;
  13700. private _engine;
  13701. private _options;
  13702. private _reusable;
  13703. private _textureType;
  13704. /**
  13705. * Smart array of input and output textures for the post process.
  13706. * @hidden
  13707. */
  13708. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13709. /**
  13710. * The index in _textures that corresponds to the output texture.
  13711. * @hidden
  13712. */
  13713. _currentRenderTextureInd: number;
  13714. private _effect;
  13715. private _samplers;
  13716. private _fragmentUrl;
  13717. private _vertexUrl;
  13718. private _parameters;
  13719. private _scaleRatio;
  13720. protected _indexParameters: any;
  13721. private _shareOutputWithPostProcess;
  13722. private _texelSize;
  13723. private _forcedOutputTexture;
  13724. /**
  13725. * Returns the fragment url or shader name used in the post process.
  13726. * @returns the fragment url or name in the shader store.
  13727. */
  13728. getEffectName(): string;
  13729. /**
  13730. * An event triggered when the postprocess is activated.
  13731. */
  13732. onActivateObservable: Observable<Camera>;
  13733. private _onActivateObserver;
  13734. /**
  13735. * A function that is added to the onActivateObservable
  13736. */
  13737. onActivate: Nullable<(camera: Camera) => void>;
  13738. /**
  13739. * An event triggered when the postprocess changes its size.
  13740. */
  13741. onSizeChangedObservable: Observable<PostProcess>;
  13742. private _onSizeChangedObserver;
  13743. /**
  13744. * A function that is added to the onSizeChangedObservable
  13745. */
  13746. onSizeChanged: (postProcess: PostProcess) => void;
  13747. /**
  13748. * An event triggered when the postprocess applies its effect.
  13749. */
  13750. onApplyObservable: Observable<Effect>;
  13751. private _onApplyObserver;
  13752. /**
  13753. * A function that is added to the onApplyObservable
  13754. */
  13755. onApply: (effect: Effect) => void;
  13756. /**
  13757. * An event triggered before rendering the postprocess
  13758. */
  13759. onBeforeRenderObservable: Observable<Effect>;
  13760. private _onBeforeRenderObserver;
  13761. /**
  13762. * A function that is added to the onBeforeRenderObservable
  13763. */
  13764. onBeforeRender: (effect: Effect) => void;
  13765. /**
  13766. * An event triggered after rendering the postprocess
  13767. */
  13768. onAfterRenderObservable: Observable<Effect>;
  13769. private _onAfterRenderObserver;
  13770. /**
  13771. * A function that is added to the onAfterRenderObservable
  13772. */
  13773. onAfterRender: (efect: Effect) => void;
  13774. /**
  13775. * 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
  13776. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13777. */
  13778. inputTexture: InternalTexture;
  13779. /**
  13780. * Gets the camera which post process is applied to.
  13781. * @returns The camera the post process is applied to.
  13782. */
  13783. getCamera(): Camera;
  13784. /**
  13785. * Gets the texel size of the postprocess.
  13786. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13787. */
  13788. readonly texelSize: Vector2;
  13789. /**
  13790. * Creates a new instance PostProcess
  13791. * @param name The name of the PostProcess.
  13792. * @param fragmentUrl The url of the fragment shader to be used.
  13793. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13794. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13795. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13796. * @param camera The camera to apply the render pass to.
  13797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13798. * @param engine The engine which the post process will be applied. (default: current engine)
  13799. * @param reusable If the post process can be reused on the same frame. (default: false)
  13800. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13801. * @param textureType Type of textures used when performing the post process. (default: 0)
  13802. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13803. * @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
  13804. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13805. */
  13806. constructor(
  13807. /** Name of the PostProcess. */
  13808. 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);
  13809. /**
  13810. * Gets a string idenfifying the name of the class
  13811. * @returns "PostProcess" string
  13812. */
  13813. getClassName(): string;
  13814. /**
  13815. * Gets the engine which this post process belongs to.
  13816. * @returns The engine the post process was enabled with.
  13817. */
  13818. getEngine(): Engine;
  13819. /**
  13820. * The effect that is created when initializing the post process.
  13821. * @returns The created effect corrisponding the the postprocess.
  13822. */
  13823. getEffect(): Effect;
  13824. /**
  13825. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13826. * @param postProcess The post process to share the output with.
  13827. * @returns This post process.
  13828. */
  13829. shareOutputWith(postProcess: PostProcess): PostProcess;
  13830. /**
  13831. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13832. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13833. */
  13834. useOwnOutput(): void;
  13835. /**
  13836. * Updates the effect with the current post process compile time values and recompiles the shader.
  13837. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13838. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13839. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13840. * @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
  13841. * @param onCompiled Called when the shader has been compiled.
  13842. * @param onError Called if there is an error when compiling a shader.
  13843. */
  13844. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13845. /**
  13846. * The post process is reusable if it can be used multiple times within one frame.
  13847. * @returns If the post process is reusable
  13848. */
  13849. isReusable(): boolean;
  13850. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13851. markTextureDirty(): void;
  13852. /**
  13853. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13854. * 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.
  13855. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13856. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13857. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13858. * @returns The target texture that was bound to be written to.
  13859. */
  13860. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13861. /**
  13862. * If the post process is supported.
  13863. */
  13864. readonly isSupported: boolean;
  13865. /**
  13866. * The aspect ratio of the output texture.
  13867. */
  13868. readonly aspectRatio: number;
  13869. /**
  13870. * Get a value indicating if the post-process is ready to be used
  13871. * @returns true if the post-process is ready (shader is compiled)
  13872. */
  13873. isReady(): boolean;
  13874. /**
  13875. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13876. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13877. */
  13878. apply(): Nullable<Effect>;
  13879. private _disposeTextures;
  13880. /**
  13881. * Disposes the post process.
  13882. * @param camera The camera to dispose the post process on.
  13883. */
  13884. dispose(camera?: Camera): void;
  13885. }
  13886. }
  13887. declare module "babylonjs/PostProcesses/postProcessManager" {
  13888. import { Nullable } from "babylonjs/types";
  13889. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13890. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13891. import { Scene } from "babylonjs/scene";
  13892. /**
  13893. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13894. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13895. */
  13896. export class PostProcessManager {
  13897. private _scene;
  13898. private _indexBuffer;
  13899. private _vertexBuffers;
  13900. /**
  13901. * Creates a new instance PostProcess
  13902. * @param scene The scene that the post process is associated with.
  13903. */
  13904. constructor(scene: Scene);
  13905. private _prepareBuffers;
  13906. private _buildIndexBuffer;
  13907. /**
  13908. * Rebuilds the vertex buffers of the manager.
  13909. * @hidden
  13910. */
  13911. _rebuild(): void;
  13912. /**
  13913. * Prepares a frame to be run through a post process.
  13914. * @param sourceTexture The input texture to the post procesess. (default: null)
  13915. * @param postProcesses An array of post processes to be run. (default: null)
  13916. * @returns True if the post processes were able to be run.
  13917. * @hidden
  13918. */
  13919. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13920. /**
  13921. * Manually render a set of post processes to a texture.
  13922. * @param postProcesses An array of post processes to be run.
  13923. * @param targetTexture The target texture to render to.
  13924. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13925. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13926. * @param lodLevel defines which lod of the texture to render to
  13927. */
  13928. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13929. /**
  13930. * Finalize the result of the output of the postprocesses.
  13931. * @param doNotPresent If true the result will not be displayed to the screen.
  13932. * @param targetTexture The target texture to render to.
  13933. * @param faceIndex The index of the face to bind the target texture to.
  13934. * @param postProcesses The array of post processes to render.
  13935. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13936. * @hidden
  13937. */
  13938. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13939. /**
  13940. * Disposes of the post process manager.
  13941. */
  13942. dispose(): void;
  13943. }
  13944. }
  13945. declare module "babylonjs/Layers/layerSceneComponent" {
  13946. import { Scene } from "babylonjs/scene";
  13947. import { ISceneComponent } from "babylonjs/sceneComponent";
  13948. import { Layer } from "babylonjs/Layers/layer";
  13949. module "babylonjs/abstractScene" {
  13950. interface AbstractScene {
  13951. /**
  13952. * The list of layers (background and foreground) of the scene
  13953. */
  13954. layers: Array<Layer>;
  13955. }
  13956. }
  13957. /**
  13958. * Defines the layer scene component responsible to manage any layers
  13959. * in a given scene.
  13960. */
  13961. export class LayerSceneComponent implements ISceneComponent {
  13962. /**
  13963. * The component name helpfull to identify the component in the list of scene components.
  13964. */
  13965. readonly name: string;
  13966. /**
  13967. * The scene the component belongs to.
  13968. */
  13969. scene: Scene;
  13970. private _engine;
  13971. /**
  13972. * Creates a new instance of the component for the given scene
  13973. * @param scene Defines the scene to register the component in
  13974. */
  13975. constructor(scene: Scene);
  13976. /**
  13977. * Registers the component in a given scene
  13978. */
  13979. register(): void;
  13980. /**
  13981. * Rebuilds the elements related to this component in case of
  13982. * context lost for instance.
  13983. */
  13984. rebuild(): void;
  13985. /**
  13986. * Disposes the component and the associated ressources.
  13987. */
  13988. dispose(): void;
  13989. private _draw;
  13990. private _drawCameraPredicate;
  13991. private _drawCameraBackground;
  13992. private _drawCameraForeground;
  13993. private _drawRenderTargetPredicate;
  13994. private _drawRenderTargetBackground;
  13995. private _drawRenderTargetForeground;
  13996. }
  13997. }
  13998. declare module "babylonjs/Shaders/layer.fragment" {
  13999. /** @hidden */
  14000. export var layerPixelShader: {
  14001. name: string;
  14002. shader: string;
  14003. };
  14004. }
  14005. declare module "babylonjs/Shaders/layer.vertex" {
  14006. /** @hidden */
  14007. export var layerVertexShader: {
  14008. name: string;
  14009. shader: string;
  14010. };
  14011. }
  14012. declare module "babylonjs/Layers/layer" {
  14013. import { Observable } from "babylonjs/Misc/observable";
  14014. import { Nullable } from "babylonjs/types";
  14015. import { Scene } from "babylonjs/scene";
  14016. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14017. import { Texture } from "babylonjs/Materials/Textures/texture";
  14018. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14019. import "babylonjs/Shaders/layer.fragment";
  14020. import "babylonjs/Shaders/layer.vertex";
  14021. /**
  14022. * This represents a full screen 2d layer.
  14023. * This can be useful to display a picture in the background of your scene for instance.
  14024. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14025. */
  14026. export class Layer {
  14027. /**
  14028. * Define the name of the layer.
  14029. */
  14030. name: string;
  14031. /**
  14032. * Define the texture the layer should display.
  14033. */
  14034. texture: Nullable<Texture>;
  14035. /**
  14036. * Is the layer in background or foreground.
  14037. */
  14038. isBackground: boolean;
  14039. /**
  14040. * Define the color of the layer (instead of texture).
  14041. */
  14042. color: Color4;
  14043. /**
  14044. * Define the scale of the layer in order to zoom in out of the texture.
  14045. */
  14046. scale: Vector2;
  14047. /**
  14048. * Define an offset for the layer in order to shift the texture.
  14049. */
  14050. offset: Vector2;
  14051. /**
  14052. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14053. */
  14054. alphaBlendingMode: number;
  14055. /**
  14056. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14057. * Alpha test will not mix with the background color in case of transparency.
  14058. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14059. */
  14060. alphaTest: boolean;
  14061. /**
  14062. * Define a mask to restrict the layer to only some of the scene cameras.
  14063. */
  14064. layerMask: number;
  14065. /**
  14066. * Define the list of render target the layer is visible into.
  14067. */
  14068. renderTargetTextures: RenderTargetTexture[];
  14069. /**
  14070. * Define if the layer is only used in renderTarget or if it also
  14071. * renders in the main frame buffer of the canvas.
  14072. */
  14073. renderOnlyInRenderTargetTextures: boolean;
  14074. private _scene;
  14075. private _vertexBuffers;
  14076. private _indexBuffer;
  14077. private _effect;
  14078. private _alphaTestEffect;
  14079. /**
  14080. * An event triggered when the layer is disposed.
  14081. */
  14082. onDisposeObservable: Observable<Layer>;
  14083. private _onDisposeObserver;
  14084. /**
  14085. * Back compatibility with callback before the onDisposeObservable existed.
  14086. * The set callback will be triggered when the layer has been disposed.
  14087. */
  14088. onDispose: () => void;
  14089. /**
  14090. * An event triggered before rendering the scene
  14091. */
  14092. onBeforeRenderObservable: Observable<Layer>;
  14093. private _onBeforeRenderObserver;
  14094. /**
  14095. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14096. * The set callback will be triggered just before rendering the layer.
  14097. */
  14098. onBeforeRender: () => void;
  14099. /**
  14100. * An event triggered after rendering the scene
  14101. */
  14102. onAfterRenderObservable: Observable<Layer>;
  14103. private _onAfterRenderObserver;
  14104. /**
  14105. * Back compatibility with callback before the onAfterRenderObservable existed.
  14106. * The set callback will be triggered just after rendering the layer.
  14107. */
  14108. onAfterRender: () => void;
  14109. /**
  14110. * Instantiates a new layer.
  14111. * This represents a full screen 2d layer.
  14112. * This can be useful to display a picture in the background of your scene for instance.
  14113. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14114. * @param name Define the name of the layer in the scene
  14115. * @param imgUrl Define the url of the texture to display in the layer
  14116. * @param scene Define the scene the layer belongs to
  14117. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14118. * @param color Defines a color for the layer
  14119. */
  14120. constructor(
  14121. /**
  14122. * Define the name of the layer.
  14123. */
  14124. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14125. private _createIndexBuffer;
  14126. /** @hidden */
  14127. _rebuild(): void;
  14128. /**
  14129. * Renders the layer in the scene.
  14130. */
  14131. render(): void;
  14132. /**
  14133. * Disposes and releases the associated ressources.
  14134. */
  14135. dispose(): void;
  14136. }
  14137. }
  14138. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14139. import { Scene } from "babylonjs/scene";
  14140. import { ISceneComponent } from "babylonjs/sceneComponent";
  14141. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14142. module "babylonjs/abstractScene" {
  14143. interface AbstractScene {
  14144. /**
  14145. * The list of procedural textures added to the scene
  14146. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14147. */
  14148. proceduralTextures: Array<ProceduralTexture>;
  14149. }
  14150. }
  14151. /**
  14152. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14153. * in a given scene.
  14154. */
  14155. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14156. /**
  14157. * The component name helpfull to identify the component in the list of scene components.
  14158. */
  14159. readonly name: string;
  14160. /**
  14161. * The scene the component belongs to.
  14162. */
  14163. scene: Scene;
  14164. /**
  14165. * Creates a new instance of the component for the given scene
  14166. * @param scene Defines the scene to register the component in
  14167. */
  14168. constructor(scene: Scene);
  14169. /**
  14170. * Registers the component in a given scene
  14171. */
  14172. register(): void;
  14173. /**
  14174. * Rebuilds the elements related to this component in case of
  14175. * context lost for instance.
  14176. */
  14177. rebuild(): void;
  14178. /**
  14179. * Disposes the component and the associated ressources.
  14180. */
  14181. dispose(): void;
  14182. private _beforeClear;
  14183. }
  14184. }
  14185. declare module "babylonjs/Shaders/procedural.vertex" {
  14186. /** @hidden */
  14187. export var proceduralVertexShader: {
  14188. name: string;
  14189. shader: string;
  14190. };
  14191. }
  14192. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14193. import { Observable } from "babylonjs/Misc/observable";
  14194. import { Nullable } from "babylonjs/types";
  14195. import { Scene } from "babylonjs/scene";
  14196. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14197. import { Effect } from "babylonjs/Materials/effect";
  14198. import { Texture } from "babylonjs/Materials/Textures/texture";
  14199. import "babylonjs/Shaders/procedural.vertex";
  14200. /**
  14201. * 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.
  14202. * This is the base class of any Procedural texture and contains most of the shareable code.
  14203. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14204. */
  14205. export class ProceduralTexture extends Texture {
  14206. isCube: boolean;
  14207. /**
  14208. * Define if the texture is enabled or not (disabled texture will not render)
  14209. */
  14210. isEnabled: boolean;
  14211. /**
  14212. * Define if the texture must be cleared before rendering (default is true)
  14213. */
  14214. autoClear: boolean;
  14215. /**
  14216. * Callback called when the texture is generated
  14217. */
  14218. onGenerated: () => void;
  14219. /**
  14220. * Event raised when the texture is generated
  14221. */
  14222. onGeneratedObservable: Observable<ProceduralTexture>;
  14223. /** @hidden */
  14224. _generateMipMaps: boolean;
  14225. /** @hidden **/
  14226. _effect: Effect;
  14227. /** @hidden */
  14228. _textures: {
  14229. [key: string]: Texture;
  14230. };
  14231. private _size;
  14232. private _currentRefreshId;
  14233. private _refreshRate;
  14234. private _vertexBuffers;
  14235. private _indexBuffer;
  14236. private _uniforms;
  14237. private _samplers;
  14238. private _fragment;
  14239. private _floats;
  14240. private _ints;
  14241. private _floatsArrays;
  14242. private _colors3;
  14243. private _colors4;
  14244. private _vectors2;
  14245. private _vectors3;
  14246. private _matrices;
  14247. private _fallbackTexture;
  14248. private _fallbackTextureUsed;
  14249. private _engine;
  14250. private _cachedDefines;
  14251. private _contentUpdateId;
  14252. private _contentData;
  14253. /**
  14254. * Instantiates a new procedural texture.
  14255. * 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.
  14256. * This is the base class of any Procedural texture and contains most of the shareable code.
  14257. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14258. * @param name Define the name of the texture
  14259. * @param size Define the size of the texture to create
  14260. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14261. * @param scene Define the scene the texture belongs to
  14262. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14263. * @param generateMipMaps Define if the texture should creates mip maps or not
  14264. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14265. */
  14266. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14267. /**
  14268. * The effect that is created when initializing the post process.
  14269. * @returns The created effect corrisponding the the postprocess.
  14270. */
  14271. getEffect(): Effect;
  14272. /**
  14273. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14274. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14275. */
  14276. getContent(): Nullable<ArrayBufferView>;
  14277. private _createIndexBuffer;
  14278. /** @hidden */
  14279. _rebuild(): void;
  14280. /**
  14281. * Resets the texture in order to recreate its associated resources.
  14282. * This can be called in case of context loss
  14283. */
  14284. reset(): void;
  14285. protected _getDefines(): string;
  14286. /**
  14287. * Is the texture ready to be used ? (rendered at least once)
  14288. * @returns true if ready, otherwise, false.
  14289. */
  14290. isReady(): boolean;
  14291. /**
  14292. * Resets the refresh counter of the texture and start bak from scratch.
  14293. * Could be useful to regenerate the texture if it is setup to render only once.
  14294. */
  14295. resetRefreshCounter(): void;
  14296. /**
  14297. * Set the fragment shader to use in order to render the texture.
  14298. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14299. */
  14300. setFragment(fragment: any): void;
  14301. /**
  14302. * Define the refresh rate of the texture or the rendering frequency.
  14303. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14304. */
  14305. refreshRate: number;
  14306. /** @hidden */
  14307. _shouldRender(): boolean;
  14308. /**
  14309. * Get the size the texture is rendering at.
  14310. * @returns the size (texture is always squared)
  14311. */
  14312. getRenderSize(): number;
  14313. /**
  14314. * Resize the texture to new value.
  14315. * @param size Define the new size the texture should have
  14316. * @param generateMipMaps Define whether the new texture should create mip maps
  14317. */
  14318. resize(size: number, generateMipMaps: boolean): void;
  14319. private _checkUniform;
  14320. /**
  14321. * Set a texture in the shader program used to render.
  14322. * @param name Define the name of the uniform samplers as defined in the shader
  14323. * @param texture Define the texture to bind to this sampler
  14324. * @return the texture itself allowing "fluent" like uniform updates
  14325. */
  14326. setTexture(name: string, texture: Texture): ProceduralTexture;
  14327. /**
  14328. * Set a float in the shader.
  14329. * @param name Define the name of the uniform as defined in the shader
  14330. * @param value Define the value to give to the uniform
  14331. * @return the texture itself allowing "fluent" like uniform updates
  14332. */
  14333. setFloat(name: string, value: number): ProceduralTexture;
  14334. /**
  14335. * Set a int in the shader.
  14336. * @param name Define the name of the uniform as defined in the shader
  14337. * @param value Define the value to give to the uniform
  14338. * @return the texture itself allowing "fluent" like uniform updates
  14339. */
  14340. setInt(name: string, value: number): ProceduralTexture;
  14341. /**
  14342. * Set an array of floats in the shader.
  14343. * @param name Define the name of the uniform as defined in the shader
  14344. * @param value Define the value to give to the uniform
  14345. * @return the texture itself allowing "fluent" like uniform updates
  14346. */
  14347. setFloats(name: string, value: number[]): ProceduralTexture;
  14348. /**
  14349. * Set a vec3 in the shader from a Color3.
  14350. * @param name Define the name of the uniform as defined in the shader
  14351. * @param value Define the value to give to the uniform
  14352. * @return the texture itself allowing "fluent" like uniform updates
  14353. */
  14354. setColor3(name: string, value: Color3): ProceduralTexture;
  14355. /**
  14356. * Set a vec4 in the shader from a Color4.
  14357. * @param name Define the name of the uniform as defined in the shader
  14358. * @param value Define the value to give to the uniform
  14359. * @return the texture itself allowing "fluent" like uniform updates
  14360. */
  14361. setColor4(name: string, value: Color4): ProceduralTexture;
  14362. /**
  14363. * Set a vec2 in the shader from a Vector2.
  14364. * @param name Define the name of the uniform as defined in the shader
  14365. * @param value Define the value to give to the uniform
  14366. * @return the texture itself allowing "fluent" like uniform updates
  14367. */
  14368. setVector2(name: string, value: Vector2): ProceduralTexture;
  14369. /**
  14370. * Set a vec3 in the shader from a Vector3.
  14371. * @param name Define the name of the uniform as defined in the shader
  14372. * @param value Define the value to give to the uniform
  14373. * @return the texture itself allowing "fluent" like uniform updates
  14374. */
  14375. setVector3(name: string, value: Vector3): ProceduralTexture;
  14376. /**
  14377. * Set a mat4 in the shader from a MAtrix.
  14378. * @param name Define the name of the uniform as defined in the shader
  14379. * @param value Define the value to give to the uniform
  14380. * @return the texture itself allowing "fluent" like uniform updates
  14381. */
  14382. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14383. /**
  14384. * Render the texture to its associated render target.
  14385. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14386. */
  14387. render(useCameraPostProcess?: boolean): void;
  14388. /**
  14389. * Clone the texture.
  14390. * @returns the cloned texture
  14391. */
  14392. clone(): ProceduralTexture;
  14393. /**
  14394. * Dispose the texture and release its asoociated resources.
  14395. */
  14396. dispose(): void;
  14397. }
  14398. }
  14399. declare module "babylonjs/Particles/baseParticleSystem" {
  14400. import { Nullable } from "babylonjs/types";
  14401. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14403. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14404. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14405. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14406. import { Scene } from "babylonjs/scene";
  14407. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14408. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14409. import { Texture } from "babylonjs/Materials/Textures/texture";
  14410. import { Animation } from "babylonjs/Animations/animation";
  14411. /**
  14412. * This represents the base class for particle system in Babylon.
  14413. * 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.
  14414. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14415. * @example https://doc.babylonjs.com/babylon101/particles
  14416. */
  14417. export class BaseParticleSystem {
  14418. /**
  14419. * Source color is added to the destination color without alpha affecting the result
  14420. */
  14421. static BLENDMODE_ONEONE: number;
  14422. /**
  14423. * Blend current color and particle color using particle’s alpha
  14424. */
  14425. static BLENDMODE_STANDARD: number;
  14426. /**
  14427. * Add current color and particle color multiplied by particle’s alpha
  14428. */
  14429. static BLENDMODE_ADD: number;
  14430. /**
  14431. * Multiply current color with particle color
  14432. */
  14433. static BLENDMODE_MULTIPLY: number;
  14434. /**
  14435. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14436. */
  14437. static BLENDMODE_MULTIPLYADD: number;
  14438. /**
  14439. * List of animations used by the particle system.
  14440. */
  14441. animations: Animation[];
  14442. /**
  14443. * The id of the Particle system.
  14444. */
  14445. id: string;
  14446. /**
  14447. * The friendly name of the Particle system.
  14448. */
  14449. name: string;
  14450. /**
  14451. * The rendering group used by the Particle system to chose when to render.
  14452. */
  14453. renderingGroupId: number;
  14454. /**
  14455. * The emitter represents the Mesh or position we are attaching the particle system to.
  14456. */
  14457. emitter: Nullable<AbstractMesh | Vector3>;
  14458. /**
  14459. * The maximum number of particles to emit per frame
  14460. */
  14461. emitRate: number;
  14462. /**
  14463. * If you want to launch only a few particles at once, that can be done, as well.
  14464. */
  14465. manualEmitCount: number;
  14466. /**
  14467. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14468. */
  14469. updateSpeed: number;
  14470. /**
  14471. * The amount of time the particle system is running (depends of the overall update speed).
  14472. */
  14473. targetStopDuration: number;
  14474. /**
  14475. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14476. */
  14477. disposeOnStop: boolean;
  14478. /**
  14479. * Minimum power of emitting particles.
  14480. */
  14481. minEmitPower: number;
  14482. /**
  14483. * Maximum power of emitting particles.
  14484. */
  14485. maxEmitPower: number;
  14486. /**
  14487. * Minimum life time of emitting particles.
  14488. */
  14489. minLifeTime: number;
  14490. /**
  14491. * Maximum life time of emitting particles.
  14492. */
  14493. maxLifeTime: number;
  14494. /**
  14495. * Minimum Size of emitting particles.
  14496. */
  14497. minSize: number;
  14498. /**
  14499. * Maximum Size of emitting particles.
  14500. */
  14501. maxSize: number;
  14502. /**
  14503. * Minimum scale of emitting particles on X axis.
  14504. */
  14505. minScaleX: number;
  14506. /**
  14507. * Maximum scale of emitting particles on X axis.
  14508. */
  14509. maxScaleX: number;
  14510. /**
  14511. * Minimum scale of emitting particles on Y axis.
  14512. */
  14513. minScaleY: number;
  14514. /**
  14515. * Maximum scale of emitting particles on Y axis.
  14516. */
  14517. maxScaleY: number;
  14518. /**
  14519. * Gets or sets the minimal initial rotation in radians.
  14520. */
  14521. minInitialRotation: number;
  14522. /**
  14523. * Gets or sets the maximal initial rotation in radians.
  14524. */
  14525. maxInitialRotation: number;
  14526. /**
  14527. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14528. */
  14529. minAngularSpeed: number;
  14530. /**
  14531. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14532. */
  14533. maxAngularSpeed: number;
  14534. /**
  14535. * The texture used to render each particle. (this can be a spritesheet)
  14536. */
  14537. particleTexture: Nullable<Texture>;
  14538. /**
  14539. * The layer mask we are rendering the particles through.
  14540. */
  14541. layerMask: number;
  14542. /**
  14543. * This can help using your own shader to render the particle system.
  14544. * The according effect will be created
  14545. */
  14546. customShader: any;
  14547. /**
  14548. * By default particle system starts as soon as they are created. This prevents the
  14549. * automatic start to happen and let you decide when to start emitting particles.
  14550. */
  14551. preventAutoStart: boolean;
  14552. private _noiseTexture;
  14553. /**
  14554. * Gets or sets a texture used to add random noise to particle positions
  14555. */
  14556. noiseTexture: Nullable<ProceduralTexture>;
  14557. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14558. noiseStrength: Vector3;
  14559. /**
  14560. * Callback triggered when the particle animation is ending.
  14561. */
  14562. onAnimationEnd: Nullable<() => void>;
  14563. /**
  14564. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14565. */
  14566. blendMode: number;
  14567. /**
  14568. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14569. * to override the particles.
  14570. */
  14571. forceDepthWrite: boolean;
  14572. /** 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 */
  14573. preWarmCycles: number;
  14574. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14575. preWarmStepOffset: number;
  14576. /**
  14577. * 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)
  14578. */
  14579. spriteCellChangeSpeed: number;
  14580. /**
  14581. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14582. */
  14583. startSpriteCellID: number;
  14584. /**
  14585. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14586. */
  14587. endSpriteCellID: number;
  14588. /**
  14589. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14590. */
  14591. spriteCellWidth: number;
  14592. /**
  14593. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14594. */
  14595. spriteCellHeight: number;
  14596. /**
  14597. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14598. */
  14599. spriteRandomStartCell: boolean;
  14600. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14601. translationPivot: Vector2;
  14602. /** @hidden */
  14603. protected _isAnimationSheetEnabled: boolean;
  14604. /**
  14605. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14606. */
  14607. beginAnimationOnStart: boolean;
  14608. /**
  14609. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14610. */
  14611. beginAnimationFrom: number;
  14612. /**
  14613. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14614. */
  14615. beginAnimationTo: number;
  14616. /**
  14617. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14618. */
  14619. beginAnimationLoop: boolean;
  14620. /**
  14621. * Gets or sets a world offset applied to all particles
  14622. */
  14623. worldOffset: Vector3;
  14624. /**
  14625. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14626. */
  14627. isAnimationSheetEnabled: boolean;
  14628. /**
  14629. * Get hosting scene
  14630. * @returns the scene
  14631. */
  14632. getScene(): Scene;
  14633. /**
  14634. * You can use gravity if you want to give an orientation to your particles.
  14635. */
  14636. gravity: Vector3;
  14637. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14638. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14639. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14640. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14641. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14642. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14643. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14644. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14645. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14646. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14647. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14648. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14649. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14650. /**
  14651. * Defines the delay in milliseconds before starting the system (0 by default)
  14652. */
  14653. startDelay: number;
  14654. /**
  14655. * Gets the current list of drag gradients.
  14656. * You must use addDragGradient and removeDragGradient to udpate this list
  14657. * @returns the list of drag gradients
  14658. */
  14659. getDragGradients(): Nullable<Array<FactorGradient>>;
  14660. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14661. limitVelocityDamping: number;
  14662. /**
  14663. * Gets the current list of limit velocity gradients.
  14664. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14665. * @returns the list of limit velocity gradients
  14666. */
  14667. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14668. /**
  14669. * Gets the current list of color gradients.
  14670. * You must use addColorGradient and removeColorGradient to udpate this list
  14671. * @returns the list of color gradients
  14672. */
  14673. getColorGradients(): Nullable<Array<ColorGradient>>;
  14674. /**
  14675. * Gets the current list of size gradients.
  14676. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14677. * @returns the list of size gradients
  14678. */
  14679. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14680. /**
  14681. * Gets the current list of color remap gradients.
  14682. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14683. * @returns the list of color remap gradients
  14684. */
  14685. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14686. /**
  14687. * Gets the current list of alpha remap gradients.
  14688. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14689. * @returns the list of alpha remap gradients
  14690. */
  14691. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14692. /**
  14693. * Gets the current list of life time gradients.
  14694. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14695. * @returns the list of life time gradients
  14696. */
  14697. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14698. /**
  14699. * Gets the current list of angular speed gradients.
  14700. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14701. * @returns the list of angular speed gradients
  14702. */
  14703. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14704. /**
  14705. * Gets the current list of velocity gradients.
  14706. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14707. * @returns the list of velocity gradients
  14708. */
  14709. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14710. /**
  14711. * Gets the current list of start size gradients.
  14712. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14713. * @returns the list of start size gradients
  14714. */
  14715. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14716. /**
  14717. * Gets the current list of emit rate gradients.
  14718. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14719. * @returns the list of emit rate gradients
  14720. */
  14721. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14722. /**
  14723. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14724. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14725. */
  14726. direction1: Vector3;
  14727. /**
  14728. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14729. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14730. */
  14731. direction2: Vector3;
  14732. /**
  14733. * 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.
  14734. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14735. */
  14736. minEmitBox: Vector3;
  14737. /**
  14738. * 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.
  14739. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14740. */
  14741. maxEmitBox: Vector3;
  14742. /**
  14743. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14744. */
  14745. color1: Color4;
  14746. /**
  14747. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14748. */
  14749. color2: Color4;
  14750. /**
  14751. * Color the particle will have at the end of its lifetime
  14752. */
  14753. colorDead: Color4;
  14754. /**
  14755. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14756. */
  14757. textureMask: Color4;
  14758. /**
  14759. * The particle emitter type defines the emitter used by the particle system.
  14760. * It can be for example box, sphere, or cone...
  14761. */
  14762. particleEmitterType: IParticleEmitterType;
  14763. /** @hidden */
  14764. _isSubEmitter: boolean;
  14765. /**
  14766. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14767. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14768. */
  14769. billboardMode: number;
  14770. protected _isBillboardBased: boolean;
  14771. /**
  14772. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14773. */
  14774. isBillboardBased: boolean;
  14775. /**
  14776. * The scene the particle system belongs to.
  14777. */
  14778. protected _scene: Scene;
  14779. /**
  14780. * Local cache of defines for image processing.
  14781. */
  14782. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14783. /**
  14784. * Default configuration related to image processing available in the standard Material.
  14785. */
  14786. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14787. /**
  14788. * Gets the image processing configuration used either in this material.
  14789. */
  14790. /**
  14791. * Sets the Default image processing configuration used either in the this material.
  14792. *
  14793. * If sets to null, the scene one is in use.
  14794. */
  14795. imageProcessingConfiguration: ImageProcessingConfiguration;
  14796. /**
  14797. * Attaches a new image processing configuration to the Standard Material.
  14798. * @param configuration
  14799. */
  14800. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14801. /** @hidden */
  14802. protected _reset(): void;
  14803. /** @hidden */
  14804. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14805. /**
  14806. * Instantiates a particle system.
  14807. * 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.
  14808. * @param name The name of the particle system
  14809. */
  14810. constructor(name: string);
  14811. /**
  14812. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14813. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14814. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14815. * @returns the emitter
  14816. */
  14817. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14818. /**
  14819. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14820. * @param radius The radius of the hemisphere to emit from
  14821. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14822. * @returns the emitter
  14823. */
  14824. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14825. /**
  14826. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14827. * @param radius The radius of the sphere to emit from
  14828. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14829. * @returns the emitter
  14830. */
  14831. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14832. /**
  14833. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14834. * @param radius The radius of the sphere to emit from
  14835. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14836. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14837. * @returns the emitter
  14838. */
  14839. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14840. /**
  14841. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14842. * @param radius The radius of the emission cylinder
  14843. * @param height The height of the emission cylinder
  14844. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14845. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14846. * @returns the emitter
  14847. */
  14848. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14849. /**
  14850. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14851. * @param radius The radius of the cylinder to emit from
  14852. * @param height The height of the emission cylinder
  14853. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14856. * @returns the emitter
  14857. */
  14858. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14859. /**
  14860. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14861. * @param radius The radius of the cone to emit from
  14862. * @param angle The base angle of the cone
  14863. * @returns the emitter
  14864. */
  14865. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14866. /**
  14867. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14868. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14869. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14870. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14871. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14872. * @returns the emitter
  14873. */
  14874. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14875. }
  14876. }
  14877. declare module "babylonjs/Particles/subEmitter" {
  14878. import { Scene } from "babylonjs/scene";
  14879. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14880. /**
  14881. * Type of sub emitter
  14882. */
  14883. export enum SubEmitterType {
  14884. /**
  14885. * Attached to the particle over it's lifetime
  14886. */
  14887. ATTACHED = 0,
  14888. /**
  14889. * Created when the particle dies
  14890. */
  14891. END = 1
  14892. }
  14893. /**
  14894. * Sub emitter class used to emit particles from an existing particle
  14895. */
  14896. export class SubEmitter {
  14897. /**
  14898. * the particle system to be used by the sub emitter
  14899. */
  14900. particleSystem: ParticleSystem;
  14901. /**
  14902. * Type of the submitter (Default: END)
  14903. */
  14904. type: SubEmitterType;
  14905. /**
  14906. * 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)
  14907. * Note: This only is supported when using an emitter of type Mesh
  14908. */
  14909. inheritDirection: boolean;
  14910. /**
  14911. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14912. */
  14913. inheritedVelocityAmount: number;
  14914. /**
  14915. * Creates a sub emitter
  14916. * @param particleSystem the particle system to be used by the sub emitter
  14917. */
  14918. constructor(
  14919. /**
  14920. * the particle system to be used by the sub emitter
  14921. */
  14922. particleSystem: ParticleSystem);
  14923. /**
  14924. * Clones the sub emitter
  14925. * @returns the cloned sub emitter
  14926. */
  14927. clone(): SubEmitter;
  14928. /**
  14929. * Serialize current object to a JSON object
  14930. * @returns the serialized object
  14931. */
  14932. serialize(): any;
  14933. /** @hidden */
  14934. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14935. /**
  14936. * Creates a new SubEmitter from a serialized JSON version
  14937. * @param serializationObject defines the JSON object to read from
  14938. * @param scene defines the hosting scene
  14939. * @param rootUrl defines the rootUrl for data loading
  14940. * @returns a new SubEmitter
  14941. */
  14942. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14943. /** Release associated resources */
  14944. dispose(): void;
  14945. }
  14946. }
  14947. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14948. /** @hidden */
  14949. export var clipPlaneFragmentDeclaration: {
  14950. name: string;
  14951. shader: string;
  14952. };
  14953. }
  14954. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14955. /** @hidden */
  14956. export var imageProcessingDeclaration: {
  14957. name: string;
  14958. shader: string;
  14959. };
  14960. }
  14961. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14962. /** @hidden */
  14963. export var imageProcessingFunctions: {
  14964. name: string;
  14965. shader: string;
  14966. };
  14967. }
  14968. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14969. /** @hidden */
  14970. export var clipPlaneFragment: {
  14971. name: string;
  14972. shader: string;
  14973. };
  14974. }
  14975. declare module "babylonjs/Shaders/particles.fragment" {
  14976. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14977. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14978. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14979. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14980. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14981. /** @hidden */
  14982. export var particlesPixelShader: {
  14983. name: string;
  14984. shader: string;
  14985. };
  14986. }
  14987. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14988. /** @hidden */
  14989. export var clipPlaneVertexDeclaration: {
  14990. name: string;
  14991. shader: string;
  14992. };
  14993. }
  14994. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14995. /** @hidden */
  14996. export var clipPlaneVertex: {
  14997. name: string;
  14998. shader: string;
  14999. };
  15000. }
  15001. declare module "babylonjs/Shaders/particles.vertex" {
  15002. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15003. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15004. /** @hidden */
  15005. export var particlesVertexShader: {
  15006. name: string;
  15007. shader: string;
  15008. };
  15009. }
  15010. declare module "babylonjs/Particles/particleSystem" {
  15011. import { Nullable } from "babylonjs/types";
  15012. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15013. import { Observable } from "babylonjs/Misc/observable";
  15014. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15015. import { Effect } from "babylonjs/Materials/effect";
  15016. import { Scene, IDisposable } from "babylonjs/scene";
  15017. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15018. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15019. import { Particle } from "babylonjs/Particles/particle";
  15020. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15021. import "babylonjs/Shaders/particles.fragment";
  15022. import "babylonjs/Shaders/particles.vertex";
  15023. /**
  15024. * This represents a particle system in Babylon.
  15025. * 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.
  15026. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15027. * @example https://doc.babylonjs.com/babylon101/particles
  15028. */
  15029. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15030. /**
  15031. * Billboard mode will only apply to Y axis
  15032. */
  15033. static readonly BILLBOARDMODE_Y: number;
  15034. /**
  15035. * Billboard mode will apply to all axes
  15036. */
  15037. static readonly BILLBOARDMODE_ALL: number;
  15038. /**
  15039. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15040. */
  15041. static readonly BILLBOARDMODE_STRETCHED: number;
  15042. /**
  15043. * This function can be defined to provide custom update for active particles.
  15044. * This function will be called instead of regular update (age, position, color, etc.).
  15045. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15046. */
  15047. updateFunction: (particles: Particle[]) => void;
  15048. private _emitterWorldMatrix;
  15049. /**
  15050. * This function can be defined to specify initial direction for every new particle.
  15051. * It by default use the emitterType defined function
  15052. */
  15053. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15054. /**
  15055. * This function can be defined to specify initial position for every new particle.
  15056. * It by default use the emitterType defined function
  15057. */
  15058. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15059. /**
  15060. * @hidden
  15061. */
  15062. _inheritedVelocityOffset: Vector3;
  15063. /**
  15064. * An event triggered when the system is disposed
  15065. */
  15066. onDisposeObservable: Observable<ParticleSystem>;
  15067. private _onDisposeObserver;
  15068. /**
  15069. * Sets a callback that will be triggered when the system is disposed
  15070. */
  15071. onDispose: () => void;
  15072. private _particles;
  15073. private _epsilon;
  15074. private _capacity;
  15075. private _stockParticles;
  15076. private _newPartsExcess;
  15077. private _vertexData;
  15078. private _vertexBuffer;
  15079. private _vertexBuffers;
  15080. private _spriteBuffer;
  15081. private _indexBuffer;
  15082. private _effect;
  15083. private _customEffect;
  15084. private _cachedDefines;
  15085. private _scaledColorStep;
  15086. private _colorDiff;
  15087. private _scaledDirection;
  15088. private _scaledGravity;
  15089. private _currentRenderId;
  15090. private _alive;
  15091. private _useInstancing;
  15092. private _started;
  15093. private _stopped;
  15094. private _actualFrame;
  15095. private _scaledUpdateSpeed;
  15096. private _vertexBufferSize;
  15097. /** @hidden */
  15098. _currentEmitRateGradient: Nullable<FactorGradient>;
  15099. /** @hidden */
  15100. _currentEmitRate1: number;
  15101. /** @hidden */
  15102. _currentEmitRate2: number;
  15103. /** @hidden */
  15104. _currentStartSizeGradient: Nullable<FactorGradient>;
  15105. /** @hidden */
  15106. _currentStartSize1: number;
  15107. /** @hidden */
  15108. _currentStartSize2: number;
  15109. private readonly _rawTextureWidth;
  15110. private _rampGradientsTexture;
  15111. private _useRampGradients;
  15112. /** Gets or sets a boolean indicating that ramp gradients must be used
  15113. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15114. */
  15115. useRampGradients: boolean;
  15116. /**
  15117. * 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.
  15118. * 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: [])
  15119. */
  15120. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15121. private _subEmitters;
  15122. /**
  15123. * @hidden
  15124. * If the particle systems emitter should be disposed when the particle system is disposed
  15125. */
  15126. _disposeEmitterOnDispose: boolean;
  15127. /**
  15128. * The current active Sub-systems, this property is used by the root particle system only.
  15129. */
  15130. activeSubSystems: Array<ParticleSystem>;
  15131. private _rootParticleSystem;
  15132. /**
  15133. * Gets the current list of active particles
  15134. */
  15135. readonly particles: Particle[];
  15136. /**
  15137. * Returns the string "ParticleSystem"
  15138. * @returns a string containing the class name
  15139. */
  15140. getClassName(): string;
  15141. /**
  15142. * Instantiates a particle system.
  15143. * 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.
  15144. * @param name The name of the particle system
  15145. * @param capacity The max number of particles alive at the same time
  15146. * @param scene The scene the particle system belongs to
  15147. * @param customEffect a custom effect used to change the way particles are rendered by default
  15148. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15149. * @param epsilon Offset used to render the particles
  15150. */
  15151. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15152. private _addFactorGradient;
  15153. private _removeFactorGradient;
  15154. /**
  15155. * Adds a new life time gradient
  15156. * @param gradient defines the gradient to use (between 0 and 1)
  15157. * @param factor defines the life time factor to affect to the specified gradient
  15158. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15159. * @returns the current particle system
  15160. */
  15161. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15162. /**
  15163. * Remove a specific life time gradient
  15164. * @param gradient defines the gradient to remove
  15165. * @returns the current particle system
  15166. */
  15167. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15168. /**
  15169. * Adds a new size gradient
  15170. * @param gradient defines the gradient to use (between 0 and 1)
  15171. * @param factor defines the size factor to affect to the specified gradient
  15172. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15173. * @returns the current particle system
  15174. */
  15175. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15176. /**
  15177. * Remove a specific size gradient
  15178. * @param gradient defines the gradient to remove
  15179. * @returns the current particle system
  15180. */
  15181. removeSizeGradient(gradient: number): IParticleSystem;
  15182. /**
  15183. * Adds a new color remap gradient
  15184. * @param gradient defines the gradient to use (between 0 and 1)
  15185. * @param min defines the color remap minimal range
  15186. * @param max defines the color remap maximal range
  15187. * @returns the current particle system
  15188. */
  15189. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15190. /**
  15191. * Remove a specific color remap gradient
  15192. * @param gradient defines the gradient to remove
  15193. * @returns the current particle system
  15194. */
  15195. removeColorRemapGradient(gradient: number): IParticleSystem;
  15196. /**
  15197. * Adds a new alpha remap gradient
  15198. * @param gradient defines the gradient to use (between 0 and 1)
  15199. * @param min defines the alpha remap minimal range
  15200. * @param max defines the alpha remap maximal range
  15201. * @returns the current particle system
  15202. */
  15203. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15204. /**
  15205. * Remove a specific alpha remap gradient
  15206. * @param gradient defines the gradient to remove
  15207. * @returns the current particle system
  15208. */
  15209. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15210. /**
  15211. * Adds a new angular speed gradient
  15212. * @param gradient defines the gradient to use (between 0 and 1)
  15213. * @param factor defines the angular speed to affect to the specified gradient
  15214. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15215. * @returns the current particle system
  15216. */
  15217. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15218. /**
  15219. * Remove a specific angular speed gradient
  15220. * @param gradient defines the gradient to remove
  15221. * @returns the current particle system
  15222. */
  15223. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15224. /**
  15225. * Adds a new velocity gradient
  15226. * @param gradient defines the gradient to use (between 0 and 1)
  15227. * @param factor defines the velocity to affect to the specified gradient
  15228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15229. * @returns the current particle system
  15230. */
  15231. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15232. /**
  15233. * Remove a specific velocity gradient
  15234. * @param gradient defines the gradient to remove
  15235. * @returns the current particle system
  15236. */
  15237. removeVelocityGradient(gradient: number): IParticleSystem;
  15238. /**
  15239. * Adds a new limit velocity gradient
  15240. * @param gradient defines the gradient to use (between 0 and 1)
  15241. * @param factor defines the limit velocity value to affect to the specified gradient
  15242. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15243. * @returns the current particle system
  15244. */
  15245. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15246. /**
  15247. * Remove a specific limit velocity gradient
  15248. * @param gradient defines the gradient to remove
  15249. * @returns the current particle system
  15250. */
  15251. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15252. /**
  15253. * Adds a new drag gradient
  15254. * @param gradient defines the gradient to use (between 0 and 1)
  15255. * @param factor defines the drag value to affect to the specified gradient
  15256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15257. * @returns the current particle system
  15258. */
  15259. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15260. /**
  15261. * Remove a specific drag gradient
  15262. * @param gradient defines the gradient to remove
  15263. * @returns the current particle system
  15264. */
  15265. removeDragGradient(gradient: number): IParticleSystem;
  15266. /**
  15267. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15268. * @param gradient defines the gradient to use (between 0 and 1)
  15269. * @param factor defines the emit rate value to affect to the specified gradient
  15270. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15271. * @returns the current particle system
  15272. */
  15273. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15274. /**
  15275. * Remove a specific emit rate gradient
  15276. * @param gradient defines the gradient to remove
  15277. * @returns the current particle system
  15278. */
  15279. removeEmitRateGradient(gradient: number): IParticleSystem;
  15280. /**
  15281. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15282. * @param gradient defines the gradient to use (between 0 and 1)
  15283. * @param factor defines the start size value to affect to the specified gradient
  15284. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15285. * @returns the current particle system
  15286. */
  15287. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15288. /**
  15289. * Remove a specific start size gradient
  15290. * @param gradient defines the gradient to remove
  15291. * @returns the current particle system
  15292. */
  15293. removeStartSizeGradient(gradient: number): IParticleSystem;
  15294. private _createRampGradientTexture;
  15295. /**
  15296. * Gets the current list of ramp gradients.
  15297. * You must use addRampGradient and removeRampGradient to udpate this list
  15298. * @returns the list of ramp gradients
  15299. */
  15300. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15301. /**
  15302. * Adds a new ramp gradient used to remap particle colors
  15303. * @param gradient defines the gradient to use (between 0 and 1)
  15304. * @param color defines the color to affect to the specified gradient
  15305. * @returns the current particle system
  15306. */
  15307. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15308. /**
  15309. * Remove a specific ramp gradient
  15310. * @param gradient defines the gradient to remove
  15311. * @returns the current particle system
  15312. */
  15313. removeRampGradient(gradient: number): ParticleSystem;
  15314. /**
  15315. * Adds a new color gradient
  15316. * @param gradient defines the gradient to use (between 0 and 1)
  15317. * @param color1 defines the color to affect to the specified gradient
  15318. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15319. * @returns this particle system
  15320. */
  15321. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15322. /**
  15323. * Remove a specific color gradient
  15324. * @param gradient defines the gradient to remove
  15325. * @returns this particle system
  15326. */
  15327. removeColorGradient(gradient: number): IParticleSystem;
  15328. private _fetchR;
  15329. protected _reset(): void;
  15330. private _resetEffect;
  15331. private _createVertexBuffers;
  15332. private _createIndexBuffer;
  15333. /**
  15334. * Gets the maximum number of particles active at the same time.
  15335. * @returns The max number of active particles.
  15336. */
  15337. getCapacity(): number;
  15338. /**
  15339. * Gets whether there are still active particles in the system.
  15340. * @returns True if it is alive, otherwise false.
  15341. */
  15342. isAlive(): boolean;
  15343. /**
  15344. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15345. * @returns True if it has been started, otherwise false.
  15346. */
  15347. isStarted(): boolean;
  15348. private _prepareSubEmitterInternalArray;
  15349. /**
  15350. * Starts the particle system and begins to emit
  15351. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15352. */
  15353. start(delay?: number): void;
  15354. /**
  15355. * Stops the particle system.
  15356. * @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.
  15357. */
  15358. stop(stopSubEmitters?: boolean): void;
  15359. /**
  15360. * Remove all active particles
  15361. */
  15362. reset(): void;
  15363. /**
  15364. * @hidden (for internal use only)
  15365. */
  15366. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15367. /**
  15368. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15369. * Its lifetime will start back at 0.
  15370. */
  15371. recycleParticle: (particle: Particle) => void;
  15372. private _stopSubEmitters;
  15373. private _createParticle;
  15374. private _removeFromRoot;
  15375. private _emitFromParticle;
  15376. private _update;
  15377. /** @hidden */
  15378. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15379. /** @hidden */
  15380. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15381. /** @hidden */
  15382. private _getEffect;
  15383. /**
  15384. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15385. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15386. */
  15387. animate(preWarmOnly?: boolean): void;
  15388. private _appendParticleVertices;
  15389. /**
  15390. * Rebuilds the particle system.
  15391. */
  15392. rebuild(): void;
  15393. /**
  15394. * Is this system ready to be used/rendered
  15395. * @return true if the system is ready
  15396. */
  15397. isReady(): boolean;
  15398. private _render;
  15399. /**
  15400. * Renders the particle system in its current state.
  15401. * @returns the current number of particles
  15402. */
  15403. render(): number;
  15404. /**
  15405. * Disposes the particle system and free the associated resources
  15406. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15407. */
  15408. dispose(disposeTexture?: boolean): void;
  15409. /**
  15410. * Clones the particle system.
  15411. * @param name The name of the cloned object
  15412. * @param newEmitter The new emitter to use
  15413. * @returns the cloned particle system
  15414. */
  15415. clone(name: string, newEmitter: any): ParticleSystem;
  15416. /**
  15417. * Serializes the particle system to a JSON object.
  15418. * @returns the JSON object
  15419. */
  15420. serialize(): any;
  15421. /** @hidden */
  15422. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15423. /** @hidden */
  15424. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15425. /**
  15426. * Parses a JSON object to create a particle system.
  15427. * @param parsedParticleSystem The JSON object to parse
  15428. * @param scene The scene to create the particle system in
  15429. * @param rootUrl The root url to use to load external dependencies like texture
  15430. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15431. * @returns the Parsed particle system
  15432. */
  15433. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15434. }
  15435. }
  15436. declare module "babylonjs/Particles/particle" {
  15437. import { Nullable } from "babylonjs/types";
  15438. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15439. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15440. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15441. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15442. /**
  15443. * A particle represents one of the element emitted by a particle system.
  15444. * This is mainly define by its coordinates, direction, velocity and age.
  15445. */
  15446. export class Particle {
  15447. /**
  15448. * The particle system the particle belongs to.
  15449. */
  15450. particleSystem: ParticleSystem;
  15451. private static _Count;
  15452. /**
  15453. * Unique ID of the particle
  15454. */
  15455. id: number;
  15456. /**
  15457. * The world position of the particle in the scene.
  15458. */
  15459. position: Vector3;
  15460. /**
  15461. * The world direction of the particle in the scene.
  15462. */
  15463. direction: Vector3;
  15464. /**
  15465. * The color of the particle.
  15466. */
  15467. color: Color4;
  15468. /**
  15469. * The color change of the particle per step.
  15470. */
  15471. colorStep: Color4;
  15472. /**
  15473. * Defines how long will the life of the particle be.
  15474. */
  15475. lifeTime: number;
  15476. /**
  15477. * The current age of the particle.
  15478. */
  15479. age: number;
  15480. /**
  15481. * The current size of the particle.
  15482. */
  15483. size: number;
  15484. /**
  15485. * The current scale of the particle.
  15486. */
  15487. scale: Vector2;
  15488. /**
  15489. * The current angle of the particle.
  15490. */
  15491. angle: number;
  15492. /**
  15493. * Defines how fast is the angle changing.
  15494. */
  15495. angularSpeed: number;
  15496. /**
  15497. * Defines the cell index used by the particle to be rendered from a sprite.
  15498. */
  15499. cellIndex: number;
  15500. /**
  15501. * The information required to support color remapping
  15502. */
  15503. remapData: Vector4;
  15504. /** @hidden */
  15505. _randomCellOffset?: number;
  15506. /** @hidden */
  15507. _initialDirection: Nullable<Vector3>;
  15508. /** @hidden */
  15509. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15510. /** @hidden */
  15511. _initialStartSpriteCellID: number;
  15512. /** @hidden */
  15513. _initialEndSpriteCellID: number;
  15514. /** @hidden */
  15515. _currentColorGradient: Nullable<ColorGradient>;
  15516. /** @hidden */
  15517. _currentColor1: Color4;
  15518. /** @hidden */
  15519. _currentColor2: Color4;
  15520. /** @hidden */
  15521. _currentSizeGradient: Nullable<FactorGradient>;
  15522. /** @hidden */
  15523. _currentSize1: number;
  15524. /** @hidden */
  15525. _currentSize2: number;
  15526. /** @hidden */
  15527. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15528. /** @hidden */
  15529. _currentAngularSpeed1: number;
  15530. /** @hidden */
  15531. _currentAngularSpeed2: number;
  15532. /** @hidden */
  15533. _currentVelocityGradient: Nullable<FactorGradient>;
  15534. /** @hidden */
  15535. _currentVelocity1: number;
  15536. /** @hidden */
  15537. _currentVelocity2: number;
  15538. /** @hidden */
  15539. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15540. /** @hidden */
  15541. _currentLimitVelocity1: number;
  15542. /** @hidden */
  15543. _currentLimitVelocity2: number;
  15544. /** @hidden */
  15545. _currentDragGradient: Nullable<FactorGradient>;
  15546. /** @hidden */
  15547. _currentDrag1: number;
  15548. /** @hidden */
  15549. _currentDrag2: number;
  15550. /** @hidden */
  15551. _randomNoiseCoordinates1: Vector3;
  15552. /** @hidden */
  15553. _randomNoiseCoordinates2: Vector3;
  15554. /**
  15555. * Creates a new instance Particle
  15556. * @param particleSystem the particle system the particle belongs to
  15557. */
  15558. constructor(
  15559. /**
  15560. * The particle system the particle belongs to.
  15561. */
  15562. particleSystem: ParticleSystem);
  15563. private updateCellInfoFromSystem;
  15564. /**
  15565. * Defines how the sprite cell index is updated for the particle
  15566. */
  15567. updateCellIndex(): void;
  15568. /** @hidden */
  15569. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15570. /** @hidden */
  15571. _inheritParticleInfoToSubEmitters(): void;
  15572. /** @hidden */
  15573. _reset(): void;
  15574. /**
  15575. * Copy the properties of particle to another one.
  15576. * @param other the particle to copy the information to.
  15577. */
  15578. copyTo(other: Particle): void;
  15579. }
  15580. }
  15581. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15582. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15583. import { Effect } from "babylonjs/Materials/effect";
  15584. import { Particle } from "babylonjs/Particles/particle";
  15585. /**
  15586. * Particle emitter represents a volume emitting particles.
  15587. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15588. */
  15589. export interface IParticleEmitterType {
  15590. /**
  15591. * Called by the particle System when the direction is computed for the created particle.
  15592. * @param worldMatrix is the world matrix of the particle system
  15593. * @param directionToUpdate is the direction vector to update with the result
  15594. * @param particle is the particle we are computed the direction for
  15595. */
  15596. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15597. /**
  15598. * Called by the particle System when the position is computed for the created particle.
  15599. * @param worldMatrix is the world matrix of the particle system
  15600. * @param positionToUpdate is the position vector to update with the result
  15601. * @param particle is the particle we are computed the position for
  15602. */
  15603. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15604. /**
  15605. * Clones the current emitter and returns a copy of it
  15606. * @returns the new emitter
  15607. */
  15608. clone(): IParticleEmitterType;
  15609. /**
  15610. * Called by the GPUParticleSystem to setup the update shader
  15611. * @param effect defines the update shader
  15612. */
  15613. applyToShader(effect: Effect): void;
  15614. /**
  15615. * Returns a string to use to update the GPU particles update shader
  15616. * @returns the effect defines string
  15617. */
  15618. getEffectDefines(): string;
  15619. /**
  15620. * Returns a string representing the class name
  15621. * @returns a string containing the class name
  15622. */
  15623. getClassName(): string;
  15624. /**
  15625. * Serializes the particle system to a JSON object.
  15626. * @returns the JSON object
  15627. */
  15628. serialize(): any;
  15629. /**
  15630. * Parse properties from a JSON object
  15631. * @param serializationObject defines the JSON object
  15632. */
  15633. parse(serializationObject: any): void;
  15634. }
  15635. }
  15636. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15637. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15638. import { Effect } from "babylonjs/Materials/effect";
  15639. import { Particle } from "babylonjs/Particles/particle";
  15640. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15641. /**
  15642. * Particle emitter emitting particles from the inside of a box.
  15643. * It emits the particles randomly between 2 given directions.
  15644. */
  15645. export class BoxParticleEmitter implements IParticleEmitterType {
  15646. /**
  15647. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15648. */
  15649. direction1: Vector3;
  15650. /**
  15651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15652. */
  15653. direction2: Vector3;
  15654. /**
  15655. * 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.
  15656. */
  15657. minEmitBox: Vector3;
  15658. /**
  15659. * 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.
  15660. */
  15661. maxEmitBox: Vector3;
  15662. /**
  15663. * Creates a new instance BoxParticleEmitter
  15664. */
  15665. constructor();
  15666. /**
  15667. * Called by the particle System when the direction is computed for the created particle.
  15668. * @param worldMatrix is the world matrix of the particle system
  15669. * @param directionToUpdate is the direction vector to update with the result
  15670. * @param particle is the particle we are computed the direction for
  15671. */
  15672. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15673. /**
  15674. * Called by the particle System when the position is computed for the created particle.
  15675. * @param worldMatrix is the world matrix of the particle system
  15676. * @param positionToUpdate is the position vector to update with the result
  15677. * @param particle is the particle we are computed the position for
  15678. */
  15679. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15680. /**
  15681. * Clones the current emitter and returns a copy of it
  15682. * @returns the new emitter
  15683. */
  15684. clone(): BoxParticleEmitter;
  15685. /**
  15686. * Called by the GPUParticleSystem to setup the update shader
  15687. * @param effect defines the update shader
  15688. */
  15689. applyToShader(effect: Effect): void;
  15690. /**
  15691. * Returns a string to use to update the GPU particles update shader
  15692. * @returns a string containng the defines string
  15693. */
  15694. getEffectDefines(): string;
  15695. /**
  15696. * Returns the string "BoxParticleEmitter"
  15697. * @returns a string containing the class name
  15698. */
  15699. getClassName(): string;
  15700. /**
  15701. * Serializes the particle system to a JSON object.
  15702. * @returns the JSON object
  15703. */
  15704. serialize(): any;
  15705. /**
  15706. * Parse properties from a JSON object
  15707. * @param serializationObject defines the JSON object
  15708. */
  15709. parse(serializationObject: any): void;
  15710. }
  15711. }
  15712. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15713. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15714. import { Effect } from "babylonjs/Materials/effect";
  15715. import { Particle } from "babylonjs/Particles/particle";
  15716. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15717. /**
  15718. * Particle emitter emitting particles from the inside of a cone.
  15719. * It emits the particles alongside the cone volume from the base to the particle.
  15720. * The emission direction might be randomized.
  15721. */
  15722. export class ConeParticleEmitter implements IParticleEmitterType {
  15723. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15724. directionRandomizer: number;
  15725. private _radius;
  15726. private _angle;
  15727. private _height;
  15728. /**
  15729. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15730. */
  15731. radiusRange: number;
  15732. /**
  15733. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15734. */
  15735. heightRange: number;
  15736. /**
  15737. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15738. */
  15739. emitFromSpawnPointOnly: boolean;
  15740. /**
  15741. * Gets or sets the radius of the emission cone
  15742. */
  15743. radius: number;
  15744. /**
  15745. * Gets or sets the angle of the emission cone
  15746. */
  15747. angle: number;
  15748. private _buildHeight;
  15749. /**
  15750. * Creates a new instance ConeParticleEmitter
  15751. * @param radius the radius of the emission cone (1 by default)
  15752. * @param angle the cone base angle (PI by default)
  15753. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15754. */
  15755. constructor(radius?: number, angle?: number,
  15756. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15757. directionRandomizer?: number);
  15758. /**
  15759. * Called by the particle System when the direction is computed for the created particle.
  15760. * @param worldMatrix is the world matrix of the particle system
  15761. * @param directionToUpdate is the direction vector to update with the result
  15762. * @param particle is the particle we are computed the direction for
  15763. */
  15764. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15765. /**
  15766. * Called by the particle System when the position is computed for the created particle.
  15767. * @param worldMatrix is the world matrix of the particle system
  15768. * @param positionToUpdate is the position vector to update with the result
  15769. * @param particle is the particle we are computed the position for
  15770. */
  15771. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15772. /**
  15773. * Clones the current emitter and returns a copy of it
  15774. * @returns the new emitter
  15775. */
  15776. clone(): ConeParticleEmitter;
  15777. /**
  15778. * Called by the GPUParticleSystem to setup the update shader
  15779. * @param effect defines the update shader
  15780. */
  15781. applyToShader(effect: Effect): void;
  15782. /**
  15783. * Returns a string to use to update the GPU particles update shader
  15784. * @returns a string containng the defines string
  15785. */
  15786. getEffectDefines(): string;
  15787. /**
  15788. * Returns the string "ConeParticleEmitter"
  15789. * @returns a string containing the class name
  15790. */
  15791. getClassName(): string;
  15792. /**
  15793. * Serializes the particle system to a JSON object.
  15794. * @returns the JSON object
  15795. */
  15796. serialize(): any;
  15797. /**
  15798. * Parse properties from a JSON object
  15799. * @param serializationObject defines the JSON object
  15800. */
  15801. parse(serializationObject: any): void;
  15802. }
  15803. }
  15804. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15805. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15806. import { Effect } from "babylonjs/Materials/effect";
  15807. import { Particle } from "babylonjs/Particles/particle";
  15808. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15809. /**
  15810. * Particle emitter emitting particles from the inside of a cylinder.
  15811. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15812. */
  15813. export class CylinderParticleEmitter implements IParticleEmitterType {
  15814. /**
  15815. * The radius of the emission cylinder.
  15816. */
  15817. radius: number;
  15818. /**
  15819. * The height of the emission cylinder.
  15820. */
  15821. height: number;
  15822. /**
  15823. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15824. */
  15825. radiusRange: number;
  15826. /**
  15827. * How much to randomize the particle direction [0-1].
  15828. */
  15829. directionRandomizer: number;
  15830. /**
  15831. * Creates a new instance CylinderParticleEmitter
  15832. * @param radius the radius of the emission cylinder (1 by default)
  15833. * @param height the height of the emission cylinder (1 by default)
  15834. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15835. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15836. */
  15837. constructor(
  15838. /**
  15839. * The radius of the emission cylinder.
  15840. */
  15841. radius?: number,
  15842. /**
  15843. * The height of the emission cylinder.
  15844. */
  15845. height?: number,
  15846. /**
  15847. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15848. */
  15849. radiusRange?: number,
  15850. /**
  15851. * How much to randomize the particle direction [0-1].
  15852. */
  15853. directionRandomizer?: number);
  15854. /**
  15855. * Called by the particle System when the direction is computed for the created particle.
  15856. * @param worldMatrix is the world matrix of the particle system
  15857. * @param directionToUpdate is the direction vector to update with the result
  15858. * @param particle is the particle we are computed the direction for
  15859. */
  15860. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15861. /**
  15862. * Called by the particle System when the position is computed for the created particle.
  15863. * @param worldMatrix is the world matrix of the particle system
  15864. * @param positionToUpdate is the position vector to update with the result
  15865. * @param particle is the particle we are computed the position for
  15866. */
  15867. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15868. /**
  15869. * Clones the current emitter and returns a copy of it
  15870. * @returns the new emitter
  15871. */
  15872. clone(): CylinderParticleEmitter;
  15873. /**
  15874. * Called by the GPUParticleSystem to setup the update shader
  15875. * @param effect defines the update shader
  15876. */
  15877. applyToShader(effect: Effect): void;
  15878. /**
  15879. * Returns a string to use to update the GPU particles update shader
  15880. * @returns a string containng the defines string
  15881. */
  15882. getEffectDefines(): string;
  15883. /**
  15884. * Returns the string "CylinderParticleEmitter"
  15885. * @returns a string containing the class name
  15886. */
  15887. getClassName(): string;
  15888. /**
  15889. * Serializes the particle system to a JSON object.
  15890. * @returns the JSON object
  15891. */
  15892. serialize(): any;
  15893. /**
  15894. * Parse properties from a JSON object
  15895. * @param serializationObject defines the JSON object
  15896. */
  15897. parse(serializationObject: any): void;
  15898. }
  15899. /**
  15900. * Particle emitter emitting particles from the inside of a cylinder.
  15901. * It emits the particles randomly between two vectors.
  15902. */
  15903. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15904. /**
  15905. * The min limit of the emission direction.
  15906. */
  15907. direction1: Vector3;
  15908. /**
  15909. * The max limit of the emission direction.
  15910. */
  15911. direction2: Vector3;
  15912. /**
  15913. * Creates a new instance CylinderDirectedParticleEmitter
  15914. * @param radius the radius of the emission cylinder (1 by default)
  15915. * @param height the height of the emission cylinder (1 by default)
  15916. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15917. * @param direction1 the min limit of the emission direction (up vector by default)
  15918. * @param direction2 the max limit of the emission direction (up vector by default)
  15919. */
  15920. constructor(radius?: number, height?: number, radiusRange?: number,
  15921. /**
  15922. * The min limit of the emission direction.
  15923. */
  15924. direction1?: Vector3,
  15925. /**
  15926. * The max limit of the emission direction.
  15927. */
  15928. direction2?: Vector3);
  15929. /**
  15930. * Called by the particle System when the direction is computed for the created particle.
  15931. * @param worldMatrix is the world matrix of the particle system
  15932. * @param directionToUpdate is the direction vector to update with the result
  15933. * @param particle is the particle we are computed the direction for
  15934. */
  15935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15936. /**
  15937. * Clones the current emitter and returns a copy of it
  15938. * @returns the new emitter
  15939. */
  15940. clone(): CylinderDirectedParticleEmitter;
  15941. /**
  15942. * Called by the GPUParticleSystem to setup the update shader
  15943. * @param effect defines the update shader
  15944. */
  15945. applyToShader(effect: Effect): void;
  15946. /**
  15947. * Returns a string to use to update the GPU particles update shader
  15948. * @returns a string containng the defines string
  15949. */
  15950. getEffectDefines(): string;
  15951. /**
  15952. * Returns the string "CylinderDirectedParticleEmitter"
  15953. * @returns a string containing the class name
  15954. */
  15955. getClassName(): string;
  15956. /**
  15957. * Serializes the particle system to a JSON object.
  15958. * @returns the JSON object
  15959. */
  15960. serialize(): any;
  15961. /**
  15962. * Parse properties from a JSON object
  15963. * @param serializationObject defines the JSON object
  15964. */
  15965. parse(serializationObject: any): void;
  15966. }
  15967. }
  15968. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15969. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15970. import { Effect } from "babylonjs/Materials/effect";
  15971. import { Particle } from "babylonjs/Particles/particle";
  15972. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15973. /**
  15974. * Particle emitter emitting particles from the inside of a hemisphere.
  15975. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15976. */
  15977. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15978. /**
  15979. * The radius of the emission hemisphere.
  15980. */
  15981. radius: number;
  15982. /**
  15983. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15984. */
  15985. radiusRange: number;
  15986. /**
  15987. * How much to randomize the particle direction [0-1].
  15988. */
  15989. directionRandomizer: number;
  15990. /**
  15991. * Creates a new instance HemisphericParticleEmitter
  15992. * @param radius the radius of the emission hemisphere (1 by default)
  15993. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15994. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15995. */
  15996. constructor(
  15997. /**
  15998. * The radius of the emission hemisphere.
  15999. */
  16000. radius?: number,
  16001. /**
  16002. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16003. */
  16004. radiusRange?: number,
  16005. /**
  16006. * How much to randomize the particle direction [0-1].
  16007. */
  16008. directionRandomizer?: number);
  16009. /**
  16010. * Called by the particle System when the direction is computed for the created particle.
  16011. * @param worldMatrix is the world matrix of the particle system
  16012. * @param directionToUpdate is the direction vector to update with the result
  16013. * @param particle is the particle we are computed the direction for
  16014. */
  16015. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16016. /**
  16017. * Called by the particle System when the position is computed for the created particle.
  16018. * @param worldMatrix is the world matrix of the particle system
  16019. * @param positionToUpdate is the position vector to update with the result
  16020. * @param particle is the particle we are computed the position for
  16021. */
  16022. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16023. /**
  16024. * Clones the current emitter and returns a copy of it
  16025. * @returns the new emitter
  16026. */
  16027. clone(): HemisphericParticleEmitter;
  16028. /**
  16029. * Called by the GPUParticleSystem to setup the update shader
  16030. * @param effect defines the update shader
  16031. */
  16032. applyToShader(effect: Effect): void;
  16033. /**
  16034. * Returns a string to use to update the GPU particles update shader
  16035. * @returns a string containng the defines string
  16036. */
  16037. getEffectDefines(): string;
  16038. /**
  16039. * Returns the string "HemisphericParticleEmitter"
  16040. * @returns a string containing the class name
  16041. */
  16042. getClassName(): string;
  16043. /**
  16044. * Serializes the particle system to a JSON object.
  16045. * @returns the JSON object
  16046. */
  16047. serialize(): any;
  16048. /**
  16049. * Parse properties from a JSON object
  16050. * @param serializationObject defines the JSON object
  16051. */
  16052. parse(serializationObject: any): void;
  16053. }
  16054. }
  16055. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16056. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16057. import { Effect } from "babylonjs/Materials/effect";
  16058. import { Particle } from "babylonjs/Particles/particle";
  16059. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16060. /**
  16061. * Particle emitter emitting particles from a point.
  16062. * It emits the particles randomly between 2 given directions.
  16063. */
  16064. export class PointParticleEmitter implements IParticleEmitterType {
  16065. /**
  16066. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16067. */
  16068. direction1: Vector3;
  16069. /**
  16070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16071. */
  16072. direction2: Vector3;
  16073. /**
  16074. * Creates a new instance PointParticleEmitter
  16075. */
  16076. constructor();
  16077. /**
  16078. * Called by the particle System when the direction is computed for the created particle.
  16079. * @param worldMatrix is the world matrix of the particle system
  16080. * @param directionToUpdate is the direction vector to update with the result
  16081. * @param particle is the particle we are computed the direction for
  16082. */
  16083. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16084. /**
  16085. * Called by the particle System when the position is computed for the created particle.
  16086. * @param worldMatrix is the world matrix of the particle system
  16087. * @param positionToUpdate is the position vector to update with the result
  16088. * @param particle is the particle we are computed the position for
  16089. */
  16090. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16091. /**
  16092. * Clones the current emitter and returns a copy of it
  16093. * @returns the new emitter
  16094. */
  16095. clone(): PointParticleEmitter;
  16096. /**
  16097. * Called by the GPUParticleSystem to setup the update shader
  16098. * @param effect defines the update shader
  16099. */
  16100. applyToShader(effect: Effect): void;
  16101. /**
  16102. * Returns a string to use to update the GPU particles update shader
  16103. * @returns a string containng the defines string
  16104. */
  16105. getEffectDefines(): string;
  16106. /**
  16107. * Returns the string "PointParticleEmitter"
  16108. * @returns a string containing the class name
  16109. */
  16110. getClassName(): string;
  16111. /**
  16112. * Serializes the particle system to a JSON object.
  16113. * @returns the JSON object
  16114. */
  16115. serialize(): any;
  16116. /**
  16117. * Parse properties from a JSON object
  16118. * @param serializationObject defines the JSON object
  16119. */
  16120. parse(serializationObject: any): void;
  16121. }
  16122. }
  16123. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16124. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16125. import { Effect } from "babylonjs/Materials/effect";
  16126. import { Particle } from "babylonjs/Particles/particle";
  16127. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16128. /**
  16129. * Particle emitter emitting particles from the inside of a sphere.
  16130. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16131. */
  16132. export class SphereParticleEmitter implements IParticleEmitterType {
  16133. /**
  16134. * The radius of the emission sphere.
  16135. */
  16136. radius: number;
  16137. /**
  16138. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16139. */
  16140. radiusRange: number;
  16141. /**
  16142. * How much to randomize the particle direction [0-1].
  16143. */
  16144. directionRandomizer: number;
  16145. /**
  16146. * Creates a new instance SphereParticleEmitter
  16147. * @param radius the radius of the emission sphere (1 by default)
  16148. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16149. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16150. */
  16151. constructor(
  16152. /**
  16153. * The radius of the emission sphere.
  16154. */
  16155. radius?: number,
  16156. /**
  16157. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16158. */
  16159. radiusRange?: number,
  16160. /**
  16161. * How much to randomize the particle direction [0-1].
  16162. */
  16163. directionRandomizer?: number);
  16164. /**
  16165. * Called by the particle System when the direction is computed for the created particle.
  16166. * @param worldMatrix is the world matrix of the particle system
  16167. * @param directionToUpdate is the direction vector to update with the result
  16168. * @param particle is the particle we are computed the direction for
  16169. */
  16170. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16171. /**
  16172. * Called by the particle System when the position is computed for the created particle.
  16173. * @param worldMatrix is the world matrix of the particle system
  16174. * @param positionToUpdate is the position vector to update with the result
  16175. * @param particle is the particle we are computed the position for
  16176. */
  16177. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16178. /**
  16179. * Clones the current emitter and returns a copy of it
  16180. * @returns the new emitter
  16181. */
  16182. clone(): SphereParticleEmitter;
  16183. /**
  16184. * Called by the GPUParticleSystem to setup the update shader
  16185. * @param effect defines the update shader
  16186. */
  16187. applyToShader(effect: Effect): void;
  16188. /**
  16189. * Returns a string to use to update the GPU particles update shader
  16190. * @returns a string containng the defines string
  16191. */
  16192. getEffectDefines(): string;
  16193. /**
  16194. * Returns the string "SphereParticleEmitter"
  16195. * @returns a string containing the class name
  16196. */
  16197. getClassName(): string;
  16198. /**
  16199. * Serializes the particle system to a JSON object.
  16200. * @returns the JSON object
  16201. */
  16202. serialize(): any;
  16203. /**
  16204. * Parse properties from a JSON object
  16205. * @param serializationObject defines the JSON object
  16206. */
  16207. parse(serializationObject: any): void;
  16208. }
  16209. /**
  16210. * Particle emitter emitting particles from the inside of a sphere.
  16211. * It emits the particles randomly between two vectors.
  16212. */
  16213. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16214. /**
  16215. * The min limit of the emission direction.
  16216. */
  16217. direction1: Vector3;
  16218. /**
  16219. * The max limit of the emission direction.
  16220. */
  16221. direction2: Vector3;
  16222. /**
  16223. * Creates a new instance SphereDirectedParticleEmitter
  16224. * @param radius the radius of the emission sphere (1 by default)
  16225. * @param direction1 the min limit of the emission direction (up vector by default)
  16226. * @param direction2 the max limit of the emission direction (up vector by default)
  16227. */
  16228. constructor(radius?: number,
  16229. /**
  16230. * The min limit of the emission direction.
  16231. */
  16232. direction1?: Vector3,
  16233. /**
  16234. * The max limit of the emission direction.
  16235. */
  16236. direction2?: Vector3);
  16237. /**
  16238. * Called by the particle System when the direction is computed for the created particle.
  16239. * @param worldMatrix is the world matrix of the particle system
  16240. * @param directionToUpdate is the direction vector to update with the result
  16241. * @param particle is the particle we are computed the direction for
  16242. */
  16243. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16244. /**
  16245. * Clones the current emitter and returns a copy of it
  16246. * @returns the new emitter
  16247. */
  16248. clone(): SphereDirectedParticleEmitter;
  16249. /**
  16250. * Called by the GPUParticleSystem to setup the update shader
  16251. * @param effect defines the update shader
  16252. */
  16253. applyToShader(effect: Effect): void;
  16254. /**
  16255. * Returns a string to use to update the GPU particles update shader
  16256. * @returns a string containng the defines string
  16257. */
  16258. getEffectDefines(): string;
  16259. /**
  16260. * Returns the string "SphereDirectedParticleEmitter"
  16261. * @returns a string containing the class name
  16262. */
  16263. getClassName(): string;
  16264. /**
  16265. * Serializes the particle system to a JSON object.
  16266. * @returns the JSON object
  16267. */
  16268. serialize(): any;
  16269. /**
  16270. * Parse properties from a JSON object
  16271. * @param serializationObject defines the JSON object
  16272. */
  16273. parse(serializationObject: any): void;
  16274. }
  16275. }
  16276. declare module "babylonjs/Particles/EmitterTypes/index" {
  16277. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16278. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16279. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16280. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16281. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16282. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16283. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16284. }
  16285. declare module "babylonjs/Particles/IParticleSystem" {
  16286. import { Nullable } from "babylonjs/types";
  16287. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16289. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16290. import { Texture } from "babylonjs/Materials/Textures/texture";
  16291. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16292. import { Scene } from "babylonjs/scene";
  16293. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16294. import { Animation } from "babylonjs/Animations/animation";
  16295. /**
  16296. * Interface representing a particle system in Babylon.js.
  16297. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16298. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16299. */
  16300. export interface IParticleSystem {
  16301. /**
  16302. * List of animations used by the particle system.
  16303. */
  16304. animations: Animation[];
  16305. /**
  16306. * The id of the Particle system.
  16307. */
  16308. id: string;
  16309. /**
  16310. * The name of the Particle system.
  16311. */
  16312. name: string;
  16313. /**
  16314. * The emitter represents the Mesh or position we are attaching the particle system to.
  16315. */
  16316. emitter: Nullable<AbstractMesh | Vector3>;
  16317. /**
  16318. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16319. */
  16320. isBillboardBased: boolean;
  16321. /**
  16322. * The rendering group used by the Particle system to chose when to render.
  16323. */
  16324. renderingGroupId: number;
  16325. /**
  16326. * The layer mask we are rendering the particles through.
  16327. */
  16328. layerMask: number;
  16329. /**
  16330. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16331. */
  16332. updateSpeed: number;
  16333. /**
  16334. * The amount of time the particle system is running (depends of the overall update speed).
  16335. */
  16336. targetStopDuration: number;
  16337. /**
  16338. * The texture used to render each particle. (this can be a spritesheet)
  16339. */
  16340. particleTexture: Nullable<Texture>;
  16341. /**
  16342. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16343. */
  16344. blendMode: number;
  16345. /**
  16346. * Minimum life time of emitting particles.
  16347. */
  16348. minLifeTime: number;
  16349. /**
  16350. * Maximum life time of emitting particles.
  16351. */
  16352. maxLifeTime: number;
  16353. /**
  16354. * Minimum Size of emitting particles.
  16355. */
  16356. minSize: number;
  16357. /**
  16358. * Maximum Size of emitting particles.
  16359. */
  16360. maxSize: number;
  16361. /**
  16362. * Minimum scale of emitting particles on X axis.
  16363. */
  16364. minScaleX: number;
  16365. /**
  16366. * Maximum scale of emitting particles on X axis.
  16367. */
  16368. maxScaleX: number;
  16369. /**
  16370. * Minimum scale of emitting particles on Y axis.
  16371. */
  16372. minScaleY: number;
  16373. /**
  16374. * Maximum scale of emitting particles on Y axis.
  16375. */
  16376. maxScaleY: number;
  16377. /**
  16378. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16379. */
  16380. color1: Color4;
  16381. /**
  16382. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16383. */
  16384. color2: Color4;
  16385. /**
  16386. * Color the particle will have at the end of its lifetime.
  16387. */
  16388. colorDead: Color4;
  16389. /**
  16390. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16391. */
  16392. emitRate: number;
  16393. /**
  16394. * You can use gravity if you want to give an orientation to your particles.
  16395. */
  16396. gravity: Vector3;
  16397. /**
  16398. * Minimum power of emitting particles.
  16399. */
  16400. minEmitPower: number;
  16401. /**
  16402. * Maximum power of emitting particles.
  16403. */
  16404. maxEmitPower: number;
  16405. /**
  16406. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16407. */
  16408. minAngularSpeed: number;
  16409. /**
  16410. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16411. */
  16412. maxAngularSpeed: number;
  16413. /**
  16414. * Gets or sets the minimal initial rotation in radians.
  16415. */
  16416. minInitialRotation: number;
  16417. /**
  16418. * Gets or sets the maximal initial rotation in radians.
  16419. */
  16420. maxInitialRotation: number;
  16421. /**
  16422. * The particle emitter type defines the emitter used by the particle system.
  16423. * It can be for example box, sphere, or cone...
  16424. */
  16425. particleEmitterType: Nullable<IParticleEmitterType>;
  16426. /**
  16427. * Defines the delay in milliseconds before starting the system (0 by default)
  16428. */
  16429. startDelay: number;
  16430. /**
  16431. * 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
  16432. */
  16433. preWarmCycles: number;
  16434. /**
  16435. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16436. */
  16437. preWarmStepOffset: number;
  16438. /**
  16439. * 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)
  16440. */
  16441. spriteCellChangeSpeed: number;
  16442. /**
  16443. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16444. */
  16445. startSpriteCellID: number;
  16446. /**
  16447. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16448. */
  16449. endSpriteCellID: number;
  16450. /**
  16451. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16452. */
  16453. spriteCellWidth: number;
  16454. /**
  16455. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16456. */
  16457. spriteCellHeight: number;
  16458. /**
  16459. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16460. */
  16461. spriteRandomStartCell: boolean;
  16462. /**
  16463. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16464. */
  16465. isAnimationSheetEnabled: boolean;
  16466. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16467. translationPivot: Vector2;
  16468. /**
  16469. * Gets or sets a texture used to add random noise to particle positions
  16470. */
  16471. noiseTexture: Nullable<BaseTexture>;
  16472. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16473. noiseStrength: Vector3;
  16474. /**
  16475. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16476. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16477. */
  16478. billboardMode: number;
  16479. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16480. limitVelocityDamping: number;
  16481. /**
  16482. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16483. */
  16484. beginAnimationOnStart: boolean;
  16485. /**
  16486. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16487. */
  16488. beginAnimationFrom: number;
  16489. /**
  16490. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16491. */
  16492. beginAnimationTo: number;
  16493. /**
  16494. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16495. */
  16496. beginAnimationLoop: boolean;
  16497. /**
  16498. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16499. */
  16500. disposeOnStop: boolean;
  16501. /**
  16502. * Gets the maximum number of particles active at the same time.
  16503. * @returns The max number of active particles.
  16504. */
  16505. getCapacity(): number;
  16506. /**
  16507. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16508. * @returns True if it has been started, otherwise false.
  16509. */
  16510. isStarted(): boolean;
  16511. /**
  16512. * Animates the particle system for this frame.
  16513. */
  16514. animate(): void;
  16515. /**
  16516. * Renders the particle system in its current state.
  16517. * @returns the current number of particles
  16518. */
  16519. render(): number;
  16520. /**
  16521. * Dispose the particle system and frees its associated resources.
  16522. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16523. */
  16524. dispose(disposeTexture?: boolean): void;
  16525. /**
  16526. * Clones the particle system.
  16527. * @param name The name of the cloned object
  16528. * @param newEmitter The new emitter to use
  16529. * @returns the cloned particle system
  16530. */
  16531. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16532. /**
  16533. * Serializes the particle system to a JSON object.
  16534. * @returns the JSON object
  16535. */
  16536. serialize(): any;
  16537. /**
  16538. * Rebuild the particle system
  16539. */
  16540. rebuild(): void;
  16541. /**
  16542. * Starts the particle system and begins to emit
  16543. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16544. */
  16545. start(delay?: number): void;
  16546. /**
  16547. * Stops the particle system.
  16548. */
  16549. stop(): void;
  16550. /**
  16551. * Remove all active particles
  16552. */
  16553. reset(): void;
  16554. /**
  16555. * Is this system ready to be used/rendered
  16556. * @return true if the system is ready
  16557. */
  16558. isReady(): boolean;
  16559. /**
  16560. * Adds a new color gradient
  16561. * @param gradient defines the gradient to use (between 0 and 1)
  16562. * @param color1 defines the color to affect to the specified gradient
  16563. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16564. * @returns the current particle system
  16565. */
  16566. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16567. /**
  16568. * Remove a specific color gradient
  16569. * @param gradient defines the gradient to remove
  16570. * @returns the current particle system
  16571. */
  16572. removeColorGradient(gradient: number): IParticleSystem;
  16573. /**
  16574. * Adds a new size gradient
  16575. * @param gradient defines the gradient to use (between 0 and 1)
  16576. * @param factor defines the size factor to affect to the specified gradient
  16577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16578. * @returns the current particle system
  16579. */
  16580. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16581. /**
  16582. * Remove a specific size gradient
  16583. * @param gradient defines the gradient to remove
  16584. * @returns the current particle system
  16585. */
  16586. removeSizeGradient(gradient: number): IParticleSystem;
  16587. /**
  16588. * Gets the current list of color gradients.
  16589. * You must use addColorGradient and removeColorGradient to udpate this list
  16590. * @returns the list of color gradients
  16591. */
  16592. getColorGradients(): Nullable<Array<ColorGradient>>;
  16593. /**
  16594. * Gets the current list of size gradients.
  16595. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16596. * @returns the list of size gradients
  16597. */
  16598. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16599. /**
  16600. * Gets the current list of angular speed gradients.
  16601. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16602. * @returns the list of angular speed gradients
  16603. */
  16604. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16605. /**
  16606. * Adds a new angular speed gradient
  16607. * @param gradient defines the gradient to use (between 0 and 1)
  16608. * @param factor defines the angular speed to affect to the specified gradient
  16609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16610. * @returns the current particle system
  16611. */
  16612. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16613. /**
  16614. * Remove a specific angular speed gradient
  16615. * @param gradient defines the gradient to remove
  16616. * @returns the current particle system
  16617. */
  16618. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16619. /**
  16620. * Gets the current list of velocity gradients.
  16621. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16622. * @returns the list of velocity gradients
  16623. */
  16624. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16625. /**
  16626. * Adds a new velocity gradient
  16627. * @param gradient defines the gradient to use (between 0 and 1)
  16628. * @param factor defines the velocity to affect to the specified gradient
  16629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16630. * @returns the current particle system
  16631. */
  16632. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16633. /**
  16634. * Remove a specific velocity gradient
  16635. * @param gradient defines the gradient to remove
  16636. * @returns the current particle system
  16637. */
  16638. removeVelocityGradient(gradient: number): IParticleSystem;
  16639. /**
  16640. * Gets the current list of limit velocity gradients.
  16641. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16642. * @returns the list of limit velocity gradients
  16643. */
  16644. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16645. /**
  16646. * Adds a new limit velocity gradient
  16647. * @param gradient defines the gradient to use (between 0 and 1)
  16648. * @param factor defines the limit velocity to affect to the specified gradient
  16649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16650. * @returns the current particle system
  16651. */
  16652. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16653. /**
  16654. * Remove a specific limit velocity gradient
  16655. * @param gradient defines the gradient to remove
  16656. * @returns the current particle system
  16657. */
  16658. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16659. /**
  16660. * Adds a new drag gradient
  16661. * @param gradient defines the gradient to use (between 0 and 1)
  16662. * @param factor defines the drag to affect to the specified gradient
  16663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16664. * @returns the current particle system
  16665. */
  16666. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16667. /**
  16668. * Remove a specific drag gradient
  16669. * @param gradient defines the gradient to remove
  16670. * @returns the current particle system
  16671. */
  16672. removeDragGradient(gradient: number): IParticleSystem;
  16673. /**
  16674. * Gets the current list of drag gradients.
  16675. * You must use addDragGradient and removeDragGradient to udpate this list
  16676. * @returns the list of drag gradients
  16677. */
  16678. getDragGradients(): Nullable<Array<FactorGradient>>;
  16679. /**
  16680. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16681. * @param gradient defines the gradient to use (between 0 and 1)
  16682. * @param factor defines the emit rate to affect to the specified gradient
  16683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16684. * @returns the current particle system
  16685. */
  16686. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16687. /**
  16688. * Remove a specific emit rate gradient
  16689. * @param gradient defines the gradient to remove
  16690. * @returns the current particle system
  16691. */
  16692. removeEmitRateGradient(gradient: number): IParticleSystem;
  16693. /**
  16694. * Gets the current list of emit rate gradients.
  16695. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16696. * @returns the list of emit rate gradients
  16697. */
  16698. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16699. /**
  16700. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16701. * @param gradient defines the gradient to use (between 0 and 1)
  16702. * @param factor defines the start size to affect to the specified gradient
  16703. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16704. * @returns the current particle system
  16705. */
  16706. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16707. /**
  16708. * Remove a specific start size gradient
  16709. * @param gradient defines the gradient to remove
  16710. * @returns the current particle system
  16711. */
  16712. removeStartSizeGradient(gradient: number): IParticleSystem;
  16713. /**
  16714. * Gets the current list of start size gradients.
  16715. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16716. * @returns the list of start size gradients
  16717. */
  16718. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16719. /**
  16720. * Adds a new life time gradient
  16721. * @param gradient defines the gradient to use (between 0 and 1)
  16722. * @param factor defines the life time factor to affect to the specified gradient
  16723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16724. * @returns the current particle system
  16725. */
  16726. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16727. /**
  16728. * Remove a specific life time gradient
  16729. * @param gradient defines the gradient to remove
  16730. * @returns the current particle system
  16731. */
  16732. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16733. /**
  16734. * Gets the current list of life time gradients.
  16735. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16736. * @returns the list of life time gradients
  16737. */
  16738. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16739. /**
  16740. * Gets the current list of color gradients.
  16741. * You must use addColorGradient and removeColorGradient to udpate this list
  16742. * @returns the list of color gradients
  16743. */
  16744. getColorGradients(): Nullable<Array<ColorGradient>>;
  16745. /**
  16746. * Adds a new ramp gradient used to remap particle colors
  16747. * @param gradient defines the gradient to use (between 0 and 1)
  16748. * @param color defines the color to affect to the specified gradient
  16749. * @returns the current particle system
  16750. */
  16751. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16752. /**
  16753. * Gets the current list of ramp gradients.
  16754. * You must use addRampGradient and removeRampGradient to udpate this list
  16755. * @returns the list of ramp gradients
  16756. */
  16757. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16758. /** Gets or sets a boolean indicating that ramp gradients must be used
  16759. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16760. */
  16761. useRampGradients: boolean;
  16762. /**
  16763. * Adds a new color remap gradient
  16764. * @param gradient defines the gradient to use (between 0 and 1)
  16765. * @param min defines the color remap minimal range
  16766. * @param max defines the color remap maximal range
  16767. * @returns the current particle system
  16768. */
  16769. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16770. /**
  16771. * Gets the current list of color remap gradients.
  16772. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16773. * @returns the list of color remap gradients
  16774. */
  16775. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16776. /**
  16777. * Adds a new alpha remap gradient
  16778. * @param gradient defines the gradient to use (between 0 and 1)
  16779. * @param min defines the alpha remap minimal range
  16780. * @param max defines the alpha remap maximal range
  16781. * @returns the current particle system
  16782. */
  16783. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16784. /**
  16785. * Gets the current list of alpha remap gradients.
  16786. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16787. * @returns the list of alpha remap gradients
  16788. */
  16789. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16790. /**
  16791. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16792. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16793. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16794. * @returns the emitter
  16795. */
  16796. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16797. /**
  16798. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16799. * @param radius The radius of the hemisphere to emit from
  16800. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16801. * @returns the emitter
  16802. */
  16803. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16804. /**
  16805. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16806. * @param radius The radius of the sphere to emit from
  16807. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16808. * @returns the emitter
  16809. */
  16810. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16811. /**
  16812. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16813. * @param radius The radius of the sphere to emit from
  16814. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16815. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16816. * @returns the emitter
  16817. */
  16818. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16819. /**
  16820. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16821. * @param radius The radius of the emission cylinder
  16822. * @param height The height of the emission cylinder
  16823. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16824. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16825. * @returns the emitter
  16826. */
  16827. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16828. /**
  16829. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16830. * @param radius The radius of the cylinder to emit from
  16831. * @param height The height of the emission cylinder
  16832. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16833. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16834. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16835. * @returns the emitter
  16836. */
  16837. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16838. /**
  16839. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16840. * @param radius The radius of the cone to emit from
  16841. * @param angle The base angle of the cone
  16842. * @returns the emitter
  16843. */
  16844. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16845. /**
  16846. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16847. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16848. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16849. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16850. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16851. * @returns the emitter
  16852. */
  16853. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16854. /**
  16855. * Get hosting scene
  16856. * @returns the scene
  16857. */
  16858. getScene(): Scene;
  16859. }
  16860. }
  16861. declare module "babylonjs/Meshes/instancedMesh" {
  16862. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16863. import { Vector3 } from "babylonjs/Maths/math";
  16864. import { Camera } from "babylonjs/Cameras/camera";
  16865. import { Node } from "babylonjs/node";
  16866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16867. import { Mesh } from "babylonjs/Meshes/mesh";
  16868. import { Material } from "babylonjs/Materials/material";
  16869. import { Skeleton } from "babylonjs/Bones/skeleton";
  16870. /**
  16871. * Creates an instance based on a source mesh.
  16872. */
  16873. export class InstancedMesh extends AbstractMesh {
  16874. private _sourceMesh;
  16875. private _currentLOD;
  16876. /** @hidden */
  16877. _indexInSourceMeshInstanceArray: number;
  16878. constructor(name: string, source: Mesh);
  16879. /**
  16880. * Returns the string "InstancedMesh".
  16881. */
  16882. getClassName(): string;
  16883. /**
  16884. * If the source mesh receives shadows
  16885. */
  16886. readonly receiveShadows: boolean;
  16887. /**
  16888. * The material of the source mesh
  16889. */
  16890. readonly material: Nullable<Material>;
  16891. /**
  16892. * Visibility of the source mesh
  16893. */
  16894. readonly visibility: number;
  16895. /**
  16896. * Skeleton of the source mesh
  16897. */
  16898. readonly skeleton: Nullable<Skeleton>;
  16899. /**
  16900. * Rendering ground id of the source mesh
  16901. */
  16902. renderingGroupId: number;
  16903. /**
  16904. * Returns the total number of vertices (integer).
  16905. */
  16906. getTotalVertices(): number;
  16907. /**
  16908. * Returns a positive integer : the total number of indices in this mesh geometry.
  16909. * @returns the numner of indices or zero if the mesh has no geometry.
  16910. */
  16911. getTotalIndices(): number;
  16912. /**
  16913. * The source mesh of the instance
  16914. */
  16915. readonly sourceMesh: Mesh;
  16916. /**
  16917. * Is this node ready to be used/rendered
  16918. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16919. * @return {boolean} is it ready
  16920. */
  16921. isReady(completeCheck?: boolean): boolean;
  16922. /**
  16923. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16924. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16925. * @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.
  16926. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16927. */
  16928. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16929. /**
  16930. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16931. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16932. * The `data` are either a numeric array either a Float32Array.
  16933. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16934. * 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).
  16935. * Note that a new underlying VertexBuffer object is created each call.
  16936. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16937. *
  16938. * Possible `kind` values :
  16939. * - VertexBuffer.PositionKind
  16940. * - VertexBuffer.UVKind
  16941. * - VertexBuffer.UV2Kind
  16942. * - VertexBuffer.UV3Kind
  16943. * - VertexBuffer.UV4Kind
  16944. * - VertexBuffer.UV5Kind
  16945. * - VertexBuffer.UV6Kind
  16946. * - VertexBuffer.ColorKind
  16947. * - VertexBuffer.MatricesIndicesKind
  16948. * - VertexBuffer.MatricesIndicesExtraKind
  16949. * - VertexBuffer.MatricesWeightsKind
  16950. * - VertexBuffer.MatricesWeightsExtraKind
  16951. *
  16952. * Returns the Mesh.
  16953. */
  16954. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16955. /**
  16956. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16957. * If the mesh has no geometry, it is simply returned as it is.
  16958. * The `data` are either a numeric array either a Float32Array.
  16959. * No new underlying VertexBuffer object is created.
  16960. * 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.
  16961. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16962. *
  16963. * Possible `kind` values :
  16964. * - VertexBuffer.PositionKind
  16965. * - VertexBuffer.UVKind
  16966. * - VertexBuffer.UV2Kind
  16967. * - VertexBuffer.UV3Kind
  16968. * - VertexBuffer.UV4Kind
  16969. * - VertexBuffer.UV5Kind
  16970. * - VertexBuffer.UV6Kind
  16971. * - VertexBuffer.ColorKind
  16972. * - VertexBuffer.MatricesIndicesKind
  16973. * - VertexBuffer.MatricesIndicesExtraKind
  16974. * - VertexBuffer.MatricesWeightsKind
  16975. * - VertexBuffer.MatricesWeightsExtraKind
  16976. *
  16977. * Returns the Mesh.
  16978. */
  16979. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16980. /**
  16981. * Sets the mesh indices.
  16982. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16983. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16984. * This method creates a new index buffer each call.
  16985. * Returns the Mesh.
  16986. */
  16987. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16988. /**
  16989. * Boolean : True if the mesh owns the requested kind of data.
  16990. */
  16991. isVerticesDataPresent(kind: string): boolean;
  16992. /**
  16993. * Returns an array of indices (IndicesArray).
  16994. */
  16995. getIndices(): Nullable<IndicesArray>;
  16996. readonly _positions: Nullable<Vector3[]>;
  16997. /**
  16998. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16999. * This means the mesh underlying bounding box and sphere are recomputed.
  17000. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17001. * @returns the current mesh
  17002. */
  17003. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17004. /** @hidden */
  17005. _preActivate(): InstancedMesh;
  17006. /** @hidden */
  17007. _activate(renderId: number): boolean;
  17008. /**
  17009. * Returns the current associated LOD AbstractMesh.
  17010. */
  17011. getLOD(camera: Camera): AbstractMesh;
  17012. /** @hidden */
  17013. _syncSubMeshes(): InstancedMesh;
  17014. /** @hidden */
  17015. _generatePointsArray(): boolean;
  17016. /**
  17017. * Creates a new InstancedMesh from the current mesh.
  17018. * - name (string) : the cloned mesh name
  17019. * - newParent (optional Node) : the optional Node to parent the clone to.
  17020. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17021. *
  17022. * Returns the clone.
  17023. */
  17024. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17025. /**
  17026. * Disposes the InstancedMesh.
  17027. * Returns nothing.
  17028. */
  17029. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17030. }
  17031. }
  17032. declare module "babylonjs/Materials/shaderMaterial" {
  17033. import { Scene } from "babylonjs/scene";
  17034. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17036. import { Mesh } from "babylonjs/Meshes/mesh";
  17037. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17038. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17039. import { Texture } from "babylonjs/Materials/Textures/texture";
  17040. import { Material } from "babylonjs/Materials/material";
  17041. /**
  17042. * Defines the options associated with the creation of a shader material.
  17043. */
  17044. export interface IShaderMaterialOptions {
  17045. /**
  17046. * Does the material work in alpha blend mode
  17047. */
  17048. needAlphaBlending: boolean;
  17049. /**
  17050. * Does the material work in alpha test mode
  17051. */
  17052. needAlphaTesting: boolean;
  17053. /**
  17054. * The list of attribute names used in the shader
  17055. */
  17056. attributes: string[];
  17057. /**
  17058. * The list of unifrom names used in the shader
  17059. */
  17060. uniforms: string[];
  17061. /**
  17062. * The list of UBO names used in the shader
  17063. */
  17064. uniformBuffers: string[];
  17065. /**
  17066. * The list of sampler names used in the shader
  17067. */
  17068. samplers: string[];
  17069. /**
  17070. * The list of defines used in the shader
  17071. */
  17072. defines: string[];
  17073. }
  17074. /**
  17075. * 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.
  17076. *
  17077. * This returned material effects how the mesh will look based on the code in the shaders.
  17078. *
  17079. * @see http://doc.babylonjs.com/how_to/shader_material
  17080. */
  17081. export class ShaderMaterial extends Material {
  17082. private _shaderPath;
  17083. private _options;
  17084. private _textures;
  17085. private _textureArrays;
  17086. private _floats;
  17087. private _ints;
  17088. private _floatsArrays;
  17089. private _colors3;
  17090. private _colors3Arrays;
  17091. private _colors4;
  17092. private _vectors2;
  17093. private _vectors3;
  17094. private _vectors4;
  17095. private _matrices;
  17096. private _matrices3x3;
  17097. private _matrices2x2;
  17098. private _vectors2Arrays;
  17099. private _vectors3Arrays;
  17100. private _cachedWorldViewMatrix;
  17101. private _renderId;
  17102. /**
  17103. * Instantiate a new shader material.
  17104. * 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.
  17105. * This returned material effects how the mesh will look based on the code in the shaders.
  17106. * @see http://doc.babylonjs.com/how_to/shader_material
  17107. * @param name Define the name of the material in the scene
  17108. * @param scene Define the scene the material belongs to
  17109. * @param shaderPath Defines the route to the shader code in one of three ways:
  17110. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17111. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17112. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17113. * @param options Define the options used to create the shader
  17114. */
  17115. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17116. /**
  17117. * Gets the options used to compile the shader.
  17118. * They can be modified to trigger a new compilation
  17119. */
  17120. readonly options: IShaderMaterialOptions;
  17121. /**
  17122. * Gets the current class name of the material e.g. "ShaderMaterial"
  17123. * Mainly use in serialization.
  17124. * @returns the class name
  17125. */
  17126. getClassName(): string;
  17127. /**
  17128. * Specifies if the material will require alpha blending
  17129. * @returns a boolean specifying if alpha blending is needed
  17130. */
  17131. needAlphaBlending(): boolean;
  17132. /**
  17133. * Specifies if this material should be rendered in alpha test mode
  17134. * @returns a boolean specifying if an alpha test is needed.
  17135. */
  17136. needAlphaTesting(): boolean;
  17137. private _checkUniform;
  17138. /**
  17139. * Set a texture in the shader.
  17140. * @param name Define the name of the uniform samplers as defined in the shader
  17141. * @param texture Define the texture to bind to this sampler
  17142. * @return the material itself allowing "fluent" like uniform updates
  17143. */
  17144. setTexture(name: string, texture: Texture): ShaderMaterial;
  17145. /**
  17146. * Set a texture array in the shader.
  17147. * @param name Define the name of the uniform sampler array as defined in the shader
  17148. * @param textures Define the list of textures to bind to this sampler
  17149. * @return the material itself allowing "fluent" like uniform updates
  17150. */
  17151. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17152. /**
  17153. * Set a float in the shader.
  17154. * @param name Define the name of the uniform as defined in the shader
  17155. * @param value Define the value to give to the uniform
  17156. * @return the material itself allowing "fluent" like uniform updates
  17157. */
  17158. setFloat(name: string, value: number): ShaderMaterial;
  17159. /**
  17160. * Set a int in the shader.
  17161. * @param name Define the name of the uniform as defined in the shader
  17162. * @param value Define the value to give to the uniform
  17163. * @return the material itself allowing "fluent" like uniform updates
  17164. */
  17165. setInt(name: string, value: number): ShaderMaterial;
  17166. /**
  17167. * Set an array of floats in the shader.
  17168. * @param name Define the name of the uniform as defined in the shader
  17169. * @param value Define the value to give to the uniform
  17170. * @return the material itself allowing "fluent" like uniform updates
  17171. */
  17172. setFloats(name: string, value: number[]): ShaderMaterial;
  17173. /**
  17174. * Set a vec3 in the shader from a Color3.
  17175. * @param name Define the name of the uniform as defined in the shader
  17176. * @param value Define the value to give to the uniform
  17177. * @return the material itself allowing "fluent" like uniform updates
  17178. */
  17179. setColor3(name: string, value: Color3): ShaderMaterial;
  17180. /**
  17181. * Set a vec3 array in the shader from a Color3 array.
  17182. * @param name Define the name of the uniform as defined in the shader
  17183. * @param value Define the value to give to the uniform
  17184. * @return the material itself allowing "fluent" like uniform updates
  17185. */
  17186. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17187. /**
  17188. * Set a vec4 in the shader from a Color4.
  17189. * @param name Define the name of the uniform as defined in the shader
  17190. * @param value Define the value to give to the uniform
  17191. * @return the material itself allowing "fluent" like uniform updates
  17192. */
  17193. setColor4(name: string, value: Color4): ShaderMaterial;
  17194. /**
  17195. * Set a vec2 in the shader from a Vector2.
  17196. * @param name Define the name of the uniform as defined in the shader
  17197. * @param value Define the value to give to the uniform
  17198. * @return the material itself allowing "fluent" like uniform updates
  17199. */
  17200. setVector2(name: string, value: Vector2): ShaderMaterial;
  17201. /**
  17202. * Set a vec3 in the shader from a Vector3.
  17203. * @param name Define the name of the uniform as defined in the shader
  17204. * @param value Define the value to give to the uniform
  17205. * @return the material itself allowing "fluent" like uniform updates
  17206. */
  17207. setVector3(name: string, value: Vector3): ShaderMaterial;
  17208. /**
  17209. * Set a vec4 in the shader from a Vector4.
  17210. * @param name Define the name of the uniform as defined in the shader
  17211. * @param value Define the value to give to the uniform
  17212. * @return the material itself allowing "fluent" like uniform updates
  17213. */
  17214. setVector4(name: string, value: Vector4): ShaderMaterial;
  17215. /**
  17216. * Set a mat4 in the shader from a Matrix.
  17217. * @param name Define the name of the uniform as defined in the shader
  17218. * @param value Define the value to give to the uniform
  17219. * @return the material itself allowing "fluent" like uniform updates
  17220. */
  17221. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17222. /**
  17223. * Set a mat3 in the shader from a Float32Array.
  17224. * @param name Define the name of the uniform as defined in the shader
  17225. * @param value Define the value to give to the uniform
  17226. * @return the material itself allowing "fluent" like uniform updates
  17227. */
  17228. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17229. /**
  17230. * Set a mat2 in the shader from a Float32Array.
  17231. * @param name Define the name of the uniform as defined in the shader
  17232. * @param value Define the value to give to the uniform
  17233. * @return the material itself allowing "fluent" like uniform updates
  17234. */
  17235. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17236. /**
  17237. * Set a vec2 array in the shader from a number array.
  17238. * @param name Define the name of the uniform as defined in the shader
  17239. * @param value Define the value to give to the uniform
  17240. * @return the material itself allowing "fluent" like uniform updates
  17241. */
  17242. setArray2(name: string, value: number[]): ShaderMaterial;
  17243. /**
  17244. * Set a vec3 array in the shader from a number array.
  17245. * @param name Define the name of the uniform as defined in the shader
  17246. * @param value Define the value to give to the uniform
  17247. * @return the material itself allowing "fluent" like uniform updates
  17248. */
  17249. setArray3(name: string, value: number[]): ShaderMaterial;
  17250. private _checkCache;
  17251. /**
  17252. * Specifies that the submesh is ready to be used
  17253. * @param mesh defines the mesh to check
  17254. * @param subMesh defines which submesh to check
  17255. * @param useInstances specifies that instances should be used
  17256. * @returns a boolean indicating that the submesh is ready or not
  17257. */
  17258. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17259. /**
  17260. * Checks if the material is ready to render the requested mesh
  17261. * @param mesh Define the mesh to render
  17262. * @param useInstances Define whether or not the material is used with instances
  17263. * @returns true if ready, otherwise false
  17264. */
  17265. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17266. /**
  17267. * Binds the world matrix to the material
  17268. * @param world defines the world transformation matrix
  17269. */
  17270. bindOnlyWorldMatrix(world: Matrix): void;
  17271. /**
  17272. * Binds the material to the mesh
  17273. * @param world defines the world transformation matrix
  17274. * @param mesh defines the mesh to bind the material to
  17275. */
  17276. bind(world: Matrix, mesh?: Mesh): void;
  17277. /**
  17278. * Gets the active textures from the material
  17279. * @returns an array of textures
  17280. */
  17281. getActiveTextures(): BaseTexture[];
  17282. /**
  17283. * Specifies if the material uses a texture
  17284. * @param texture defines the texture to check against the material
  17285. * @returns a boolean specifying if the material uses the texture
  17286. */
  17287. hasTexture(texture: BaseTexture): boolean;
  17288. /**
  17289. * Makes a duplicate of the material, and gives it a new name
  17290. * @param name defines the new name for the duplicated material
  17291. * @returns the cloned material
  17292. */
  17293. clone(name: string): ShaderMaterial;
  17294. /**
  17295. * Disposes the material
  17296. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17297. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17298. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17299. */
  17300. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17301. /**
  17302. * Serializes this material in a JSON representation
  17303. * @returns the serialized material object
  17304. */
  17305. serialize(): any;
  17306. /**
  17307. * Creates a shader material from parsed shader material data
  17308. * @param source defines the JSON represnetation of the material
  17309. * @param scene defines the hosting scene
  17310. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17311. * @returns a new material
  17312. */
  17313. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17314. }
  17315. }
  17316. declare module "babylonjs/Shaders/color.fragment" {
  17317. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17318. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17319. /** @hidden */
  17320. export var colorPixelShader: {
  17321. name: string;
  17322. shader: string;
  17323. };
  17324. }
  17325. declare module "babylonjs/Shaders/color.vertex" {
  17326. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17327. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17328. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17329. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17330. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17331. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17332. /** @hidden */
  17333. export var colorVertexShader: {
  17334. name: string;
  17335. shader: string;
  17336. };
  17337. }
  17338. declare module "babylonjs/Meshes/linesMesh" {
  17339. import { Nullable } from "babylonjs/types";
  17340. import { Scene } from "babylonjs/scene";
  17341. import { Color3 } from "babylonjs/Maths/math";
  17342. import { Node } from "babylonjs/node";
  17343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17344. import { Mesh } from "babylonjs/Meshes/mesh";
  17345. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17346. import { Effect } from "babylonjs/Materials/effect";
  17347. import { Material } from "babylonjs/Materials/material";
  17348. import "babylonjs/Shaders/color.fragment";
  17349. import "babylonjs/Shaders/color.vertex";
  17350. /**
  17351. * Line mesh
  17352. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17353. */
  17354. export class LinesMesh extends Mesh {
  17355. /**
  17356. * If vertex color should be applied to the mesh
  17357. */
  17358. useVertexColor?: boolean | undefined;
  17359. /**
  17360. * If vertex alpha should be applied to the mesh
  17361. */
  17362. useVertexAlpha?: boolean | undefined;
  17363. /**
  17364. * Color of the line (Default: White)
  17365. */
  17366. color: Color3;
  17367. /**
  17368. * Alpha of the line (Default: 1)
  17369. */
  17370. alpha: number;
  17371. /**
  17372. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17373. * This margin is expressed in world space coordinates, so its value may vary.
  17374. * Default value is 0.1
  17375. */
  17376. intersectionThreshold: number;
  17377. private _colorShader;
  17378. /**
  17379. * Creates a new LinesMesh
  17380. * @param name defines the name
  17381. * @param scene defines the hosting scene
  17382. * @param parent defines the parent mesh if any
  17383. * @param source defines the optional source LinesMesh used to clone data from
  17384. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17385. * When false, achieved by calling a clone(), also passing False.
  17386. * This will make creation of children, recursive.
  17387. * @param useVertexColor defines if this LinesMesh supports vertex color
  17388. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17389. */
  17390. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17391. /**
  17392. * If vertex color should be applied to the mesh
  17393. */
  17394. useVertexColor?: boolean | undefined,
  17395. /**
  17396. * If vertex alpha should be applied to the mesh
  17397. */
  17398. useVertexAlpha?: boolean | undefined);
  17399. private _addClipPlaneDefine;
  17400. private _removeClipPlaneDefine;
  17401. isReady(): boolean;
  17402. /**
  17403. * Returns the string "LineMesh"
  17404. */
  17405. getClassName(): string;
  17406. /**
  17407. * @hidden
  17408. */
  17409. /**
  17410. * @hidden
  17411. */
  17412. material: Material;
  17413. /**
  17414. * @hidden
  17415. */
  17416. readonly checkCollisions: boolean;
  17417. /** @hidden */
  17418. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17419. /** @hidden */
  17420. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17421. /**
  17422. * Disposes of the line mesh
  17423. * @param doNotRecurse If children should be disposed
  17424. */
  17425. dispose(doNotRecurse?: boolean): void;
  17426. /**
  17427. * Returns a new LineMesh object cloned from the current one.
  17428. */
  17429. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17430. /**
  17431. * Creates a new InstancedLinesMesh object from the mesh model.
  17432. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17433. * @param name defines the name of the new instance
  17434. * @returns a new InstancedLinesMesh
  17435. */
  17436. createInstance(name: string): InstancedLinesMesh;
  17437. }
  17438. /**
  17439. * Creates an instance based on a source LinesMesh
  17440. */
  17441. export class InstancedLinesMesh extends InstancedMesh {
  17442. /**
  17443. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17444. * This margin is expressed in world space coordinates, so its value may vary.
  17445. * Initilized with the intersectionThreshold value of the source LinesMesh
  17446. */
  17447. intersectionThreshold: number;
  17448. constructor(name: string, source: LinesMesh);
  17449. /**
  17450. * Returns the string "InstancedLinesMesh".
  17451. */
  17452. getClassName(): string;
  17453. }
  17454. }
  17455. declare module "babylonjs/Shaders/line.fragment" {
  17456. /** @hidden */
  17457. export var linePixelShader: {
  17458. name: string;
  17459. shader: string;
  17460. };
  17461. }
  17462. declare module "babylonjs/Shaders/line.vertex" {
  17463. /** @hidden */
  17464. export var lineVertexShader: {
  17465. name: string;
  17466. shader: string;
  17467. };
  17468. }
  17469. declare module "babylonjs/Rendering/edgesRenderer" {
  17470. import { Nullable } from "babylonjs/types";
  17471. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17473. import { Vector3 } from "babylonjs/Maths/math";
  17474. import { IDisposable } from "babylonjs/scene";
  17475. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17476. import "babylonjs/Shaders/line.fragment";
  17477. import "babylonjs/Shaders/line.vertex";
  17478. module "babylonjs/Meshes/abstractMesh" {
  17479. interface AbstractMesh {
  17480. /**
  17481. * Disables the mesh edge rendering mode
  17482. * @returns the currentAbstractMesh
  17483. */
  17484. disableEdgesRendering(): AbstractMesh;
  17485. /**
  17486. * Enables the edge rendering mode on the mesh.
  17487. * This mode makes the mesh edges visible
  17488. * @param epsilon defines the maximal distance between two angles to detect a face
  17489. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17490. * @returns the currentAbstractMesh
  17491. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17492. */
  17493. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17494. /**
  17495. * Gets the edgesRenderer associated with the mesh
  17496. */
  17497. edgesRenderer: Nullable<EdgesRenderer>;
  17498. }
  17499. }
  17500. module "babylonjs/Meshes/linesMesh" {
  17501. interface LinesMesh {
  17502. /**
  17503. * Enables the edge rendering mode on the mesh.
  17504. * This mode makes the mesh edges visible
  17505. * @param epsilon defines the maximal distance between two angles to detect a face
  17506. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17507. * @returns the currentAbstractMesh
  17508. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17509. */
  17510. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17511. }
  17512. }
  17513. module "babylonjs/Meshes/linesMesh" {
  17514. interface InstancedLinesMesh {
  17515. /**
  17516. * Enables the edge rendering mode on the mesh.
  17517. * This mode makes the mesh edges visible
  17518. * @param epsilon defines the maximal distance between two angles to detect a face
  17519. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17520. * @returns the current InstancedLinesMesh
  17521. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17522. */
  17523. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17524. }
  17525. }
  17526. /**
  17527. * Defines the minimum contract an Edges renderer should follow.
  17528. */
  17529. export interface IEdgesRenderer extends IDisposable {
  17530. /**
  17531. * Gets or sets a boolean indicating if the edgesRenderer is active
  17532. */
  17533. isEnabled: boolean;
  17534. /**
  17535. * Renders the edges of the attached mesh,
  17536. */
  17537. render(): void;
  17538. /**
  17539. * Checks wether or not the edges renderer is ready to render.
  17540. * @return true if ready, otherwise false.
  17541. */
  17542. isReady(): boolean;
  17543. }
  17544. /**
  17545. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17546. */
  17547. export class EdgesRenderer implements IEdgesRenderer {
  17548. /**
  17549. * Define the size of the edges with an orthographic camera
  17550. */
  17551. edgesWidthScalerForOrthographic: number;
  17552. /**
  17553. * Define the size of the edges with a perspective camera
  17554. */
  17555. edgesWidthScalerForPerspective: number;
  17556. protected _source: AbstractMesh;
  17557. protected _linesPositions: number[];
  17558. protected _linesNormals: number[];
  17559. protected _linesIndices: number[];
  17560. protected _epsilon: number;
  17561. protected _indicesCount: number;
  17562. protected _lineShader: ShaderMaterial;
  17563. protected _ib: WebGLBuffer;
  17564. protected _buffers: {
  17565. [key: string]: Nullable<VertexBuffer>;
  17566. };
  17567. protected _checkVerticesInsteadOfIndices: boolean;
  17568. private _meshRebuildObserver;
  17569. private _meshDisposeObserver;
  17570. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17571. isEnabled: boolean;
  17572. /**
  17573. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17574. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17575. * @param source Mesh used to create edges
  17576. * @param epsilon sum of angles in adjacency to check for edge
  17577. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17578. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17579. */
  17580. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17581. protected _prepareRessources(): void;
  17582. /** @hidden */
  17583. _rebuild(): void;
  17584. /**
  17585. * Releases the required resources for the edges renderer
  17586. */
  17587. dispose(): void;
  17588. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17589. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17590. /**
  17591. * Checks if the pair of p0 and p1 is en edge
  17592. * @param faceIndex
  17593. * @param edge
  17594. * @param faceNormals
  17595. * @param p0
  17596. * @param p1
  17597. * @private
  17598. */
  17599. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17600. /**
  17601. * push line into the position, normal and index buffer
  17602. * @protected
  17603. */
  17604. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17605. /**
  17606. * Generates lines edges from adjacencjes
  17607. * @private
  17608. */
  17609. _generateEdgesLines(): void;
  17610. /**
  17611. * Checks wether or not the edges renderer is ready to render.
  17612. * @return true if ready, otherwise false.
  17613. */
  17614. isReady(): boolean;
  17615. /**
  17616. * Renders the edges of the attached mesh,
  17617. */
  17618. render(): void;
  17619. }
  17620. /**
  17621. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17622. */
  17623. export class LineEdgesRenderer extends EdgesRenderer {
  17624. /**
  17625. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17626. * @param source LineMesh used to generate edges
  17627. * @param epsilon not important (specified angle for edge detection)
  17628. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17629. */
  17630. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17631. /**
  17632. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17633. */
  17634. _generateEdgesLines(): void;
  17635. }
  17636. }
  17637. declare module "babylonjs/Rendering/renderingGroup" {
  17638. import { SmartArray } from "babylonjs/Misc/smartArray";
  17639. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17641. import { Nullable } from "babylonjs/types";
  17642. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17643. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17644. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17645. import { Material } from "babylonjs/Materials/material";
  17646. import { Scene } from "babylonjs/scene";
  17647. /**
  17648. * This represents the object necessary to create a rendering group.
  17649. * This is exclusively used and created by the rendering manager.
  17650. * To modify the behavior, you use the available helpers in your scene or meshes.
  17651. * @hidden
  17652. */
  17653. export class RenderingGroup {
  17654. index: number;
  17655. private _scene;
  17656. private _opaqueSubMeshes;
  17657. private _transparentSubMeshes;
  17658. private _alphaTestSubMeshes;
  17659. private _depthOnlySubMeshes;
  17660. private _particleSystems;
  17661. private _spriteManagers;
  17662. private _opaqueSortCompareFn;
  17663. private _alphaTestSortCompareFn;
  17664. private _transparentSortCompareFn;
  17665. private _renderOpaque;
  17666. private _renderAlphaTest;
  17667. private _renderTransparent;
  17668. /** @hidden */
  17669. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17670. onBeforeTransparentRendering: () => void;
  17671. /**
  17672. * Set the opaque sort comparison function.
  17673. * If null the sub meshes will be render in the order they were created
  17674. */
  17675. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17676. /**
  17677. * Set the alpha test sort comparison function.
  17678. * If null the sub meshes will be render in the order they were created
  17679. */
  17680. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17681. /**
  17682. * Set the transparent sort comparison function.
  17683. * If null the sub meshes will be render in the order they were created
  17684. */
  17685. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17686. /**
  17687. * Creates a new rendering group.
  17688. * @param index The rendering group index
  17689. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17690. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17691. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17692. */
  17693. 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>);
  17694. /**
  17695. * Render all the sub meshes contained in the group.
  17696. * @param customRenderFunction Used to override the default render behaviour of the group.
  17697. * @returns true if rendered some submeshes.
  17698. */
  17699. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17700. /**
  17701. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17702. * @param subMeshes The submeshes to render
  17703. */
  17704. private renderOpaqueSorted;
  17705. /**
  17706. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17707. * @param subMeshes The submeshes to render
  17708. */
  17709. private renderAlphaTestSorted;
  17710. /**
  17711. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17712. * @param subMeshes The submeshes to render
  17713. */
  17714. private renderTransparentSorted;
  17715. /**
  17716. * Renders the submeshes in a specified order.
  17717. * @param subMeshes The submeshes to sort before render
  17718. * @param sortCompareFn The comparison function use to sort
  17719. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17720. * @param transparent Specifies to activate blending if true
  17721. */
  17722. private static renderSorted;
  17723. /**
  17724. * Renders the submeshes in the order they were dispatched (no sort applied).
  17725. * @param subMeshes The submeshes to render
  17726. */
  17727. private static renderUnsorted;
  17728. /**
  17729. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17730. * are rendered back to front if in the same alpha index.
  17731. *
  17732. * @param a The first submesh
  17733. * @param b The second submesh
  17734. * @returns The result of the comparison
  17735. */
  17736. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17737. /**
  17738. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17739. * are rendered back to front.
  17740. *
  17741. * @param a The first submesh
  17742. * @param b The second submesh
  17743. * @returns The result of the comparison
  17744. */
  17745. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17746. /**
  17747. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17748. * are rendered front to back (prevent overdraw).
  17749. *
  17750. * @param a The first submesh
  17751. * @param b The second submesh
  17752. * @returns The result of the comparison
  17753. */
  17754. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17755. /**
  17756. * Resets the different lists of submeshes to prepare a new frame.
  17757. */
  17758. prepare(): void;
  17759. dispose(): void;
  17760. /**
  17761. * Inserts the submesh in its correct queue depending on its material.
  17762. * @param subMesh The submesh to dispatch
  17763. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17764. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17765. */
  17766. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17767. dispatchSprites(spriteManager: ISpriteManager): void;
  17768. dispatchParticles(particleSystem: IParticleSystem): void;
  17769. private _renderParticles;
  17770. private _renderSprites;
  17771. }
  17772. }
  17773. declare module "babylonjs/Rendering/renderingManager" {
  17774. import { Nullable } from "babylonjs/types";
  17775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17776. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17777. import { SmartArray } from "babylonjs/Misc/smartArray";
  17778. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17779. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17780. import { Material } from "babylonjs/Materials/material";
  17781. import { Scene } from "babylonjs/scene";
  17782. import { Camera } from "babylonjs/Cameras/camera";
  17783. /**
  17784. * Interface describing the different options available in the rendering manager
  17785. * regarding Auto Clear between groups.
  17786. */
  17787. export interface IRenderingManagerAutoClearSetup {
  17788. /**
  17789. * Defines whether or not autoclear is enable.
  17790. */
  17791. autoClear: boolean;
  17792. /**
  17793. * Defines whether or not to autoclear the depth buffer.
  17794. */
  17795. depth: boolean;
  17796. /**
  17797. * Defines whether or not to autoclear the stencil buffer.
  17798. */
  17799. stencil: boolean;
  17800. }
  17801. /**
  17802. * This class is used by the onRenderingGroupObservable
  17803. */
  17804. export class RenderingGroupInfo {
  17805. /**
  17806. * The Scene that being rendered
  17807. */
  17808. scene: Scene;
  17809. /**
  17810. * The camera currently used for the rendering pass
  17811. */
  17812. camera: Nullable<Camera>;
  17813. /**
  17814. * The ID of the renderingGroup being processed
  17815. */
  17816. renderingGroupId: number;
  17817. }
  17818. /**
  17819. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17820. * It is enable to manage the different groups as well as the different necessary sort functions.
  17821. * This should not be used directly aside of the few static configurations
  17822. */
  17823. export class RenderingManager {
  17824. /**
  17825. * The max id used for rendering groups (not included)
  17826. */
  17827. static MAX_RENDERINGGROUPS: number;
  17828. /**
  17829. * The min id used for rendering groups (included)
  17830. */
  17831. static MIN_RENDERINGGROUPS: number;
  17832. /**
  17833. * Used to globally prevent autoclearing scenes.
  17834. */
  17835. static AUTOCLEAR: boolean;
  17836. /**
  17837. * @hidden
  17838. */
  17839. _useSceneAutoClearSetup: boolean;
  17840. private _scene;
  17841. private _renderingGroups;
  17842. private _depthStencilBufferAlreadyCleaned;
  17843. private _autoClearDepthStencil;
  17844. private _customOpaqueSortCompareFn;
  17845. private _customAlphaTestSortCompareFn;
  17846. private _customTransparentSortCompareFn;
  17847. private _renderingGroupInfo;
  17848. /**
  17849. * Instantiates a new rendering group for a particular scene
  17850. * @param scene Defines the scene the groups belongs to
  17851. */
  17852. constructor(scene: Scene);
  17853. private _clearDepthStencilBuffer;
  17854. /**
  17855. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17856. * @hidden
  17857. */
  17858. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17859. /**
  17860. * Resets the different information of the group to prepare a new frame
  17861. * @hidden
  17862. */
  17863. reset(): void;
  17864. /**
  17865. * Dispose and release the group and its associated resources.
  17866. * @hidden
  17867. */
  17868. dispose(): void;
  17869. /**
  17870. * Clear the info related to rendering groups preventing retention points during dispose.
  17871. */
  17872. freeRenderingGroups(): void;
  17873. private _prepareRenderingGroup;
  17874. /**
  17875. * Add a sprite manager to the rendering manager in order to render it this frame.
  17876. * @param spriteManager Define the sprite manager to render
  17877. */
  17878. dispatchSprites(spriteManager: ISpriteManager): void;
  17879. /**
  17880. * Add a particle system to the rendering manager in order to render it this frame.
  17881. * @param particleSystem Define the particle system to render
  17882. */
  17883. dispatchParticles(particleSystem: IParticleSystem): void;
  17884. /**
  17885. * Add a submesh to the manager in order to render it this frame
  17886. * @param subMesh The submesh to dispatch
  17887. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17888. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17889. */
  17890. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17891. /**
  17892. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17893. * This allowed control for front to back rendering or reversly depending of the special needs.
  17894. *
  17895. * @param renderingGroupId The rendering group id corresponding to its index
  17896. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17897. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17898. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17899. */
  17900. 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;
  17901. /**
  17902. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17903. *
  17904. * @param renderingGroupId The rendering group id corresponding to its index
  17905. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17906. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17907. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17908. */
  17909. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17910. /**
  17911. * Gets the current auto clear configuration for one rendering group of the rendering
  17912. * manager.
  17913. * @param index the rendering group index to get the information for
  17914. * @returns The auto clear setup for the requested rendering group
  17915. */
  17916. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17917. }
  17918. }
  17919. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17920. import { Observable } from "babylonjs/Misc/observable";
  17921. import { SmartArray } from "babylonjs/Misc/smartArray";
  17922. import { Nullable } from "babylonjs/types";
  17923. import { Camera } from "babylonjs/Cameras/camera";
  17924. import { Scene } from "babylonjs/scene";
  17925. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17926. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17928. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17929. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17930. import { Texture } from "babylonjs/Materials/Textures/texture";
  17931. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17932. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17933. import { Engine } from "babylonjs/Engines/engine";
  17934. /**
  17935. * This Helps creating a texture that will be created from a camera in your scene.
  17936. * It is basically a dynamic texture that could be used to create special effects for instance.
  17937. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17938. */
  17939. export class RenderTargetTexture extends Texture {
  17940. isCube: boolean;
  17941. /**
  17942. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17943. */
  17944. static readonly REFRESHRATE_RENDER_ONCE: number;
  17945. /**
  17946. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17947. */
  17948. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17949. /**
  17950. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17951. * the central point of your effect and can save a lot of performances.
  17952. */
  17953. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17954. /**
  17955. * Use this predicate to dynamically define the list of mesh you want to render.
  17956. * If set, the renderList property will be overwritten.
  17957. */
  17958. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17959. private _renderList;
  17960. /**
  17961. * Use this list to define the list of mesh you want to render.
  17962. */
  17963. renderList: Nullable<Array<AbstractMesh>>;
  17964. private _hookArray;
  17965. /**
  17966. * Define if particles should be rendered in your texture.
  17967. */
  17968. renderParticles: boolean;
  17969. /**
  17970. * Define if sprites should be rendered in your texture.
  17971. */
  17972. renderSprites: boolean;
  17973. /**
  17974. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17975. */
  17976. coordinatesMode: number;
  17977. /**
  17978. * Define the camera used to render the texture.
  17979. */
  17980. activeCamera: Nullable<Camera>;
  17981. /**
  17982. * Override the render function of the texture with your own one.
  17983. */
  17984. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17985. /**
  17986. * Define if camera post processes should be use while rendering the texture.
  17987. */
  17988. useCameraPostProcesses: boolean;
  17989. /**
  17990. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17991. */
  17992. ignoreCameraViewport: boolean;
  17993. private _postProcessManager;
  17994. private _postProcesses;
  17995. private _resizeObserver;
  17996. /**
  17997. * An event triggered when the texture is unbind.
  17998. */
  17999. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18000. /**
  18001. * An event triggered when the texture is unbind.
  18002. */
  18003. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18004. private _onAfterUnbindObserver;
  18005. /**
  18006. * Set a after unbind callback in the texture.
  18007. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18008. */
  18009. onAfterUnbind: () => void;
  18010. /**
  18011. * An event triggered before rendering the texture
  18012. */
  18013. onBeforeRenderObservable: Observable<number>;
  18014. private _onBeforeRenderObserver;
  18015. /**
  18016. * Set a before render callback in the texture.
  18017. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18018. */
  18019. onBeforeRender: (faceIndex: number) => void;
  18020. /**
  18021. * An event triggered after rendering the texture
  18022. */
  18023. onAfterRenderObservable: Observable<number>;
  18024. private _onAfterRenderObserver;
  18025. /**
  18026. * Set a after render callback in the texture.
  18027. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18028. */
  18029. onAfterRender: (faceIndex: number) => void;
  18030. /**
  18031. * An event triggered after the texture clear
  18032. */
  18033. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18034. private _onClearObserver;
  18035. /**
  18036. * Set a clear callback in the texture.
  18037. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18038. */
  18039. onClear: (Engine: Engine) => void;
  18040. /**
  18041. * Define the clear color of the Render Target if it should be different from the scene.
  18042. */
  18043. clearColor: Color4;
  18044. protected _size: number | {
  18045. width: number;
  18046. height: number;
  18047. };
  18048. protected _initialSizeParameter: number | {
  18049. width: number;
  18050. height: number;
  18051. } | {
  18052. ratio: number;
  18053. };
  18054. protected _sizeRatio: Nullable<number>;
  18055. /** @hidden */
  18056. _generateMipMaps: boolean;
  18057. protected _renderingManager: RenderingManager;
  18058. /** @hidden */
  18059. _waitingRenderList: string[];
  18060. protected _doNotChangeAspectRatio: boolean;
  18061. protected _currentRefreshId: number;
  18062. protected _refreshRate: number;
  18063. protected _textureMatrix: Matrix;
  18064. protected _samples: number;
  18065. protected _renderTargetOptions: RenderTargetCreationOptions;
  18066. /**
  18067. * Gets render target creation options that were used.
  18068. */
  18069. readonly renderTargetOptions: RenderTargetCreationOptions;
  18070. protected _engine: Engine;
  18071. protected _onRatioRescale(): void;
  18072. /**
  18073. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18074. * It must define where the camera used to render the texture is set
  18075. */
  18076. boundingBoxPosition: Vector3;
  18077. private _boundingBoxSize;
  18078. /**
  18079. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18080. * When defined, the cubemap will switch to local mode
  18081. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18082. * @example https://www.babylonjs-playground.com/#RNASML
  18083. */
  18084. boundingBoxSize: Vector3;
  18085. /**
  18086. * In case the RTT has been created with a depth texture, get the associated
  18087. * depth texture.
  18088. * Otherwise, return null.
  18089. */
  18090. depthStencilTexture: Nullable<InternalTexture>;
  18091. /**
  18092. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18093. * or used a shadow, depth texture...
  18094. * @param name The friendly name of the texture
  18095. * @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)
  18096. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18097. * @param generateMipMaps True if mip maps need to be generated after render.
  18098. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18099. * @param type The type of the buffer in the RTT (int, half float, float...)
  18100. * @param isCube True if a cube texture needs to be created
  18101. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18102. * @param generateDepthBuffer True to generate a depth buffer
  18103. * @param generateStencilBuffer True to generate a stencil buffer
  18104. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18105. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18106. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18107. */
  18108. constructor(name: string, size: number | {
  18109. width: number;
  18110. height: number;
  18111. } | {
  18112. ratio: number;
  18113. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18114. /**
  18115. * Creates a depth stencil texture.
  18116. * This is only available in WebGL 2 or with the depth texture extension available.
  18117. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18118. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18119. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18120. */
  18121. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18122. private _processSizeParameter;
  18123. /**
  18124. * Define the number of samples to use in case of MSAA.
  18125. * It defaults to one meaning no MSAA has been enabled.
  18126. */
  18127. samples: number;
  18128. /**
  18129. * Resets the refresh counter of the texture and start bak from scratch.
  18130. * Could be useful to regenerate the texture if it is setup to render only once.
  18131. */
  18132. resetRefreshCounter(): void;
  18133. /**
  18134. * Define the refresh rate of the texture or the rendering frequency.
  18135. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18136. */
  18137. refreshRate: number;
  18138. /**
  18139. * Adds a post process to the render target rendering passes.
  18140. * @param postProcess define the post process to add
  18141. */
  18142. addPostProcess(postProcess: PostProcess): void;
  18143. /**
  18144. * Clear all the post processes attached to the render target
  18145. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18146. */
  18147. clearPostProcesses(dispose?: boolean): void;
  18148. /**
  18149. * Remove one of the post process from the list of attached post processes to the texture
  18150. * @param postProcess define the post process to remove from the list
  18151. */
  18152. removePostProcess(postProcess: PostProcess): void;
  18153. /** @hidden */
  18154. _shouldRender(): boolean;
  18155. /**
  18156. * Gets the actual render size of the texture.
  18157. * @returns the width of the render size
  18158. */
  18159. getRenderSize(): number;
  18160. /**
  18161. * Gets the actual render width of the texture.
  18162. * @returns the width of the render size
  18163. */
  18164. getRenderWidth(): number;
  18165. /**
  18166. * Gets the actual render height of the texture.
  18167. * @returns the height of the render size
  18168. */
  18169. getRenderHeight(): number;
  18170. /**
  18171. * Get if the texture can be rescaled or not.
  18172. */
  18173. readonly canRescale: boolean;
  18174. /**
  18175. * Resize the texture using a ratio.
  18176. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18177. */
  18178. scale(ratio: number): void;
  18179. /**
  18180. * Get the texture reflection matrix used to rotate/transform the reflection.
  18181. * @returns the reflection matrix
  18182. */
  18183. getReflectionTextureMatrix(): Matrix;
  18184. /**
  18185. * Resize the texture to a new desired size.
  18186. * Be carrefull as it will recreate all the data in the new texture.
  18187. * @param size Define the new size. It can be:
  18188. * - a number for squared texture,
  18189. * - an object containing { width: number, height: number }
  18190. * - or an object containing a ratio { ratio: number }
  18191. */
  18192. resize(size: number | {
  18193. width: number;
  18194. height: number;
  18195. } | {
  18196. ratio: number;
  18197. }): void;
  18198. /**
  18199. * Renders all the objects from the render list into the texture.
  18200. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18201. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18202. */
  18203. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18204. private _bestReflectionRenderTargetDimension;
  18205. /**
  18206. * @hidden
  18207. * @param faceIndex face index to bind to if this is a cubetexture
  18208. */
  18209. _bindFrameBuffer(faceIndex?: number): void;
  18210. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18211. private renderToTarget;
  18212. /**
  18213. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18214. * This allowed control for front to back rendering or reversly depending of the special needs.
  18215. *
  18216. * @param renderingGroupId The rendering group id corresponding to its index
  18217. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18218. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18219. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18220. */
  18221. 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;
  18222. /**
  18223. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18224. *
  18225. * @param renderingGroupId The rendering group id corresponding to its index
  18226. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18227. */
  18228. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18229. /**
  18230. * Clones the texture.
  18231. * @returns the cloned texture
  18232. */
  18233. clone(): RenderTargetTexture;
  18234. /**
  18235. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18236. * @returns The JSON representation of the texture
  18237. */
  18238. serialize(): any;
  18239. /**
  18240. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18241. */
  18242. disposeFramebufferObjects(): void;
  18243. /**
  18244. * Dispose the texture and release its associated resources.
  18245. */
  18246. dispose(): void;
  18247. /** @hidden */
  18248. _rebuild(): void;
  18249. /**
  18250. * Clear the info related to rendering groups preventing retention point in material dispose.
  18251. */
  18252. freeRenderingGroups(): void;
  18253. /**
  18254. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18255. * @returns the view count
  18256. */
  18257. getViewCount(): number;
  18258. }
  18259. }
  18260. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18261. import { Scene } from "babylonjs/scene";
  18262. import { Plane } from "babylonjs/Maths/math";
  18263. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18264. /**
  18265. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18266. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18267. * You can then easily use it as a reflectionTexture on a flat surface.
  18268. * In case the surface is not a plane, please consider relying on reflection probes.
  18269. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18270. */
  18271. export class MirrorTexture extends RenderTargetTexture {
  18272. private scene;
  18273. /**
  18274. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18275. * 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.
  18276. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18277. */
  18278. mirrorPlane: Plane;
  18279. /**
  18280. * Define the blur ratio used to blur the reflection if needed.
  18281. */
  18282. blurRatio: number;
  18283. /**
  18284. * Define the adaptive blur kernel used to blur the reflection if needed.
  18285. * This will autocompute the closest best match for the `blurKernel`
  18286. */
  18287. adaptiveBlurKernel: number;
  18288. /**
  18289. * Define the blur kernel used to blur the reflection if needed.
  18290. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18291. */
  18292. blurKernel: number;
  18293. /**
  18294. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18295. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18296. */
  18297. blurKernelX: number;
  18298. /**
  18299. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18300. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18301. */
  18302. blurKernelY: number;
  18303. private _autoComputeBlurKernel;
  18304. protected _onRatioRescale(): void;
  18305. private _updateGammaSpace;
  18306. private _imageProcessingConfigChangeObserver;
  18307. private _transformMatrix;
  18308. private _mirrorMatrix;
  18309. private _savedViewMatrix;
  18310. private _blurX;
  18311. private _blurY;
  18312. private _adaptiveBlurKernel;
  18313. private _blurKernelX;
  18314. private _blurKernelY;
  18315. private _blurRatio;
  18316. /**
  18317. * Instantiates a Mirror Texture.
  18318. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18319. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18320. * You can then easily use it as a reflectionTexture on a flat surface.
  18321. * In case the surface is not a plane, please consider relying on reflection probes.
  18322. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18323. * @param name
  18324. * @param size
  18325. * @param scene
  18326. * @param generateMipMaps
  18327. * @param type
  18328. * @param samplingMode
  18329. * @param generateDepthBuffer
  18330. */
  18331. constructor(name: string, size: number | {
  18332. width: number;
  18333. height: number;
  18334. } | {
  18335. ratio: number;
  18336. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18337. private _preparePostProcesses;
  18338. /**
  18339. * Clone the mirror texture.
  18340. * @returns the cloned texture
  18341. */
  18342. clone(): MirrorTexture;
  18343. /**
  18344. * Serialize the texture to a JSON representation you could use in Parse later on
  18345. * @returns the serialized JSON representation
  18346. */
  18347. serialize(): any;
  18348. /**
  18349. * Dispose the texture and release its associated resources.
  18350. */
  18351. dispose(): void;
  18352. }
  18353. }
  18354. declare module "babylonjs/Materials/Textures/texture" {
  18355. import { Observable } from "babylonjs/Misc/observable";
  18356. import { Nullable } from "babylonjs/types";
  18357. import { Scene } from "babylonjs/scene";
  18358. import { Matrix } from "babylonjs/Maths/math";
  18359. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18360. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18361. /**
  18362. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18363. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18364. */
  18365. export class Texture extends BaseTexture {
  18366. /** @hidden */
  18367. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18368. /** @hidden */
  18369. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18370. /** @hidden */
  18371. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18372. /** nearest is mag = nearest and min = nearest and mip = linear */
  18373. static readonly NEAREST_SAMPLINGMODE: number;
  18374. /** nearest is mag = nearest and min = nearest and mip = linear */
  18375. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18376. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18377. static readonly BILINEAR_SAMPLINGMODE: number;
  18378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18379. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18380. /** Trilinear is mag = linear and min = linear and mip = linear */
  18381. static readonly TRILINEAR_SAMPLINGMODE: number;
  18382. /** Trilinear is mag = linear and min = linear and mip = linear */
  18383. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18384. /** mag = nearest and min = nearest and mip = nearest */
  18385. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18386. /** mag = nearest and min = linear and mip = nearest */
  18387. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18388. /** mag = nearest and min = linear and mip = linear */
  18389. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18390. /** mag = nearest and min = linear and mip = none */
  18391. static readonly NEAREST_LINEAR: number;
  18392. /** mag = nearest and min = nearest and mip = none */
  18393. static readonly NEAREST_NEAREST: number;
  18394. /** mag = linear and min = nearest and mip = nearest */
  18395. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18396. /** mag = linear and min = nearest and mip = linear */
  18397. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18398. /** mag = linear and min = linear and mip = none */
  18399. static readonly LINEAR_LINEAR: number;
  18400. /** mag = linear and min = nearest and mip = none */
  18401. static readonly LINEAR_NEAREST: number;
  18402. /** Explicit coordinates mode */
  18403. static readonly EXPLICIT_MODE: number;
  18404. /** Spherical coordinates mode */
  18405. static readonly SPHERICAL_MODE: number;
  18406. /** Planar coordinates mode */
  18407. static readonly PLANAR_MODE: number;
  18408. /** Cubic coordinates mode */
  18409. static readonly CUBIC_MODE: number;
  18410. /** Projection coordinates mode */
  18411. static readonly PROJECTION_MODE: number;
  18412. /** Inverse Cubic coordinates mode */
  18413. static readonly SKYBOX_MODE: number;
  18414. /** Inverse Cubic coordinates mode */
  18415. static readonly INVCUBIC_MODE: number;
  18416. /** Equirectangular coordinates mode */
  18417. static readonly EQUIRECTANGULAR_MODE: number;
  18418. /** Equirectangular Fixed coordinates mode */
  18419. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18420. /** Equirectangular Fixed Mirrored coordinates mode */
  18421. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18422. /** Texture is not repeating outside of 0..1 UVs */
  18423. static readonly CLAMP_ADDRESSMODE: number;
  18424. /** Texture is repeating outside of 0..1 UVs */
  18425. static readonly WRAP_ADDRESSMODE: number;
  18426. /** Texture is repeating and mirrored */
  18427. static readonly MIRROR_ADDRESSMODE: number;
  18428. /**
  18429. * 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
  18430. */
  18431. static UseSerializedUrlIfAny: boolean;
  18432. /**
  18433. * Define the url of the texture.
  18434. */
  18435. url: Nullable<string>;
  18436. /**
  18437. * Define an offset on the texture to offset the u coordinates of the UVs
  18438. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18439. */
  18440. uOffset: number;
  18441. /**
  18442. * Define an offset on the texture to offset the v coordinates of the UVs
  18443. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18444. */
  18445. vOffset: number;
  18446. /**
  18447. * Define an offset on the texture to scale the u coordinates of the UVs
  18448. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18449. */
  18450. uScale: number;
  18451. /**
  18452. * Define an offset on the texture to scale the v coordinates of the UVs
  18453. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18454. */
  18455. vScale: number;
  18456. /**
  18457. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18458. * @see http://doc.babylonjs.com/how_to/more_materials
  18459. */
  18460. uAng: number;
  18461. /**
  18462. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18463. * @see http://doc.babylonjs.com/how_to/more_materials
  18464. */
  18465. vAng: number;
  18466. /**
  18467. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18468. * @see http://doc.babylonjs.com/how_to/more_materials
  18469. */
  18470. wAng: number;
  18471. /**
  18472. * Defines the center of rotation (U)
  18473. */
  18474. uRotationCenter: number;
  18475. /**
  18476. * Defines the center of rotation (V)
  18477. */
  18478. vRotationCenter: number;
  18479. /**
  18480. * Defines the center of rotation (W)
  18481. */
  18482. wRotationCenter: number;
  18483. /**
  18484. * Are mip maps generated for this texture or not.
  18485. */
  18486. readonly noMipmap: boolean;
  18487. /**
  18488. * List of inspectable custom properties (used by the Inspector)
  18489. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18490. */
  18491. inspectableCustomProperties: IInspectable[];
  18492. private _noMipmap;
  18493. /** @hidden */
  18494. _invertY: boolean;
  18495. private _rowGenerationMatrix;
  18496. private _cachedTextureMatrix;
  18497. private _projectionModeMatrix;
  18498. private _t0;
  18499. private _t1;
  18500. private _t2;
  18501. private _cachedUOffset;
  18502. private _cachedVOffset;
  18503. private _cachedUScale;
  18504. private _cachedVScale;
  18505. private _cachedUAng;
  18506. private _cachedVAng;
  18507. private _cachedWAng;
  18508. private _cachedProjectionMatrixId;
  18509. private _cachedCoordinatesMode;
  18510. /** @hidden */
  18511. protected _initialSamplingMode: number;
  18512. /** @hidden */
  18513. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18514. private _deleteBuffer;
  18515. protected _format: Nullable<number>;
  18516. private _delayedOnLoad;
  18517. private _delayedOnError;
  18518. /**
  18519. * Observable triggered once the texture has been loaded.
  18520. */
  18521. onLoadObservable: Observable<Texture>;
  18522. protected _isBlocking: boolean;
  18523. /**
  18524. * Is the texture preventing material to render while loading.
  18525. * If false, a default texture will be used instead of the loading one during the preparation step.
  18526. */
  18527. isBlocking: boolean;
  18528. /**
  18529. * Get the current sampling mode associated with the texture.
  18530. */
  18531. readonly samplingMode: number;
  18532. /**
  18533. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18534. */
  18535. readonly invertY: boolean;
  18536. /**
  18537. * Instantiates a new texture.
  18538. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18539. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18540. * @param url define the url of the picture to load as a texture
  18541. * @param scene define the scene the texture will belong to
  18542. * @param noMipmap define if the texture will require mip maps or not
  18543. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18544. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18545. * @param onLoad define a callback triggered when the texture has been loaded
  18546. * @param onError define a callback triggered when an error occurred during the loading session
  18547. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18548. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18549. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18550. */
  18551. 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);
  18552. /**
  18553. * Update the url (and optional buffer) of this texture if url was null during construction.
  18554. * @param url the url of the texture
  18555. * @param buffer the buffer of the texture (defaults to null)
  18556. * @param onLoad callback called when the texture is loaded (defaults to null)
  18557. */
  18558. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18559. /**
  18560. * Finish the loading sequence of a texture flagged as delayed load.
  18561. * @hidden
  18562. */
  18563. delayLoad(): void;
  18564. private _prepareRowForTextureGeneration;
  18565. /**
  18566. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18567. * @returns the transform matrix of the texture.
  18568. */
  18569. getTextureMatrix(): Matrix;
  18570. /**
  18571. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18572. * @returns The reflection texture transform
  18573. */
  18574. getReflectionTextureMatrix(): Matrix;
  18575. /**
  18576. * Clones the texture.
  18577. * @returns the cloned texture
  18578. */
  18579. clone(): Texture;
  18580. /**
  18581. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18582. * @returns The JSON representation of the texture
  18583. */
  18584. serialize(): any;
  18585. /**
  18586. * Get the current class name of the texture useful for serialization or dynamic coding.
  18587. * @returns "Texture"
  18588. */
  18589. getClassName(): string;
  18590. /**
  18591. * Dispose the texture and release its associated resources.
  18592. */
  18593. dispose(): void;
  18594. /**
  18595. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18596. * @param parsedTexture Define the JSON representation of the texture
  18597. * @param scene Define the scene the parsed texture should be instantiated in
  18598. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18599. * @returns The parsed texture if successful
  18600. */
  18601. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18602. /**
  18603. * Creates a texture from its base 64 representation.
  18604. * @param data Define the base64 payload without the data: prefix
  18605. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18606. * @param scene Define the scene the texture should belong to
  18607. * @param noMipmap Forces the texture to not create mip map information if true
  18608. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18609. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18610. * @param onLoad define a callback triggered when the texture has been loaded
  18611. * @param onError define a callback triggered when an error occurred during the loading session
  18612. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18613. * @returns the created texture
  18614. */
  18615. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18616. /**
  18617. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18618. * @param data Define the base64 payload without the data: prefix
  18619. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18620. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18621. * @param scene Define the scene the texture should belong to
  18622. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18623. * @param noMipmap Forces the texture to not create mip map information if true
  18624. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18625. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18626. * @param onLoad define a callback triggered when the texture has been loaded
  18627. * @param onError define a callback triggered when an error occurred during the loading session
  18628. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18629. * @returns the created texture
  18630. */
  18631. 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;
  18632. }
  18633. }
  18634. declare module "babylonjs/Materials/Textures/rawTexture" {
  18635. import { Scene } from "babylonjs/scene";
  18636. import { Texture } from "babylonjs/Materials/Textures/texture";
  18637. /**
  18638. * Raw texture can help creating a texture directly from an array of data.
  18639. * This can be super useful if you either get the data from an uncompressed source or
  18640. * if you wish to create your texture pixel by pixel.
  18641. */
  18642. export class RawTexture extends Texture {
  18643. /**
  18644. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18645. */
  18646. format: number;
  18647. private _engine;
  18648. /**
  18649. * Instantiates a new RawTexture.
  18650. * Raw texture can help creating a texture directly from an array of data.
  18651. * This can be super useful if you either get the data from an uncompressed source or
  18652. * if you wish to create your texture pixel by pixel.
  18653. * @param data define the array of data to use to create the texture
  18654. * @param width define the width of the texture
  18655. * @param height define the height of the texture
  18656. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18657. * @param scene define the scene the texture belongs to
  18658. * @param generateMipMaps define whether mip maps should be generated or not
  18659. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18660. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18661. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18662. */
  18663. constructor(data: ArrayBufferView, width: number, height: number,
  18664. /**
  18665. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18666. */
  18667. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18668. /**
  18669. * Updates the texture underlying data.
  18670. * @param data Define the new data of the texture
  18671. */
  18672. update(data: ArrayBufferView): void;
  18673. /**
  18674. * Creates a luminance texture from some data.
  18675. * @param data Define the texture data
  18676. * @param width Define the width of the texture
  18677. * @param height Define the height of the texture
  18678. * @param scene Define the scene the texture belongs to
  18679. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18680. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18681. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18682. * @returns the luminance texture
  18683. */
  18684. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18685. /**
  18686. * Creates a luminance alpha texture from some data.
  18687. * @param data Define the texture data
  18688. * @param width Define the width of the texture
  18689. * @param height Define the height of the texture
  18690. * @param scene Define the scene the texture belongs to
  18691. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18694. * @returns the luminance alpha texture
  18695. */
  18696. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18697. /**
  18698. * Creates an alpha texture from some data.
  18699. * @param data Define the texture data
  18700. * @param width Define the width of the texture
  18701. * @param height Define the height of the texture
  18702. * @param scene Define the scene the texture belongs to
  18703. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18704. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18705. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18706. * @returns the alpha texture
  18707. */
  18708. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18709. /**
  18710. * Creates a RGB texture from some data.
  18711. * @param data Define the texture data
  18712. * @param width Define the width of the texture
  18713. * @param height Define the height of the texture
  18714. * @param scene Define the scene the texture belongs to
  18715. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18716. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18717. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18718. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18719. * @returns the RGB alpha texture
  18720. */
  18721. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18722. /**
  18723. * Creates a RGBA texture from some data.
  18724. * @param data Define the texture data
  18725. * @param width Define the width of the texture
  18726. * @param height Define the height of the texture
  18727. * @param scene Define the scene the texture belongs to
  18728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18731. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18732. * @returns the RGBA texture
  18733. */
  18734. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18735. /**
  18736. * Creates a R texture from some data.
  18737. * @param data Define the texture data
  18738. * @param width Define the width of the texture
  18739. * @param height Define the height of the texture
  18740. * @param scene Define the scene the texture belongs to
  18741. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18742. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18743. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18744. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18745. * @returns the R texture
  18746. */
  18747. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18748. }
  18749. }
  18750. declare module "babylonjs/Animations/runtimeAnimation" {
  18751. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  18752. import { Animatable } from "babylonjs/Animations/animatable";
  18753. import { Scene } from "babylonjs/scene";
  18754. /**
  18755. * Defines a runtime animation
  18756. */
  18757. export class RuntimeAnimation {
  18758. private _events;
  18759. /**
  18760. * The current frame of the runtime animation
  18761. */
  18762. private _currentFrame;
  18763. /**
  18764. * The animation used by the runtime animation
  18765. */
  18766. private _animation;
  18767. /**
  18768. * The target of the runtime animation
  18769. */
  18770. private _target;
  18771. /**
  18772. * The initiating animatable
  18773. */
  18774. private _host;
  18775. /**
  18776. * The original value of the runtime animation
  18777. */
  18778. private _originalValue;
  18779. /**
  18780. * The original blend value of the runtime animation
  18781. */
  18782. private _originalBlendValue;
  18783. /**
  18784. * The offsets cache of the runtime animation
  18785. */
  18786. private _offsetsCache;
  18787. /**
  18788. * The high limits cache of the runtime animation
  18789. */
  18790. private _highLimitsCache;
  18791. /**
  18792. * Specifies if the runtime animation has been stopped
  18793. */
  18794. private _stopped;
  18795. /**
  18796. * The blending factor of the runtime animation
  18797. */
  18798. private _blendingFactor;
  18799. /**
  18800. * The BabylonJS scene
  18801. */
  18802. private _scene;
  18803. /**
  18804. * The current value of the runtime animation
  18805. */
  18806. private _currentValue;
  18807. /** @hidden */
  18808. _animationState: _IAnimationState;
  18809. /**
  18810. * The active target of the runtime animation
  18811. */
  18812. private _activeTargets;
  18813. private _currentActiveTarget;
  18814. private _directTarget;
  18815. /**
  18816. * The target path of the runtime animation
  18817. */
  18818. private _targetPath;
  18819. /**
  18820. * The weight of the runtime animation
  18821. */
  18822. private _weight;
  18823. /**
  18824. * The ratio offset of the runtime animation
  18825. */
  18826. private _ratioOffset;
  18827. /**
  18828. * The previous delay of the runtime animation
  18829. */
  18830. private _previousDelay;
  18831. /**
  18832. * The previous ratio of the runtime animation
  18833. */
  18834. private _previousRatio;
  18835. private _enableBlending;
  18836. private _keys;
  18837. private _minFrame;
  18838. private _maxFrame;
  18839. private _minValue;
  18840. private _maxValue;
  18841. private _targetIsArray;
  18842. /**
  18843. * Gets the current frame of the runtime animation
  18844. */
  18845. readonly currentFrame: number;
  18846. /**
  18847. * Gets the weight of the runtime animation
  18848. */
  18849. readonly weight: number;
  18850. /**
  18851. * Gets the current value of the runtime animation
  18852. */
  18853. readonly currentValue: any;
  18854. /**
  18855. * Gets the target path of the runtime animation
  18856. */
  18857. readonly targetPath: string;
  18858. /**
  18859. * Gets the actual target of the runtime animation
  18860. */
  18861. readonly target: any;
  18862. /** @hidden */
  18863. _onLoop: () => void;
  18864. /**
  18865. * Create a new RuntimeAnimation object
  18866. * @param target defines the target of the animation
  18867. * @param animation defines the source animation object
  18868. * @param scene defines the hosting scene
  18869. * @param host defines the initiating Animatable
  18870. */
  18871. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18872. private _preparePath;
  18873. /**
  18874. * Gets the animation from the runtime animation
  18875. */
  18876. readonly animation: Animation;
  18877. /**
  18878. * Resets the runtime animation to the beginning
  18879. * @param restoreOriginal defines whether to restore the target property to the original value
  18880. */
  18881. reset(restoreOriginal?: boolean): void;
  18882. /**
  18883. * Specifies if the runtime animation is stopped
  18884. * @returns Boolean specifying if the runtime animation is stopped
  18885. */
  18886. isStopped(): boolean;
  18887. /**
  18888. * Disposes of the runtime animation
  18889. */
  18890. dispose(): void;
  18891. /**
  18892. * Apply the interpolated value to the target
  18893. * @param currentValue defines the value computed by the animation
  18894. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18895. */
  18896. setValue(currentValue: any, weight: number): void;
  18897. private _getOriginalValues;
  18898. private _setValue;
  18899. /**
  18900. * Gets the loop pmode of the runtime animation
  18901. * @returns Loop Mode
  18902. */
  18903. private _getCorrectLoopMode;
  18904. /**
  18905. * Move the current animation to a given frame
  18906. * @param frame defines the frame to move to
  18907. */
  18908. goToFrame(frame: number): void;
  18909. /**
  18910. * @hidden Internal use only
  18911. */
  18912. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18913. /**
  18914. * Execute the current animation
  18915. * @param delay defines the delay to add to the current frame
  18916. * @param from defines the lower bound of the animation range
  18917. * @param to defines the upper bound of the animation range
  18918. * @param loop defines if the current animation must loop
  18919. * @param speedRatio defines the current speed ratio
  18920. * @param weight defines the weight of the animation (default is -1 so no weight)
  18921. * @param onLoop optional callback called when animation loops
  18922. * @returns a boolean indicating if the animation is running
  18923. */
  18924. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18925. }
  18926. }
  18927. declare module "babylonjs/Animations/animatable" {
  18928. import { Animation } from "babylonjs/Animations/animation";
  18929. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18930. import { Nullable } from "babylonjs/types";
  18931. import { Observable } from "babylonjs/Misc/observable";
  18932. import { Scene } from "babylonjs/scene";
  18933. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18934. import { Node } from "babylonjs/node";
  18935. /**
  18936. * Class used to store an actual running animation
  18937. */
  18938. export class Animatable {
  18939. /** defines the target object */
  18940. target: any;
  18941. /** defines the starting frame number (default is 0) */
  18942. fromFrame: number;
  18943. /** defines the ending frame number (default is 100) */
  18944. toFrame: number;
  18945. /** defines if the animation must loop (default is false) */
  18946. loopAnimation: boolean;
  18947. /** defines a callback to call when animation ends if it is not looping */
  18948. onAnimationEnd?: (() => void) | null | undefined;
  18949. /** defines a callback to call when animation loops */
  18950. onAnimationLoop?: (() => void) | null | undefined;
  18951. private _localDelayOffset;
  18952. private _pausedDelay;
  18953. private _runtimeAnimations;
  18954. private _paused;
  18955. private _scene;
  18956. private _speedRatio;
  18957. private _weight;
  18958. private _syncRoot;
  18959. /**
  18960. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18961. * This will only apply for non looping animation (default is true)
  18962. */
  18963. disposeOnEnd: boolean;
  18964. /**
  18965. * Gets a boolean indicating if the animation has started
  18966. */
  18967. animationStarted: boolean;
  18968. /**
  18969. * Observer raised when the animation ends
  18970. */
  18971. onAnimationEndObservable: Observable<Animatable>;
  18972. /**
  18973. * Observer raised when the animation loops
  18974. */
  18975. onAnimationLoopObservable: Observable<Animatable>;
  18976. /**
  18977. * Gets the root Animatable used to synchronize and normalize animations
  18978. */
  18979. readonly syncRoot: Animatable;
  18980. /**
  18981. * Gets the current frame of the first RuntimeAnimation
  18982. * Used to synchronize Animatables
  18983. */
  18984. readonly masterFrame: number;
  18985. /**
  18986. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18987. */
  18988. weight: number;
  18989. /**
  18990. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18991. */
  18992. speedRatio: number;
  18993. /**
  18994. * Creates a new Animatable
  18995. * @param scene defines the hosting scene
  18996. * @param target defines the target object
  18997. * @param fromFrame defines the starting frame number (default is 0)
  18998. * @param toFrame defines the ending frame number (default is 100)
  18999. * @param loopAnimation defines if the animation must loop (default is false)
  19000. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19001. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19002. * @param animations defines a group of animation to add to the new Animatable
  19003. * @param onAnimationLoop defines a callback to call when animation loops
  19004. */
  19005. constructor(scene: Scene,
  19006. /** defines the target object */
  19007. target: any,
  19008. /** defines the starting frame number (default is 0) */
  19009. fromFrame?: number,
  19010. /** defines the ending frame number (default is 100) */
  19011. toFrame?: number,
  19012. /** defines if the animation must loop (default is false) */
  19013. loopAnimation?: boolean, speedRatio?: number,
  19014. /** defines a callback to call when animation ends if it is not looping */
  19015. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19016. /** defines a callback to call when animation loops */
  19017. onAnimationLoop?: (() => void) | null | undefined);
  19018. /**
  19019. * Synchronize and normalize current Animatable with a source Animatable
  19020. * This is useful when using animation weights and when animations are not of the same length
  19021. * @param root defines the root Animatable to synchronize with
  19022. * @returns the current Animatable
  19023. */
  19024. syncWith(root: Animatable): Animatable;
  19025. /**
  19026. * Gets the list of runtime animations
  19027. * @returns an array of RuntimeAnimation
  19028. */
  19029. getAnimations(): RuntimeAnimation[];
  19030. /**
  19031. * Adds more animations to the current animatable
  19032. * @param target defines the target of the animations
  19033. * @param animations defines the new animations to add
  19034. */
  19035. appendAnimations(target: any, animations: Animation[]): void;
  19036. /**
  19037. * Gets the source animation for a specific property
  19038. * @param property defines the propertyu to look for
  19039. * @returns null or the source animation for the given property
  19040. */
  19041. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19042. /**
  19043. * Gets the runtime animation for a specific property
  19044. * @param property defines the propertyu to look for
  19045. * @returns null or the runtime animation for the given property
  19046. */
  19047. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19048. /**
  19049. * Resets the animatable to its original state
  19050. */
  19051. reset(): void;
  19052. /**
  19053. * Allows the animatable to blend with current running animations
  19054. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19055. * @param blendingSpeed defines the blending speed to use
  19056. */
  19057. enableBlending(blendingSpeed: number): void;
  19058. /**
  19059. * Disable animation blending
  19060. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19061. */
  19062. disableBlending(): void;
  19063. /**
  19064. * Jump directly to a given frame
  19065. * @param frame defines the frame to jump to
  19066. */
  19067. goToFrame(frame: number): void;
  19068. /**
  19069. * Pause the animation
  19070. */
  19071. pause(): void;
  19072. /**
  19073. * Restart the animation
  19074. */
  19075. restart(): void;
  19076. private _raiseOnAnimationEnd;
  19077. /**
  19078. * Stop and delete the current animation
  19079. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19080. * @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)
  19081. */
  19082. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19083. /**
  19084. * Wait asynchronously for the animation to end
  19085. * @returns a promise which will be fullfilled when the animation ends
  19086. */
  19087. waitAsync(): Promise<Animatable>;
  19088. /** @hidden */
  19089. _animate(delay: number): boolean;
  19090. }
  19091. module "babylonjs/scene" {
  19092. interface Scene {
  19093. /** @hidden */
  19094. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19095. /** @hidden */
  19096. _processLateAnimationBindingsForMatrices(holder: {
  19097. totalWeight: number;
  19098. animations: RuntimeAnimation[];
  19099. originalValue: Matrix;
  19100. }): any;
  19101. /** @hidden */
  19102. _processLateAnimationBindingsForQuaternions(holder: {
  19103. totalWeight: number;
  19104. animations: RuntimeAnimation[];
  19105. originalValue: Quaternion;
  19106. }, refQuaternion: Quaternion): Quaternion;
  19107. /** @hidden */
  19108. _processLateAnimationBindings(): void;
  19109. /**
  19110. * Will start the animation sequence of a given target
  19111. * @param target defines the target
  19112. * @param from defines from which frame should animation start
  19113. * @param to defines until which frame should animation run.
  19114. * @param weight defines the weight to apply to the animation (1.0 by default)
  19115. * @param loop defines if the animation loops
  19116. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19117. * @param onAnimationEnd defines the function to be executed when the animation ends
  19118. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19119. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19120. * @param onAnimationLoop defines the callback to call when an animation loops
  19121. * @returns the animatable object created for this animation
  19122. */
  19123. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19124. /**
  19125. * Will start the animation sequence of a given target
  19126. * @param target defines the target
  19127. * @param from defines from which frame should animation start
  19128. * @param to defines until which frame should animation run.
  19129. * @param loop defines if the animation loops
  19130. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19131. * @param onAnimationEnd defines the function to be executed when the animation ends
  19132. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19133. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19134. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19135. * @param onAnimationLoop defines the callback to call when an animation loops
  19136. * @returns the animatable object created for this animation
  19137. */
  19138. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19139. /**
  19140. * Will start the animation sequence of a given target and its hierarchy
  19141. * @param target defines the target
  19142. * @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.
  19143. * @param from defines from which frame should animation start
  19144. * @param to defines until which frame should animation run.
  19145. * @param loop defines if the animation loops
  19146. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19147. * @param onAnimationEnd defines the function to be executed when the animation ends
  19148. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19149. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19150. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19151. * @param onAnimationLoop defines the callback to call when an animation loops
  19152. * @returns the list of created animatables
  19153. */
  19154. 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[];
  19155. /**
  19156. * Begin a new animation on a given node
  19157. * @param target defines the target where the animation will take place
  19158. * @param animations defines the list of animations to start
  19159. * @param from defines the initial value
  19160. * @param to defines the final value
  19161. * @param loop defines if you want animation to loop (off by default)
  19162. * @param speedRatio defines the speed ratio to apply to all animations
  19163. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19164. * @param onAnimationLoop defines the callback to call when an animation loops
  19165. * @returns the list of created animatables
  19166. */
  19167. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19168. /**
  19169. * Begin a new animation on a given node and its hierarchy
  19170. * @param target defines the root node where the animation will take place
  19171. * @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.
  19172. * @param animations defines the list of animations to start
  19173. * @param from defines the initial value
  19174. * @param to defines the final value
  19175. * @param loop defines if you want animation to loop (off by default)
  19176. * @param speedRatio defines the speed ratio to apply to all animations
  19177. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19178. * @param onAnimationLoop defines the callback to call when an animation loops
  19179. * @returns the list of animatables created for all nodes
  19180. */
  19181. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19182. /**
  19183. * Gets the animatable associated with a specific target
  19184. * @param target defines the target of the animatable
  19185. * @returns the required animatable if found
  19186. */
  19187. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19188. /**
  19189. * Gets all animatables associated with a given target
  19190. * @param target defines the target to look animatables for
  19191. * @returns an array of Animatables
  19192. */
  19193. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19194. /**
  19195. * Will stop the animation of the given target
  19196. * @param target - the target
  19197. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19198. * @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)
  19199. */
  19200. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19201. /**
  19202. * Stops and removes all animations that have been applied to the scene
  19203. */
  19204. stopAllAnimations(): void;
  19205. }
  19206. }
  19207. module "babylonjs/Bones/bone" {
  19208. interface Bone {
  19209. /**
  19210. * Copy an animation range from another bone
  19211. * @param source defines the source bone
  19212. * @param rangeName defines the range name to copy
  19213. * @param frameOffset defines the frame offset
  19214. * @param rescaleAsRequired defines if rescaling must be applied if required
  19215. * @param skelDimensionsRatio defines the scaling ratio
  19216. * @returns true if operation was successful
  19217. */
  19218. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19219. }
  19220. }
  19221. }
  19222. declare module "babylonjs/Bones/skeleton" {
  19223. import { Bone } from "babylonjs/Bones/bone";
  19224. import { IAnimatable } from "babylonjs/Misc/tools";
  19225. import { Observable } from "babylonjs/Misc/observable";
  19226. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19227. import { Scene } from "babylonjs/scene";
  19228. import { Nullable } from "babylonjs/types";
  19229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19230. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19231. import { Animatable } from "babylonjs/Animations/animatable";
  19232. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19233. import { Animation } from "babylonjs/Animations/animation";
  19234. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19235. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19236. /**
  19237. * Class used to handle skinning animations
  19238. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19239. */
  19240. export class Skeleton implements IAnimatable {
  19241. /** defines the skeleton name */
  19242. name: string;
  19243. /** defines the skeleton Id */
  19244. id: string;
  19245. /**
  19246. * Defines the list of child bones
  19247. */
  19248. bones: Bone[];
  19249. /**
  19250. * Defines an estimate of the dimension of the skeleton at rest
  19251. */
  19252. dimensionsAtRest: Vector3;
  19253. /**
  19254. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19255. */
  19256. needInitialSkinMatrix: boolean;
  19257. /**
  19258. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19259. */
  19260. overrideMesh: Nullable<AbstractMesh>;
  19261. /**
  19262. * Gets the list of animations attached to this skeleton
  19263. */
  19264. animations: Array<Animation>;
  19265. private _scene;
  19266. private _isDirty;
  19267. private _transformMatrices;
  19268. private _transformMatrixTexture;
  19269. private _meshesWithPoseMatrix;
  19270. private _animatables;
  19271. private _identity;
  19272. private _synchronizedWithMesh;
  19273. private _ranges;
  19274. private _lastAbsoluteTransformsUpdateId;
  19275. private _canUseTextureForBones;
  19276. private _uniqueId;
  19277. /** @hidden */
  19278. _numBonesWithLinkedTransformNode: number;
  19279. /**
  19280. * Specifies if the skeleton should be serialized
  19281. */
  19282. doNotSerialize: boolean;
  19283. private _useTextureToStoreBoneMatrices;
  19284. /**
  19285. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19286. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19287. */
  19288. useTextureToStoreBoneMatrices: boolean;
  19289. private _animationPropertiesOverride;
  19290. /**
  19291. * Gets or sets the animation properties override
  19292. */
  19293. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19294. /**
  19295. * List of inspectable custom properties (used by the Inspector)
  19296. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19297. */
  19298. inspectableCustomProperties: IInspectable[];
  19299. /**
  19300. * An observable triggered before computing the skeleton's matrices
  19301. */
  19302. onBeforeComputeObservable: Observable<Skeleton>;
  19303. /**
  19304. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19305. */
  19306. readonly isUsingTextureForMatrices: boolean;
  19307. /**
  19308. * Gets the unique ID of this skeleton
  19309. */
  19310. readonly uniqueId: number;
  19311. /**
  19312. * Creates a new skeleton
  19313. * @param name defines the skeleton name
  19314. * @param id defines the skeleton Id
  19315. * @param scene defines the hosting scene
  19316. */
  19317. constructor(
  19318. /** defines the skeleton name */
  19319. name: string,
  19320. /** defines the skeleton Id */
  19321. id: string, scene: Scene);
  19322. /**
  19323. * Gets the current object class name.
  19324. * @return the class name
  19325. */
  19326. getClassName(): string;
  19327. /**
  19328. * Returns an array containing the root bones
  19329. * @returns an array containing the root bones
  19330. */
  19331. getChildren(): Array<Bone>;
  19332. /**
  19333. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19334. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19335. * @returns a Float32Array containing matrices data
  19336. */
  19337. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19338. /**
  19339. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19340. * @returns a raw texture containing the data
  19341. */
  19342. getTransformMatrixTexture(): Nullable<RawTexture>;
  19343. /**
  19344. * Gets the current hosting scene
  19345. * @returns a scene object
  19346. */
  19347. getScene(): Scene;
  19348. /**
  19349. * Gets a string representing the current skeleton data
  19350. * @param fullDetails defines a boolean indicating if we want a verbose version
  19351. * @returns a string representing the current skeleton data
  19352. */
  19353. toString(fullDetails?: boolean): string;
  19354. /**
  19355. * Get bone's index searching by name
  19356. * @param name defines bone's name to search for
  19357. * @return the indice of the bone. Returns -1 if not found
  19358. */
  19359. getBoneIndexByName(name: string): number;
  19360. /**
  19361. * Creater a new animation range
  19362. * @param name defines the name of the range
  19363. * @param from defines the start key
  19364. * @param to defines the end key
  19365. */
  19366. createAnimationRange(name: string, from: number, to: number): void;
  19367. /**
  19368. * Delete a specific animation range
  19369. * @param name defines the name of the range
  19370. * @param deleteFrames defines if frames must be removed as well
  19371. */
  19372. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19373. /**
  19374. * Gets a specific animation range
  19375. * @param name defines the name of the range to look for
  19376. * @returns the requested animation range or null if not found
  19377. */
  19378. getAnimationRange(name: string): Nullable<AnimationRange>;
  19379. /**
  19380. * Gets the list of all animation ranges defined on this skeleton
  19381. * @returns an array
  19382. */
  19383. getAnimationRanges(): Nullable<AnimationRange>[];
  19384. /**
  19385. * Copy animation range from a source skeleton.
  19386. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19387. * @param source defines the source skeleton
  19388. * @param name defines the name of the range to copy
  19389. * @param rescaleAsRequired defines if rescaling must be applied if required
  19390. * @returns true if operation was successful
  19391. */
  19392. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19393. /**
  19394. * Forces the skeleton to go to rest pose
  19395. */
  19396. returnToRest(): void;
  19397. private _getHighestAnimationFrame;
  19398. /**
  19399. * Begin a specific animation range
  19400. * @param name defines the name of the range to start
  19401. * @param loop defines if looping must be turned on (false by default)
  19402. * @param speedRatio defines the speed ratio to apply (1 by default)
  19403. * @param onAnimationEnd defines a callback which will be called when animation will end
  19404. * @returns a new animatable
  19405. */
  19406. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19407. /** @hidden */
  19408. _markAsDirty(): void;
  19409. /** @hidden */
  19410. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19411. /** @hidden */
  19412. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19413. private _computeTransformMatrices;
  19414. /**
  19415. * Build all resources required to render a skeleton
  19416. */
  19417. prepare(): void;
  19418. /**
  19419. * Gets the list of animatables currently running for this skeleton
  19420. * @returns an array of animatables
  19421. */
  19422. getAnimatables(): IAnimatable[];
  19423. /**
  19424. * Clone the current skeleton
  19425. * @param name defines the name of the new skeleton
  19426. * @param id defines the id of the enw skeleton
  19427. * @returns the new skeleton
  19428. */
  19429. clone(name: string, id: string): Skeleton;
  19430. /**
  19431. * Enable animation blending for this skeleton
  19432. * @param blendingSpeed defines the blending speed to apply
  19433. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19434. */
  19435. enableBlending(blendingSpeed?: number): void;
  19436. /**
  19437. * Releases all resources associated with the current skeleton
  19438. */
  19439. dispose(): void;
  19440. /**
  19441. * Serialize the skeleton in a JSON object
  19442. * @returns a JSON object
  19443. */
  19444. serialize(): any;
  19445. /**
  19446. * Creates a new skeleton from serialized data
  19447. * @param parsedSkeleton defines the serialized data
  19448. * @param scene defines the hosting scene
  19449. * @returns a new skeleton
  19450. */
  19451. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19452. /**
  19453. * Compute all node absolute transforms
  19454. * @param forceUpdate defines if computation must be done even if cache is up to date
  19455. */
  19456. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19457. /**
  19458. * Gets the root pose matrix
  19459. * @returns a matrix
  19460. */
  19461. getPoseMatrix(): Nullable<Matrix>;
  19462. /**
  19463. * Sorts bones per internal index
  19464. */
  19465. sortBones(): void;
  19466. private _sortBones;
  19467. }
  19468. }
  19469. declare module "babylonjs/Morph/morphTarget" {
  19470. import { IAnimatable } from "babylonjs/Misc/tools";
  19471. import { Observable } from "babylonjs/Misc/observable";
  19472. import { Nullable, FloatArray } from "babylonjs/types";
  19473. import { Scene } from "babylonjs/scene";
  19474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19475. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19476. /**
  19477. * Defines a target to use with MorphTargetManager
  19478. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19479. */
  19480. export class MorphTarget implements IAnimatable {
  19481. /** defines the name of the target */
  19482. name: string;
  19483. /**
  19484. * Gets or sets the list of animations
  19485. */
  19486. animations: import("babylonjs/Animations/animation").Animation[];
  19487. private _scene;
  19488. private _positions;
  19489. private _normals;
  19490. private _tangents;
  19491. private _influence;
  19492. /**
  19493. * Observable raised when the influence changes
  19494. */
  19495. onInfluenceChanged: Observable<boolean>;
  19496. /** @hidden */
  19497. _onDataLayoutChanged: Observable<void>;
  19498. /**
  19499. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19500. */
  19501. influence: number;
  19502. /**
  19503. * Gets or sets the id of the morph Target
  19504. */
  19505. id: string;
  19506. private _animationPropertiesOverride;
  19507. /**
  19508. * Gets or sets the animation properties override
  19509. */
  19510. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19511. /**
  19512. * Creates a new MorphTarget
  19513. * @param name defines the name of the target
  19514. * @param influence defines the influence to use
  19515. * @param scene defines the scene the morphtarget belongs to
  19516. */
  19517. constructor(
  19518. /** defines the name of the target */
  19519. name: string, influence?: number, scene?: Nullable<Scene>);
  19520. /**
  19521. * Gets a boolean defining if the target contains position data
  19522. */
  19523. readonly hasPositions: boolean;
  19524. /**
  19525. * Gets a boolean defining if the target contains normal data
  19526. */
  19527. readonly hasNormals: boolean;
  19528. /**
  19529. * Gets a boolean defining if the target contains tangent data
  19530. */
  19531. readonly hasTangents: boolean;
  19532. /**
  19533. * Affects position data to this target
  19534. * @param data defines the position data to use
  19535. */
  19536. setPositions(data: Nullable<FloatArray>): void;
  19537. /**
  19538. * Gets the position data stored in this target
  19539. * @returns a FloatArray containing the position data (or null if not present)
  19540. */
  19541. getPositions(): Nullable<FloatArray>;
  19542. /**
  19543. * Affects normal data to this target
  19544. * @param data defines the normal data to use
  19545. */
  19546. setNormals(data: Nullable<FloatArray>): void;
  19547. /**
  19548. * Gets the normal data stored in this target
  19549. * @returns a FloatArray containing the normal data (or null if not present)
  19550. */
  19551. getNormals(): Nullable<FloatArray>;
  19552. /**
  19553. * Affects tangent data to this target
  19554. * @param data defines the tangent data to use
  19555. */
  19556. setTangents(data: Nullable<FloatArray>): void;
  19557. /**
  19558. * Gets the tangent data stored in this target
  19559. * @returns a FloatArray containing the tangent data (or null if not present)
  19560. */
  19561. getTangents(): Nullable<FloatArray>;
  19562. /**
  19563. * Serializes the current target into a Serialization object
  19564. * @returns the serialized object
  19565. */
  19566. serialize(): any;
  19567. /**
  19568. * Returns the string "MorphTarget"
  19569. * @returns "MorphTarget"
  19570. */
  19571. getClassName(): string;
  19572. /**
  19573. * Creates a new target from serialized data
  19574. * @param serializationObject defines the serialized data to use
  19575. * @returns a new MorphTarget
  19576. */
  19577. static Parse(serializationObject: any): MorphTarget;
  19578. /**
  19579. * Creates a MorphTarget from mesh data
  19580. * @param mesh defines the source mesh
  19581. * @param name defines the name to use for the new target
  19582. * @param influence defines the influence to attach to the target
  19583. * @returns a new MorphTarget
  19584. */
  19585. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19586. }
  19587. }
  19588. declare module "babylonjs/Morph/morphTargetManager" {
  19589. import { Nullable } from "babylonjs/types";
  19590. import { Scene } from "babylonjs/scene";
  19591. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19592. /**
  19593. * This class is used to deform meshes using morphing between different targets
  19594. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19595. */
  19596. export class MorphTargetManager {
  19597. private _targets;
  19598. private _targetInfluenceChangedObservers;
  19599. private _targetDataLayoutChangedObservers;
  19600. private _activeTargets;
  19601. private _scene;
  19602. private _influences;
  19603. private _supportsNormals;
  19604. private _supportsTangents;
  19605. private _vertexCount;
  19606. private _uniqueId;
  19607. private _tempInfluences;
  19608. /**
  19609. * Creates a new MorphTargetManager
  19610. * @param scene defines the current scene
  19611. */
  19612. constructor(scene?: Nullable<Scene>);
  19613. /**
  19614. * Gets the unique ID of this manager
  19615. */
  19616. readonly uniqueId: number;
  19617. /**
  19618. * Gets the number of vertices handled by this manager
  19619. */
  19620. readonly vertexCount: number;
  19621. /**
  19622. * Gets a boolean indicating if this manager supports morphing of normals
  19623. */
  19624. readonly supportsNormals: boolean;
  19625. /**
  19626. * Gets a boolean indicating if this manager supports morphing of tangents
  19627. */
  19628. readonly supportsTangents: boolean;
  19629. /**
  19630. * Gets the number of targets stored in this manager
  19631. */
  19632. readonly numTargets: number;
  19633. /**
  19634. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19635. */
  19636. readonly numInfluencers: number;
  19637. /**
  19638. * Gets the list of influences (one per target)
  19639. */
  19640. readonly influences: Float32Array;
  19641. /**
  19642. * Gets the active target at specified index. An active target is a target with an influence > 0
  19643. * @param index defines the index to check
  19644. * @returns the requested target
  19645. */
  19646. getActiveTarget(index: number): MorphTarget;
  19647. /**
  19648. * Gets the target at specified index
  19649. * @param index defines the index to check
  19650. * @returns the requested target
  19651. */
  19652. getTarget(index: number): MorphTarget;
  19653. /**
  19654. * Add a new target to this manager
  19655. * @param target defines the target to add
  19656. */
  19657. addTarget(target: MorphTarget): void;
  19658. /**
  19659. * Removes a target from the manager
  19660. * @param target defines the target to remove
  19661. */
  19662. removeTarget(target: MorphTarget): void;
  19663. /**
  19664. * Serializes the current manager into a Serialization object
  19665. * @returns the serialized object
  19666. */
  19667. serialize(): any;
  19668. private _syncActiveTargets;
  19669. /**
  19670. * Syncrhonize the targets with all the meshes using this morph target manager
  19671. */
  19672. synchronize(): void;
  19673. /**
  19674. * Creates a new MorphTargetManager from serialized data
  19675. * @param serializationObject defines the serialized data
  19676. * @param scene defines the hosting scene
  19677. * @returns the new MorphTargetManager
  19678. */
  19679. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19680. }
  19681. }
  19682. declare module "babylonjs/Meshes/groundMesh" {
  19683. import { Scene } from "babylonjs/scene";
  19684. import { Vector3 } from "babylonjs/Maths/math";
  19685. import { Mesh } from "babylonjs/Meshes/mesh";
  19686. /**
  19687. * Mesh representing the gorund
  19688. */
  19689. export class GroundMesh extends Mesh {
  19690. /** If octree should be generated */
  19691. generateOctree: boolean;
  19692. private _heightQuads;
  19693. /** @hidden */
  19694. _subdivisionsX: number;
  19695. /** @hidden */
  19696. _subdivisionsY: number;
  19697. /** @hidden */
  19698. _width: number;
  19699. /** @hidden */
  19700. _height: number;
  19701. /** @hidden */
  19702. _minX: number;
  19703. /** @hidden */
  19704. _maxX: number;
  19705. /** @hidden */
  19706. _minZ: number;
  19707. /** @hidden */
  19708. _maxZ: number;
  19709. constructor(name: string, scene: Scene);
  19710. /**
  19711. * "GroundMesh"
  19712. * @returns "GroundMesh"
  19713. */
  19714. getClassName(): string;
  19715. /**
  19716. * The minimum of x and y subdivisions
  19717. */
  19718. readonly subdivisions: number;
  19719. /**
  19720. * X subdivisions
  19721. */
  19722. readonly subdivisionsX: number;
  19723. /**
  19724. * Y subdivisions
  19725. */
  19726. readonly subdivisionsY: number;
  19727. /**
  19728. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19729. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19730. * @param chunksCount the number of subdivisions for x and y
  19731. * @param octreeBlocksSize (Default: 32)
  19732. */
  19733. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19734. /**
  19735. * Returns a height (y) value in the Worl system :
  19736. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19737. * @param x x coordinate
  19738. * @param z z coordinate
  19739. * @returns the ground y position if (x, z) are outside the ground surface.
  19740. */
  19741. getHeightAtCoordinates(x: number, z: number): number;
  19742. /**
  19743. * Returns a normalized vector (Vector3) orthogonal to the ground
  19744. * at the ground coordinates (x, z) expressed in the World system.
  19745. * @param x x coordinate
  19746. * @param z z coordinate
  19747. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19748. */
  19749. getNormalAtCoordinates(x: number, z: number): Vector3;
  19750. /**
  19751. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19752. * at the ground coordinates (x, z) expressed in the World system.
  19753. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19754. * @param x x coordinate
  19755. * @param z z coordinate
  19756. * @param ref vector to store the result
  19757. * @returns the GroundMesh.
  19758. */
  19759. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19760. /**
  19761. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19762. * if the ground has been updated.
  19763. * This can be used in the render loop.
  19764. * @returns the GroundMesh.
  19765. */
  19766. updateCoordinateHeights(): GroundMesh;
  19767. private _getFacetAt;
  19768. private _initHeightQuads;
  19769. private _computeHeightQuads;
  19770. /**
  19771. * Serializes this ground mesh
  19772. * @param serializationObject object to write serialization to
  19773. */
  19774. serialize(serializationObject: any): void;
  19775. /**
  19776. * Parses a serialized ground mesh
  19777. * @param parsedMesh the serialized mesh
  19778. * @param scene the scene to create the ground mesh in
  19779. * @returns the created ground mesh
  19780. */
  19781. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19782. }
  19783. }
  19784. declare module "babylonjs/Physics/physicsJoint" {
  19785. import { Vector3 } from "babylonjs/Maths/math";
  19786. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19787. /**
  19788. * Interface for Physics-Joint data
  19789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19790. */
  19791. export interface PhysicsJointData {
  19792. /**
  19793. * The main pivot of the joint
  19794. */
  19795. mainPivot?: Vector3;
  19796. /**
  19797. * The connected pivot of the joint
  19798. */
  19799. connectedPivot?: Vector3;
  19800. /**
  19801. * The main axis of the joint
  19802. */
  19803. mainAxis?: Vector3;
  19804. /**
  19805. * The connected axis of the joint
  19806. */
  19807. connectedAxis?: Vector3;
  19808. /**
  19809. * The collision of the joint
  19810. */
  19811. collision?: boolean;
  19812. /**
  19813. * Native Oimo/Cannon/Energy data
  19814. */
  19815. nativeParams?: any;
  19816. }
  19817. /**
  19818. * This is a holder class for the physics joint created by the physics plugin
  19819. * It holds a set of functions to control the underlying joint
  19820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19821. */
  19822. export class PhysicsJoint {
  19823. /**
  19824. * The type of the physics joint
  19825. */
  19826. type: number;
  19827. /**
  19828. * The data for the physics joint
  19829. */
  19830. jointData: PhysicsJointData;
  19831. private _physicsJoint;
  19832. protected _physicsPlugin: IPhysicsEnginePlugin;
  19833. /**
  19834. * Initializes the physics joint
  19835. * @param type The type of the physics joint
  19836. * @param jointData The data for the physics joint
  19837. */
  19838. constructor(
  19839. /**
  19840. * The type of the physics joint
  19841. */
  19842. type: number,
  19843. /**
  19844. * The data for the physics joint
  19845. */
  19846. jointData: PhysicsJointData);
  19847. /**
  19848. * Gets the physics joint
  19849. */
  19850. /**
  19851. * Sets the physics joint
  19852. */
  19853. physicsJoint: any;
  19854. /**
  19855. * Sets the physics plugin
  19856. */
  19857. physicsPlugin: IPhysicsEnginePlugin;
  19858. /**
  19859. * Execute a function that is physics-plugin specific.
  19860. * @param {Function} func the function that will be executed.
  19861. * It accepts two parameters: the physics world and the physics joint
  19862. */
  19863. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19864. /**
  19865. * Distance-Joint type
  19866. */
  19867. static DistanceJoint: number;
  19868. /**
  19869. * Hinge-Joint type
  19870. */
  19871. static HingeJoint: number;
  19872. /**
  19873. * Ball-and-Socket joint type
  19874. */
  19875. static BallAndSocketJoint: number;
  19876. /**
  19877. * Wheel-Joint type
  19878. */
  19879. static WheelJoint: number;
  19880. /**
  19881. * Slider-Joint type
  19882. */
  19883. static SliderJoint: number;
  19884. /**
  19885. * Prismatic-Joint type
  19886. */
  19887. static PrismaticJoint: number;
  19888. /**
  19889. * Universal-Joint type
  19890. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19891. */
  19892. static UniversalJoint: number;
  19893. /**
  19894. * Hinge-Joint 2 type
  19895. */
  19896. static Hinge2Joint: number;
  19897. /**
  19898. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19899. */
  19900. static PointToPointJoint: number;
  19901. /**
  19902. * Spring-Joint type
  19903. */
  19904. static SpringJoint: number;
  19905. /**
  19906. * Lock-Joint type
  19907. */
  19908. static LockJoint: number;
  19909. }
  19910. /**
  19911. * A class representing a physics distance joint
  19912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19913. */
  19914. export class DistanceJoint extends PhysicsJoint {
  19915. /**
  19916. *
  19917. * @param jointData The data for the Distance-Joint
  19918. */
  19919. constructor(jointData: DistanceJointData);
  19920. /**
  19921. * Update the predefined distance.
  19922. * @param maxDistance The maximum preferred distance
  19923. * @param minDistance The minimum preferred distance
  19924. */
  19925. updateDistance(maxDistance: number, minDistance?: number): void;
  19926. }
  19927. /**
  19928. * Represents a Motor-Enabled Joint
  19929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19930. */
  19931. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19932. /**
  19933. * Initializes the Motor-Enabled Joint
  19934. * @param type The type of the joint
  19935. * @param jointData The physica joint data for the joint
  19936. */
  19937. constructor(type: number, jointData: PhysicsJointData);
  19938. /**
  19939. * Set the motor values.
  19940. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19941. * @param force the force to apply
  19942. * @param maxForce max force for this motor.
  19943. */
  19944. setMotor(force?: number, maxForce?: number): void;
  19945. /**
  19946. * Set the motor's limits.
  19947. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19948. * @param upperLimit The upper limit of the motor
  19949. * @param lowerLimit The lower limit of the motor
  19950. */
  19951. setLimit(upperLimit: number, lowerLimit?: number): void;
  19952. }
  19953. /**
  19954. * This class represents a single physics Hinge-Joint
  19955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19956. */
  19957. export class HingeJoint extends MotorEnabledJoint {
  19958. /**
  19959. * Initializes the Hinge-Joint
  19960. * @param jointData The joint data for the Hinge-Joint
  19961. */
  19962. constructor(jointData: PhysicsJointData);
  19963. /**
  19964. * Set the motor values.
  19965. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19966. * @param {number} force the force to apply
  19967. * @param {number} maxForce max force for this motor.
  19968. */
  19969. setMotor(force?: number, maxForce?: number): void;
  19970. /**
  19971. * Set the motor's limits.
  19972. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19973. * @param upperLimit The upper limit of the motor
  19974. * @param lowerLimit The lower limit of the motor
  19975. */
  19976. setLimit(upperLimit: number, lowerLimit?: number): void;
  19977. }
  19978. /**
  19979. * This class represents a dual hinge physics joint (same as wheel joint)
  19980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19981. */
  19982. export class Hinge2Joint extends MotorEnabledJoint {
  19983. /**
  19984. * Initializes the Hinge2-Joint
  19985. * @param jointData The joint data for the Hinge2-Joint
  19986. */
  19987. constructor(jointData: PhysicsJointData);
  19988. /**
  19989. * Set the motor values.
  19990. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19991. * @param {number} targetSpeed the speed the motor is to reach
  19992. * @param {number} maxForce max force for this motor.
  19993. * @param {motorIndex} the motor's index, 0 or 1.
  19994. */
  19995. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19996. /**
  19997. * Set the motor limits.
  19998. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19999. * @param {number} upperLimit the upper limit
  20000. * @param {number} lowerLimit lower limit
  20001. * @param {motorIndex} the motor's index, 0 or 1.
  20002. */
  20003. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20004. }
  20005. /**
  20006. * Interface for a motor enabled joint
  20007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20008. */
  20009. export interface IMotorEnabledJoint {
  20010. /**
  20011. * Physics joint
  20012. */
  20013. physicsJoint: any;
  20014. /**
  20015. * Sets the motor of the motor-enabled joint
  20016. * @param force The force of the motor
  20017. * @param maxForce The maximum force of the motor
  20018. * @param motorIndex The index of the motor
  20019. */
  20020. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20021. /**
  20022. * Sets the limit of the motor
  20023. * @param upperLimit The upper limit of the motor
  20024. * @param lowerLimit The lower limit of the motor
  20025. * @param motorIndex The index of the motor
  20026. */
  20027. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20028. }
  20029. /**
  20030. * Joint data for a Distance-Joint
  20031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20032. */
  20033. export interface DistanceJointData extends PhysicsJointData {
  20034. /**
  20035. * Max distance the 2 joint objects can be apart
  20036. */
  20037. maxDistance: number;
  20038. }
  20039. /**
  20040. * Joint data from a spring joint
  20041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20042. */
  20043. export interface SpringJointData extends PhysicsJointData {
  20044. /**
  20045. * Length of the spring
  20046. */
  20047. length: number;
  20048. /**
  20049. * Stiffness of the spring
  20050. */
  20051. stiffness: number;
  20052. /**
  20053. * Damping of the spring
  20054. */
  20055. damping: number;
  20056. /** this callback will be called when applying the force to the impostors. */
  20057. forceApplicationCallback: () => void;
  20058. }
  20059. }
  20060. declare module "babylonjs/Physics/physicsRaycastResult" {
  20061. import { Vector3 } from "babylonjs/Maths/math";
  20062. /**
  20063. * Holds the data for the raycast result
  20064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20065. */
  20066. export class PhysicsRaycastResult {
  20067. private _hasHit;
  20068. private _hitDistance;
  20069. private _hitNormalWorld;
  20070. private _hitPointWorld;
  20071. private _rayFromWorld;
  20072. private _rayToWorld;
  20073. /**
  20074. * Gets if there was a hit
  20075. */
  20076. readonly hasHit: boolean;
  20077. /**
  20078. * Gets the distance from the hit
  20079. */
  20080. readonly hitDistance: number;
  20081. /**
  20082. * Gets the hit normal/direction in the world
  20083. */
  20084. readonly hitNormalWorld: Vector3;
  20085. /**
  20086. * Gets the hit point in the world
  20087. */
  20088. readonly hitPointWorld: Vector3;
  20089. /**
  20090. * Gets the ray "start point" of the ray in the world
  20091. */
  20092. readonly rayFromWorld: Vector3;
  20093. /**
  20094. * Gets the ray "end point" of the ray in the world
  20095. */
  20096. readonly rayToWorld: Vector3;
  20097. /**
  20098. * Sets the hit data (normal & point in world space)
  20099. * @param hitNormalWorld defines the normal in world space
  20100. * @param hitPointWorld defines the point in world space
  20101. */
  20102. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20103. /**
  20104. * Sets the distance from the start point to the hit point
  20105. * @param distance
  20106. */
  20107. setHitDistance(distance: number): void;
  20108. /**
  20109. * Calculates the distance manually
  20110. */
  20111. calculateHitDistance(): void;
  20112. /**
  20113. * Resets all the values to default
  20114. * @param from The from point on world space
  20115. * @param to The to point on world space
  20116. */
  20117. reset(from?: Vector3, to?: Vector3): void;
  20118. }
  20119. /**
  20120. * Interface for the size containing width and height
  20121. */
  20122. interface IXYZ {
  20123. /**
  20124. * X
  20125. */
  20126. x: number;
  20127. /**
  20128. * Y
  20129. */
  20130. y: number;
  20131. /**
  20132. * Z
  20133. */
  20134. z: number;
  20135. }
  20136. }
  20137. declare module "babylonjs/Physics/IPhysicsEngine" {
  20138. import { Nullable } from "babylonjs/types";
  20139. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20141. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20142. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20143. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20144. /**
  20145. * Interface used to describe a physics joint
  20146. */
  20147. export interface PhysicsImpostorJoint {
  20148. /** Defines the main impostor to which the joint is linked */
  20149. mainImpostor: PhysicsImpostor;
  20150. /** Defines the impostor that is connected to the main impostor using this joint */
  20151. connectedImpostor: PhysicsImpostor;
  20152. /** Defines the joint itself */
  20153. joint: PhysicsJoint;
  20154. }
  20155. /** @hidden */
  20156. export interface IPhysicsEnginePlugin {
  20157. world: any;
  20158. name: string;
  20159. setGravity(gravity: Vector3): void;
  20160. setTimeStep(timeStep: number): void;
  20161. getTimeStep(): number;
  20162. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20163. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20164. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20165. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20166. removePhysicsBody(impostor: PhysicsImpostor): void;
  20167. generateJoint(joint: PhysicsImpostorJoint): void;
  20168. removeJoint(joint: PhysicsImpostorJoint): void;
  20169. isSupported(): boolean;
  20170. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20171. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20172. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20173. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20174. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20175. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20176. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20177. getBodyMass(impostor: PhysicsImpostor): number;
  20178. getBodyFriction(impostor: PhysicsImpostor): number;
  20179. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20180. getBodyRestitution(impostor: PhysicsImpostor): number;
  20181. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20182. getBodyPressure?(impostor: PhysicsImpostor): number;
  20183. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20184. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20185. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20186. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20187. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20188. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20189. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20190. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20191. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20192. sleepBody(impostor: PhysicsImpostor): void;
  20193. wakeUpBody(impostor: PhysicsImpostor): void;
  20194. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20195. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20196. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20197. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20198. getRadius(impostor: PhysicsImpostor): number;
  20199. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20200. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20201. dispose(): void;
  20202. }
  20203. /**
  20204. * Interface used to define a physics engine
  20205. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20206. */
  20207. export interface IPhysicsEngine {
  20208. /**
  20209. * Gets the gravity vector used by the simulation
  20210. */
  20211. gravity: Vector3;
  20212. /**
  20213. * Sets the gravity vector used by the simulation
  20214. * @param gravity defines the gravity vector to use
  20215. */
  20216. setGravity(gravity: Vector3): void;
  20217. /**
  20218. * Set the time step of the physics engine.
  20219. * Default is 1/60.
  20220. * To slow it down, enter 1/600 for example.
  20221. * To speed it up, 1/30
  20222. * @param newTimeStep the new timestep to apply to this world.
  20223. */
  20224. setTimeStep(newTimeStep: number): void;
  20225. /**
  20226. * Get the time step of the physics engine.
  20227. * @returns the current time step
  20228. */
  20229. getTimeStep(): number;
  20230. /**
  20231. * Release all resources
  20232. */
  20233. dispose(): void;
  20234. /**
  20235. * Gets the name of the current physics plugin
  20236. * @returns the name of the plugin
  20237. */
  20238. getPhysicsPluginName(): string;
  20239. /**
  20240. * Adding a new impostor for the impostor tracking.
  20241. * This will be done by the impostor itself.
  20242. * @param impostor the impostor to add
  20243. */
  20244. addImpostor(impostor: PhysicsImpostor): void;
  20245. /**
  20246. * Remove an impostor from the engine.
  20247. * This impostor and its mesh will not longer be updated by the physics engine.
  20248. * @param impostor the impostor to remove
  20249. */
  20250. removeImpostor(impostor: PhysicsImpostor): void;
  20251. /**
  20252. * Add a joint to the physics engine
  20253. * @param mainImpostor defines the main impostor to which the joint is added.
  20254. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20255. * @param joint defines the joint that will connect both impostors.
  20256. */
  20257. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20258. /**
  20259. * Removes a joint from the simulation
  20260. * @param mainImpostor defines the impostor used with the joint
  20261. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20262. * @param joint defines the joint to remove
  20263. */
  20264. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20265. /**
  20266. * Gets the current plugin used to run the simulation
  20267. * @returns current plugin
  20268. */
  20269. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20270. /**
  20271. * Gets the list of physic impostors
  20272. * @returns an array of PhysicsImpostor
  20273. */
  20274. getImpostors(): Array<PhysicsImpostor>;
  20275. /**
  20276. * Gets the impostor for a physics enabled object
  20277. * @param object defines the object impersonated by the impostor
  20278. * @returns the PhysicsImpostor or null if not found
  20279. */
  20280. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20281. /**
  20282. * Gets the impostor for a physics body object
  20283. * @param body defines physics body used by the impostor
  20284. * @returns the PhysicsImpostor or null if not found
  20285. */
  20286. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20287. /**
  20288. * Does a raycast in the physics world
  20289. * @param from when should the ray start?
  20290. * @param to when should the ray end?
  20291. * @returns PhysicsRaycastResult
  20292. */
  20293. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20294. /**
  20295. * Called by the scene. No need to call it.
  20296. * @param delta defines the timespam between frames
  20297. */
  20298. _step(delta: number): void;
  20299. }
  20300. }
  20301. declare module "babylonjs/Physics/physicsImpostor" {
  20302. import { Nullable, IndicesArray } from "babylonjs/types";
  20303. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20304. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20306. import { Scene } from "babylonjs/scene";
  20307. import { Bone } from "babylonjs/Bones/bone";
  20308. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20309. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20310. /**
  20311. * The interface for the physics imposter parameters
  20312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20313. */
  20314. export interface PhysicsImpostorParameters {
  20315. /**
  20316. * The mass of the physics imposter
  20317. */
  20318. mass: number;
  20319. /**
  20320. * The friction of the physics imposter
  20321. */
  20322. friction?: number;
  20323. /**
  20324. * The coefficient of restitution of the physics imposter
  20325. */
  20326. restitution?: number;
  20327. /**
  20328. * The native options of the physics imposter
  20329. */
  20330. nativeOptions?: any;
  20331. /**
  20332. * Specifies if the parent should be ignored
  20333. */
  20334. ignoreParent?: boolean;
  20335. /**
  20336. * Specifies if bi-directional transformations should be disabled
  20337. */
  20338. disableBidirectionalTransformation?: boolean;
  20339. /**
  20340. * The pressure inside the physics imposter, soft object only
  20341. */
  20342. pressure?: number;
  20343. /**
  20344. * The stiffness the physics imposter, soft object only
  20345. */
  20346. stiffness?: number;
  20347. /**
  20348. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20349. */
  20350. velocityIterations?: number;
  20351. /**
  20352. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20353. */
  20354. positionIterations?: number;
  20355. /**
  20356. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20357. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20358. * Add to fix multiple points
  20359. */
  20360. fixedPoints?: number;
  20361. /**
  20362. * The collision margin around a soft object
  20363. */
  20364. margin?: number;
  20365. /**
  20366. * The collision margin around a soft object
  20367. */
  20368. damping?: number;
  20369. /**
  20370. * The path for a rope based on an extrusion
  20371. */
  20372. path?: any;
  20373. /**
  20374. * The shape of an extrusion used for a rope based on an extrusion
  20375. */
  20376. shape?: any;
  20377. }
  20378. /**
  20379. * Interface for a physics-enabled object
  20380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20381. */
  20382. export interface IPhysicsEnabledObject {
  20383. /**
  20384. * The position of the physics-enabled object
  20385. */
  20386. position: Vector3;
  20387. /**
  20388. * The rotation of the physics-enabled object
  20389. */
  20390. rotationQuaternion: Nullable<Quaternion>;
  20391. /**
  20392. * The scale of the physics-enabled object
  20393. */
  20394. scaling: Vector3;
  20395. /**
  20396. * The rotation of the physics-enabled object
  20397. */
  20398. rotation?: Vector3;
  20399. /**
  20400. * The parent of the physics-enabled object
  20401. */
  20402. parent?: any;
  20403. /**
  20404. * The bounding info of the physics-enabled object
  20405. * @returns The bounding info of the physics-enabled object
  20406. */
  20407. getBoundingInfo(): BoundingInfo;
  20408. /**
  20409. * Computes the world matrix
  20410. * @param force Specifies if the world matrix should be computed by force
  20411. * @returns A world matrix
  20412. */
  20413. computeWorldMatrix(force: boolean): Matrix;
  20414. /**
  20415. * Gets the world matrix
  20416. * @returns A world matrix
  20417. */
  20418. getWorldMatrix?(): Matrix;
  20419. /**
  20420. * Gets the child meshes
  20421. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20422. * @returns An array of abstract meshes
  20423. */
  20424. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20425. /**
  20426. * Gets the vertex data
  20427. * @param kind The type of vertex data
  20428. * @returns A nullable array of numbers, or a float32 array
  20429. */
  20430. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20431. /**
  20432. * Gets the indices from the mesh
  20433. * @returns A nullable array of index arrays
  20434. */
  20435. getIndices?(): Nullable<IndicesArray>;
  20436. /**
  20437. * Gets the scene from the mesh
  20438. * @returns the indices array or null
  20439. */
  20440. getScene?(): Scene;
  20441. /**
  20442. * Gets the absolute position from the mesh
  20443. * @returns the absolute position
  20444. */
  20445. getAbsolutePosition(): Vector3;
  20446. /**
  20447. * Gets the absolute pivot point from the mesh
  20448. * @returns the absolute pivot point
  20449. */
  20450. getAbsolutePivotPoint(): Vector3;
  20451. /**
  20452. * Rotates the mesh
  20453. * @param axis The axis of rotation
  20454. * @param amount The amount of rotation
  20455. * @param space The space of the rotation
  20456. * @returns The rotation transform node
  20457. */
  20458. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20459. /**
  20460. * Translates the mesh
  20461. * @param axis The axis of translation
  20462. * @param distance The distance of translation
  20463. * @param space The space of the translation
  20464. * @returns The transform node
  20465. */
  20466. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20467. /**
  20468. * Sets the absolute position of the mesh
  20469. * @param absolutePosition The absolute position of the mesh
  20470. * @returns The transform node
  20471. */
  20472. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20473. /**
  20474. * Gets the class name of the mesh
  20475. * @returns The class name
  20476. */
  20477. getClassName(): string;
  20478. }
  20479. /**
  20480. * Represents a physics imposter
  20481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20482. */
  20483. export class PhysicsImpostor {
  20484. /**
  20485. * The physics-enabled object used as the physics imposter
  20486. */
  20487. object: IPhysicsEnabledObject;
  20488. /**
  20489. * The type of the physics imposter
  20490. */
  20491. type: number;
  20492. private _options;
  20493. private _scene?;
  20494. /**
  20495. * The default object size of the imposter
  20496. */
  20497. static DEFAULT_OBJECT_SIZE: Vector3;
  20498. /**
  20499. * The identity quaternion of the imposter
  20500. */
  20501. static IDENTITY_QUATERNION: Quaternion;
  20502. /** @hidden */
  20503. _pluginData: any;
  20504. private _physicsEngine;
  20505. private _physicsBody;
  20506. private _bodyUpdateRequired;
  20507. private _onBeforePhysicsStepCallbacks;
  20508. private _onAfterPhysicsStepCallbacks;
  20509. /** @hidden */
  20510. _onPhysicsCollideCallbacks: Array<{
  20511. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20512. otherImpostors: Array<PhysicsImpostor>;
  20513. }>;
  20514. private _deltaPosition;
  20515. private _deltaRotation;
  20516. private _deltaRotationConjugated;
  20517. /** hidden */
  20518. _isFromLine: boolean;
  20519. private _parent;
  20520. private _isDisposed;
  20521. private static _tmpVecs;
  20522. private static _tmpQuat;
  20523. /**
  20524. * Specifies if the physics imposter is disposed
  20525. */
  20526. readonly isDisposed: boolean;
  20527. /**
  20528. * Gets the mass of the physics imposter
  20529. */
  20530. mass: number;
  20531. /**
  20532. * Gets the coefficient of friction
  20533. */
  20534. /**
  20535. * Sets the coefficient of friction
  20536. */
  20537. friction: number;
  20538. /**
  20539. * Gets the coefficient of restitution
  20540. */
  20541. /**
  20542. * Sets the coefficient of restitution
  20543. */
  20544. restitution: number;
  20545. /**
  20546. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20547. */
  20548. /**
  20549. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20550. */
  20551. pressure: number;
  20552. /**
  20553. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20554. */
  20555. /**
  20556. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20557. */
  20558. stiffness: number;
  20559. /**
  20560. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20561. */
  20562. /**
  20563. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20564. */
  20565. velocityIterations: number;
  20566. /**
  20567. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20568. */
  20569. /**
  20570. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20571. */
  20572. positionIterations: number;
  20573. /**
  20574. * The unique id of the physics imposter
  20575. * set by the physics engine when adding this impostor to the array
  20576. */
  20577. uniqueId: number;
  20578. /**
  20579. * @hidden
  20580. */
  20581. soft: boolean;
  20582. /**
  20583. * @hidden
  20584. */
  20585. segments: number;
  20586. private _joints;
  20587. /**
  20588. * Initializes the physics imposter
  20589. * @param object The physics-enabled object used as the physics imposter
  20590. * @param type The type of the physics imposter
  20591. * @param _options The options for the physics imposter
  20592. * @param _scene The Babylon scene
  20593. */
  20594. constructor(
  20595. /**
  20596. * The physics-enabled object used as the physics imposter
  20597. */
  20598. object: IPhysicsEnabledObject,
  20599. /**
  20600. * The type of the physics imposter
  20601. */
  20602. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20603. /**
  20604. * This function will completly initialize this impostor.
  20605. * It will create a new body - but only if this mesh has no parent.
  20606. * If it has, this impostor will not be used other than to define the impostor
  20607. * of the child mesh.
  20608. * @hidden
  20609. */
  20610. _init(): void;
  20611. private _getPhysicsParent;
  20612. /**
  20613. * Should a new body be generated.
  20614. * @returns boolean specifying if body initialization is required
  20615. */
  20616. isBodyInitRequired(): boolean;
  20617. /**
  20618. * Sets the updated scaling
  20619. * @param updated Specifies if the scaling is updated
  20620. */
  20621. setScalingUpdated(): void;
  20622. /**
  20623. * Force a regeneration of this or the parent's impostor's body.
  20624. * Use under cautious - This will remove all joints already implemented.
  20625. */
  20626. forceUpdate(): void;
  20627. /**
  20628. * Gets the body that holds this impostor. Either its own, or its parent.
  20629. */
  20630. /**
  20631. * Set the physics body. Used mainly by the physics engine/plugin
  20632. */
  20633. physicsBody: any;
  20634. /**
  20635. * Get the parent of the physics imposter
  20636. * @returns Physics imposter or null
  20637. */
  20638. /**
  20639. * Sets the parent of the physics imposter
  20640. */
  20641. parent: Nullable<PhysicsImpostor>;
  20642. /**
  20643. * Resets the update flags
  20644. */
  20645. resetUpdateFlags(): void;
  20646. /**
  20647. * Gets the object extend size
  20648. * @returns the object extend size
  20649. */
  20650. getObjectExtendSize(): Vector3;
  20651. /**
  20652. * Gets the object center
  20653. * @returns The object center
  20654. */
  20655. getObjectCenter(): Vector3;
  20656. /**
  20657. * Get a specific parametes from the options parameter
  20658. * @param paramName The object parameter name
  20659. * @returns The object parameter
  20660. */
  20661. getParam(paramName: string): any;
  20662. /**
  20663. * Sets a specific parameter in the options given to the physics plugin
  20664. * @param paramName The parameter name
  20665. * @param value The value of the parameter
  20666. */
  20667. setParam(paramName: string, value: number): void;
  20668. /**
  20669. * Specifically change the body's mass option. Won't recreate the physics body object
  20670. * @param mass The mass of the physics imposter
  20671. */
  20672. setMass(mass: number): void;
  20673. /**
  20674. * Gets the linear velocity
  20675. * @returns linear velocity or null
  20676. */
  20677. getLinearVelocity(): Nullable<Vector3>;
  20678. /**
  20679. * Sets the linear velocity
  20680. * @param velocity linear velocity or null
  20681. */
  20682. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20683. /**
  20684. * Gets the angular velocity
  20685. * @returns angular velocity or null
  20686. */
  20687. getAngularVelocity(): Nullable<Vector3>;
  20688. /**
  20689. * Sets the angular velocity
  20690. * @param velocity The velocity or null
  20691. */
  20692. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20693. /**
  20694. * Execute a function with the physics plugin native code
  20695. * Provide a function the will have two variables - the world object and the physics body object
  20696. * @param func The function to execute with the physics plugin native code
  20697. */
  20698. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20699. /**
  20700. * Register a function that will be executed before the physics world is stepping forward
  20701. * @param func The function to execute before the physics world is stepped forward
  20702. */
  20703. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20704. /**
  20705. * Unregister a function that will be executed before the physics world is stepping forward
  20706. * @param func The function to execute before the physics world is stepped forward
  20707. */
  20708. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20709. /**
  20710. * Register a function that will be executed after the physics step
  20711. * @param func The function to execute after physics step
  20712. */
  20713. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20714. /**
  20715. * Unregisters a function that will be executed after the physics step
  20716. * @param func The function to execute after physics step
  20717. */
  20718. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20719. /**
  20720. * register a function that will be executed when this impostor collides against a different body
  20721. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20722. * @param func Callback that is executed on collision
  20723. */
  20724. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20725. /**
  20726. * Unregisters the physics imposter on contact
  20727. * @param collideAgainst The physics object to collide against
  20728. * @param func Callback to execute on collision
  20729. */
  20730. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20731. private _tmpQuat;
  20732. private _tmpQuat2;
  20733. /**
  20734. * Get the parent rotation
  20735. * @returns The parent rotation
  20736. */
  20737. getParentsRotation(): Quaternion;
  20738. /**
  20739. * this function is executed by the physics engine.
  20740. */
  20741. beforeStep: () => void;
  20742. /**
  20743. * this function is executed by the physics engine
  20744. */
  20745. afterStep: () => void;
  20746. /**
  20747. * Legacy collision detection event support
  20748. */
  20749. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20750. /**
  20751. * event and body object due to cannon's event-based architecture.
  20752. */
  20753. onCollide: (e: {
  20754. body: any;
  20755. }) => void;
  20756. /**
  20757. * Apply a force
  20758. * @param force The force to apply
  20759. * @param contactPoint The contact point for the force
  20760. * @returns The physics imposter
  20761. */
  20762. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20763. /**
  20764. * Apply an impulse
  20765. * @param force The impulse force
  20766. * @param contactPoint The contact point for the impulse force
  20767. * @returns The physics imposter
  20768. */
  20769. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20770. /**
  20771. * A help function to create a joint
  20772. * @param otherImpostor A physics imposter used to create a joint
  20773. * @param jointType The type of joint
  20774. * @param jointData The data for the joint
  20775. * @returns The physics imposter
  20776. */
  20777. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20778. /**
  20779. * Add a joint to this impostor with a different impostor
  20780. * @param otherImpostor A physics imposter used to add a joint
  20781. * @param joint The joint to add
  20782. * @returns The physics imposter
  20783. */
  20784. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20785. /**
  20786. * Add an anchor to a cloth impostor
  20787. * @param otherImpostor rigid impostor to anchor to
  20788. * @param width ratio across width from 0 to 1
  20789. * @param height ratio up height from 0 to 1
  20790. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20791. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20792. * @returns impostor the soft imposter
  20793. */
  20794. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20795. /**
  20796. * Add a hook to a rope impostor
  20797. * @param otherImpostor rigid impostor to anchor to
  20798. * @param length ratio across rope from 0 to 1
  20799. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20800. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20801. * @returns impostor the rope imposter
  20802. */
  20803. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20804. /**
  20805. * Will keep this body still, in a sleep mode.
  20806. * @returns the physics imposter
  20807. */
  20808. sleep(): PhysicsImpostor;
  20809. /**
  20810. * Wake the body up.
  20811. * @returns The physics imposter
  20812. */
  20813. wakeUp(): PhysicsImpostor;
  20814. /**
  20815. * Clones the physics imposter
  20816. * @param newObject The physics imposter clones to this physics-enabled object
  20817. * @returns A nullable physics imposter
  20818. */
  20819. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20820. /**
  20821. * Disposes the physics imposter
  20822. */
  20823. dispose(): void;
  20824. /**
  20825. * Sets the delta position
  20826. * @param position The delta position amount
  20827. */
  20828. setDeltaPosition(position: Vector3): void;
  20829. /**
  20830. * Sets the delta rotation
  20831. * @param rotation The delta rotation amount
  20832. */
  20833. setDeltaRotation(rotation: Quaternion): void;
  20834. /**
  20835. * Gets the box size of the physics imposter and stores the result in the input parameter
  20836. * @param result Stores the box size
  20837. * @returns The physics imposter
  20838. */
  20839. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20840. /**
  20841. * Gets the radius of the physics imposter
  20842. * @returns Radius of the physics imposter
  20843. */
  20844. getRadius(): number;
  20845. /**
  20846. * Sync a bone with this impostor
  20847. * @param bone The bone to sync to the impostor.
  20848. * @param boneMesh The mesh that the bone is influencing.
  20849. * @param jointPivot The pivot of the joint / bone in local space.
  20850. * @param distToJoint Optional distance from the impostor to the joint.
  20851. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20852. */
  20853. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20854. /**
  20855. * Sync impostor to a bone
  20856. * @param bone The bone that the impostor will be synced to.
  20857. * @param boneMesh The mesh that the bone is influencing.
  20858. * @param jointPivot The pivot of the joint / bone in local space.
  20859. * @param distToJoint Optional distance from the impostor to the joint.
  20860. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20861. * @param boneAxis Optional vector3 axis the bone is aligned with
  20862. */
  20863. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20864. /**
  20865. * No-Imposter type
  20866. */
  20867. static NoImpostor: number;
  20868. /**
  20869. * Sphere-Imposter type
  20870. */
  20871. static SphereImpostor: number;
  20872. /**
  20873. * Box-Imposter type
  20874. */
  20875. static BoxImpostor: number;
  20876. /**
  20877. * Plane-Imposter type
  20878. */
  20879. static PlaneImpostor: number;
  20880. /**
  20881. * Mesh-imposter type
  20882. */
  20883. static MeshImpostor: number;
  20884. /**
  20885. * Cylinder-Imposter type
  20886. */
  20887. static CylinderImpostor: number;
  20888. /**
  20889. * Particle-Imposter type
  20890. */
  20891. static ParticleImpostor: number;
  20892. /**
  20893. * Heightmap-Imposter type
  20894. */
  20895. static HeightmapImpostor: number;
  20896. /**
  20897. * ConvexHull-Impostor type (Ammo.js plugin only)
  20898. */
  20899. static ConvexHullImpostor: number;
  20900. /**
  20901. * Rope-Imposter type
  20902. */
  20903. static RopeImpostor: number;
  20904. /**
  20905. * Cloth-Imposter type
  20906. */
  20907. static ClothImpostor: number;
  20908. /**
  20909. * Softbody-Imposter type
  20910. */
  20911. static SoftbodyImpostor: number;
  20912. }
  20913. }
  20914. declare module "babylonjs/Meshes/mesh" {
  20915. import { Observable } from "babylonjs/Misc/observable";
  20916. import { IAnimatable } from "babylonjs/Misc/tools";
  20917. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20918. import { Camera } from "babylonjs/Cameras/camera";
  20919. import { Scene } from "babylonjs/scene";
  20920. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20921. import { Engine } from "babylonjs/Engines/engine";
  20922. import { Node } from "babylonjs/node";
  20923. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20924. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20925. import { Buffer } from "babylonjs/Meshes/buffer";
  20926. import { Geometry } from "babylonjs/Meshes/geometry";
  20927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20928. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20929. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20930. import { Effect } from "babylonjs/Materials/effect";
  20931. import { Material } from "babylonjs/Materials/material";
  20932. import { Skeleton } from "babylonjs/Bones/skeleton";
  20933. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20934. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20935. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20936. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20937. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20938. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20939. /**
  20940. * Class used to represent a specific level of detail of a mesh
  20941. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20942. */
  20943. export class MeshLODLevel {
  20944. /** Defines the distance where this level should star being displayed */
  20945. distance: number;
  20946. /** Defines the mesh to use to render this level */
  20947. mesh: Nullable<Mesh>;
  20948. /**
  20949. * Creates a new LOD level
  20950. * @param distance defines the distance where this level should star being displayed
  20951. * @param mesh defines the mesh to use to render this level
  20952. */
  20953. constructor(
  20954. /** Defines the distance where this level should star being displayed */
  20955. distance: number,
  20956. /** Defines the mesh to use to render this level */
  20957. mesh: Nullable<Mesh>);
  20958. }
  20959. /**
  20960. * @hidden
  20961. **/
  20962. export class _CreationDataStorage {
  20963. closePath?: boolean;
  20964. closeArray?: boolean;
  20965. idx: number[];
  20966. dashSize: number;
  20967. gapSize: number;
  20968. path3D: Path3D;
  20969. pathArray: Vector3[][];
  20970. arc: number;
  20971. radius: number;
  20972. cap: number;
  20973. tessellation: number;
  20974. }
  20975. /**
  20976. * @hidden
  20977. **/
  20978. class _InstanceDataStorage {
  20979. visibleInstances: any;
  20980. batchCache: _InstancesBatch;
  20981. instancesBufferSize: number;
  20982. instancesBuffer: Nullable<Buffer>;
  20983. instancesData: Float32Array;
  20984. overridenInstanceCount: number;
  20985. isFrozen: boolean;
  20986. previousBatch: _InstancesBatch;
  20987. hardwareInstancedRendering: boolean;
  20988. sideOrientation: number;
  20989. }
  20990. /**
  20991. * @hidden
  20992. **/
  20993. export class _InstancesBatch {
  20994. mustReturn: boolean;
  20995. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20996. renderSelf: boolean[];
  20997. hardwareInstancedRendering: boolean[];
  20998. }
  20999. /**
  21000. * Class used to represent renderable models
  21001. */
  21002. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21003. /**
  21004. * Mesh side orientation : usually the external or front surface
  21005. */
  21006. static readonly FRONTSIDE: number;
  21007. /**
  21008. * Mesh side orientation : usually the internal or back surface
  21009. */
  21010. static readonly BACKSIDE: number;
  21011. /**
  21012. * Mesh side orientation : both internal and external or front and back surfaces
  21013. */
  21014. static readonly DOUBLESIDE: number;
  21015. /**
  21016. * Mesh side orientation : by default, `FRONTSIDE`
  21017. */
  21018. static readonly DEFAULTSIDE: number;
  21019. /**
  21020. * Mesh cap setting : no cap
  21021. */
  21022. static readonly NO_CAP: number;
  21023. /**
  21024. * Mesh cap setting : one cap at the beginning of the mesh
  21025. */
  21026. static readonly CAP_START: number;
  21027. /**
  21028. * Mesh cap setting : one cap at the end of the mesh
  21029. */
  21030. static readonly CAP_END: number;
  21031. /**
  21032. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21033. */
  21034. static readonly CAP_ALL: number;
  21035. /**
  21036. * Gets the default side orientation.
  21037. * @param orientation the orientation to value to attempt to get
  21038. * @returns the default orientation
  21039. * @hidden
  21040. */
  21041. static _GetDefaultSideOrientation(orientation?: number): number;
  21042. private _onBeforeRenderObservable;
  21043. private _onBeforeBindObservable;
  21044. private _onAfterRenderObservable;
  21045. private _onBeforeDrawObservable;
  21046. /**
  21047. * An event triggered before rendering the mesh
  21048. */
  21049. readonly onBeforeRenderObservable: Observable<Mesh>;
  21050. /**
  21051. * An event triggered before binding the mesh
  21052. */
  21053. readonly onBeforeBindObservable: Observable<Mesh>;
  21054. /**
  21055. * An event triggered after rendering the mesh
  21056. */
  21057. readonly onAfterRenderObservable: Observable<Mesh>;
  21058. /**
  21059. * An event triggered before drawing the mesh
  21060. */
  21061. readonly onBeforeDrawObservable: Observable<Mesh>;
  21062. private _onBeforeDrawObserver;
  21063. /**
  21064. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21065. */
  21066. onBeforeDraw: () => void;
  21067. /**
  21068. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21069. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21070. */
  21071. delayLoadState: number;
  21072. /**
  21073. * Gets the list of instances created from this mesh
  21074. * it is not supposed to be modified manually.
  21075. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21076. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21077. */
  21078. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21079. /**
  21080. * Gets the file containing delay loading data for this mesh
  21081. */
  21082. delayLoadingFile: string;
  21083. /** @hidden */
  21084. _binaryInfo: any;
  21085. private _LODLevels;
  21086. /**
  21087. * User defined function used to change how LOD level selection is done
  21088. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21089. */
  21090. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21091. private _morphTargetManager;
  21092. /**
  21093. * Gets or sets the morph target manager
  21094. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21095. */
  21096. morphTargetManager: Nullable<MorphTargetManager>;
  21097. /** @hidden */
  21098. _creationDataStorage: Nullable<_CreationDataStorage>;
  21099. /** @hidden */
  21100. _geometry: Nullable<Geometry>;
  21101. /** @hidden */
  21102. _delayInfo: Array<string>;
  21103. /** @hidden */
  21104. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21105. /** @hidden */
  21106. _instanceDataStorage: _InstanceDataStorage;
  21107. private _effectiveMaterial;
  21108. /** @hidden */
  21109. _shouldGenerateFlatShading: boolean;
  21110. private _preActivateId;
  21111. /** @hidden */
  21112. _originalBuilderSideOrientation: number;
  21113. /**
  21114. * Use this property to change the original side orientation defined at construction time
  21115. */
  21116. overrideMaterialSideOrientation: Nullable<number>;
  21117. private _areNormalsFrozen;
  21118. private _sourcePositions;
  21119. private _sourceNormals;
  21120. private _source;
  21121. private meshMap;
  21122. /**
  21123. * Gets the source mesh (the one used to clone this one from)
  21124. */
  21125. readonly source: Nullable<Mesh>;
  21126. /**
  21127. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21128. */
  21129. isUnIndexed: boolean;
  21130. /**
  21131. * @constructor
  21132. * @param name The value used by scene.getMeshByName() to do a lookup.
  21133. * @param scene The scene to add this mesh to.
  21134. * @param parent The parent of this mesh, if it has one
  21135. * @param source An optional Mesh from which geometry is shared, cloned.
  21136. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21137. * When false, achieved by calling a clone(), also passing False.
  21138. * This will make creation of children, recursive.
  21139. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21140. */
  21141. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21142. /**
  21143. * Gets the class name
  21144. * @returns the string "Mesh".
  21145. */
  21146. getClassName(): string;
  21147. /** @hidden */
  21148. readonly _isMesh: boolean;
  21149. /**
  21150. * Returns a description of this mesh
  21151. * @param fullDetails define if full details about this mesh must be used
  21152. * @returns a descriptive string representing this mesh
  21153. */
  21154. toString(fullDetails?: boolean): string;
  21155. /** @hidden */
  21156. _unBindEffect(): void;
  21157. /**
  21158. * Gets a boolean indicating if this mesh has LOD
  21159. */
  21160. readonly hasLODLevels: boolean;
  21161. /**
  21162. * Gets the list of MeshLODLevel associated with the current mesh
  21163. * @returns an array of MeshLODLevel
  21164. */
  21165. getLODLevels(): MeshLODLevel[];
  21166. private _sortLODLevels;
  21167. /**
  21168. * Add a mesh as LOD level triggered at the given distance.
  21169. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21170. * @param distance The distance from the center of the object to show this level
  21171. * @param mesh The mesh to be added as LOD level (can be null)
  21172. * @return This mesh (for chaining)
  21173. */
  21174. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21175. /**
  21176. * Returns the LOD level mesh at the passed distance or null if not found.
  21177. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21178. * @param distance The distance from the center of the object to show this level
  21179. * @returns a Mesh or `null`
  21180. */
  21181. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21182. /**
  21183. * Remove a mesh from the LOD array
  21184. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21185. * @param mesh defines the mesh to be removed
  21186. * @return This mesh (for chaining)
  21187. */
  21188. removeLODLevel(mesh: Mesh): Mesh;
  21189. /**
  21190. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21191. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21192. * @param camera defines the camera to use to compute distance
  21193. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21194. * @return This mesh (for chaining)
  21195. */
  21196. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21197. /**
  21198. * Gets the mesh internal Geometry object
  21199. */
  21200. readonly geometry: Nullable<Geometry>;
  21201. /**
  21202. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21203. * @returns the total number of vertices
  21204. */
  21205. getTotalVertices(): number;
  21206. /**
  21207. * Returns the content of an associated vertex buffer
  21208. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21209. * - VertexBuffer.PositionKind
  21210. * - VertexBuffer.UVKind
  21211. * - VertexBuffer.UV2Kind
  21212. * - VertexBuffer.UV3Kind
  21213. * - VertexBuffer.UV4Kind
  21214. * - VertexBuffer.UV5Kind
  21215. * - VertexBuffer.UV6Kind
  21216. * - VertexBuffer.ColorKind
  21217. * - VertexBuffer.MatricesIndicesKind
  21218. * - VertexBuffer.MatricesIndicesExtraKind
  21219. * - VertexBuffer.MatricesWeightsKind
  21220. * - VertexBuffer.MatricesWeightsExtraKind
  21221. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  21222. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21223. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21224. */
  21225. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21226. /**
  21227. * Returns the mesh VertexBuffer object from the requested `kind`
  21228. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21229. * - VertexBuffer.PositionKind
  21230. * - VertexBuffer.UVKind
  21231. * - VertexBuffer.UV2Kind
  21232. * - VertexBuffer.UV3Kind
  21233. * - VertexBuffer.UV4Kind
  21234. * - VertexBuffer.UV5Kind
  21235. * - VertexBuffer.UV6Kind
  21236. * - VertexBuffer.ColorKind
  21237. * - VertexBuffer.MatricesIndicesKind
  21238. * - VertexBuffer.MatricesIndicesExtraKind
  21239. * - VertexBuffer.MatricesWeightsKind
  21240. * - VertexBuffer.MatricesWeightsExtraKind
  21241. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21242. */
  21243. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21244. /**
  21245. * Tests if a specific vertex buffer is associated with this mesh
  21246. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21247. * - VertexBuffer.PositionKind
  21248. * - VertexBuffer.UVKind
  21249. * - VertexBuffer.UV2Kind
  21250. * - VertexBuffer.UV3Kind
  21251. * - VertexBuffer.UV4Kind
  21252. * - VertexBuffer.UV5Kind
  21253. * - VertexBuffer.UV6Kind
  21254. * - VertexBuffer.ColorKind
  21255. * - VertexBuffer.MatricesIndicesKind
  21256. * - VertexBuffer.MatricesIndicesExtraKind
  21257. * - VertexBuffer.MatricesWeightsKind
  21258. * - VertexBuffer.MatricesWeightsExtraKind
  21259. * @returns a boolean
  21260. */
  21261. isVerticesDataPresent(kind: string): boolean;
  21262. /**
  21263. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21264. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21265. * - VertexBuffer.PositionKind
  21266. * - VertexBuffer.UVKind
  21267. * - VertexBuffer.UV2Kind
  21268. * - VertexBuffer.UV3Kind
  21269. * - VertexBuffer.UV4Kind
  21270. * - VertexBuffer.UV5Kind
  21271. * - VertexBuffer.UV6Kind
  21272. * - VertexBuffer.ColorKind
  21273. * - VertexBuffer.MatricesIndicesKind
  21274. * - VertexBuffer.MatricesIndicesExtraKind
  21275. * - VertexBuffer.MatricesWeightsKind
  21276. * - VertexBuffer.MatricesWeightsExtraKind
  21277. * @returns a boolean
  21278. */
  21279. isVertexBufferUpdatable(kind: string): boolean;
  21280. /**
  21281. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21282. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21283. * - VertexBuffer.PositionKind
  21284. * - VertexBuffer.UVKind
  21285. * - VertexBuffer.UV2Kind
  21286. * - VertexBuffer.UV3Kind
  21287. * - VertexBuffer.UV4Kind
  21288. * - VertexBuffer.UV5Kind
  21289. * - VertexBuffer.UV6Kind
  21290. * - VertexBuffer.ColorKind
  21291. * - VertexBuffer.MatricesIndicesKind
  21292. * - VertexBuffer.MatricesIndicesExtraKind
  21293. * - VertexBuffer.MatricesWeightsKind
  21294. * - VertexBuffer.MatricesWeightsExtraKind
  21295. * @returns an array of strings
  21296. */
  21297. getVerticesDataKinds(): string[];
  21298. /**
  21299. * Returns a positive integer : the total number of indices in this mesh geometry.
  21300. * @returns the numner of indices or zero if the mesh has no geometry.
  21301. */
  21302. getTotalIndices(): number;
  21303. /**
  21304. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21305. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21306. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21307. * @returns the indices array or an empty array if the mesh has no geometry
  21308. */
  21309. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21310. readonly isBlocked: boolean;
  21311. /**
  21312. * Determine if the current mesh is ready to be rendered
  21313. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21314. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21315. * @returns true if all associated assets are ready (material, textures, shaders)
  21316. */
  21317. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21318. /**
  21319. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  21320. */
  21321. readonly areNormalsFrozen: boolean;
  21322. /**
  21323. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  21324. * @returns the current mesh
  21325. */
  21326. freezeNormals(): Mesh;
  21327. /**
  21328. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  21329. * @returns the current mesh
  21330. */
  21331. unfreezeNormals(): Mesh;
  21332. /**
  21333. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21334. */
  21335. overridenInstanceCount: number;
  21336. /** @hidden */
  21337. _preActivate(): Mesh;
  21338. /** @hidden */
  21339. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21340. /** @hidden */
  21341. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21342. /**
  21343. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21344. * This means the mesh underlying bounding box and sphere are recomputed.
  21345. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21346. * @returns the current mesh
  21347. */
  21348. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21349. /** @hidden */
  21350. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21351. /**
  21352. * This function will subdivide the mesh into multiple submeshes
  21353. * @param count defines the expected number of submeshes
  21354. */
  21355. subdivide(count: number): void;
  21356. /**
  21357. * Copy a FloatArray into a specific associated vertex buffer
  21358. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21359. * - VertexBuffer.PositionKind
  21360. * - VertexBuffer.UVKind
  21361. * - VertexBuffer.UV2Kind
  21362. * - VertexBuffer.UV3Kind
  21363. * - VertexBuffer.UV4Kind
  21364. * - VertexBuffer.UV5Kind
  21365. * - VertexBuffer.UV6Kind
  21366. * - VertexBuffer.ColorKind
  21367. * - VertexBuffer.MatricesIndicesKind
  21368. * - VertexBuffer.MatricesIndicesExtraKind
  21369. * - VertexBuffer.MatricesWeightsKind
  21370. * - VertexBuffer.MatricesWeightsExtraKind
  21371. * @param data defines the data source
  21372. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21373. * @param stride defines the data stride size (can be null)
  21374. * @returns the current mesh
  21375. */
  21376. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21377. /**
  21378. * Flags an associated vertex buffer as updatable
  21379. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21380. * - VertexBuffer.PositionKind
  21381. * - VertexBuffer.UVKind
  21382. * - VertexBuffer.UV2Kind
  21383. * - VertexBuffer.UV3Kind
  21384. * - VertexBuffer.UV4Kind
  21385. * - VertexBuffer.UV5Kind
  21386. * - VertexBuffer.UV6Kind
  21387. * - VertexBuffer.ColorKind
  21388. * - VertexBuffer.MatricesIndicesKind
  21389. * - VertexBuffer.MatricesIndicesExtraKind
  21390. * - VertexBuffer.MatricesWeightsKind
  21391. * - VertexBuffer.MatricesWeightsExtraKind
  21392. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21393. */
  21394. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21395. /**
  21396. * Sets the mesh global Vertex Buffer
  21397. * @param buffer defines the buffer to use
  21398. * @returns the current mesh
  21399. */
  21400. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21401. /**
  21402. * Update a specific associated vertex buffer
  21403. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21404. * - VertexBuffer.PositionKind
  21405. * - VertexBuffer.UVKind
  21406. * - VertexBuffer.UV2Kind
  21407. * - VertexBuffer.UV3Kind
  21408. * - VertexBuffer.UV4Kind
  21409. * - VertexBuffer.UV5Kind
  21410. * - VertexBuffer.UV6Kind
  21411. * - VertexBuffer.ColorKind
  21412. * - VertexBuffer.MatricesIndicesKind
  21413. * - VertexBuffer.MatricesIndicesExtraKind
  21414. * - VertexBuffer.MatricesWeightsKind
  21415. * - VertexBuffer.MatricesWeightsExtraKind
  21416. * @param data defines the data source
  21417. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21418. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  21419. * @returns the current mesh
  21420. */
  21421. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21422. /**
  21423. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21424. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21425. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21426. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21427. * @returns the current mesh
  21428. */
  21429. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21430. /**
  21431. * Creates a un-shared specific occurence of the geometry for the mesh.
  21432. * @returns the current mesh
  21433. */
  21434. makeGeometryUnique(): Mesh;
  21435. /**
  21436. * Set the index buffer of this mesh
  21437. * @param indices defines the source data
  21438. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21439. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21440. * @returns the current mesh
  21441. */
  21442. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21443. /**
  21444. * Update the current index buffer
  21445. * @param indices defines the source data
  21446. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21447. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21448. * @returns the current mesh
  21449. */
  21450. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21451. /**
  21452. * Invert the geometry to move from a right handed system to a left handed one.
  21453. * @returns the current mesh
  21454. */
  21455. toLeftHanded(): Mesh;
  21456. /** @hidden */
  21457. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21458. /** @hidden */
  21459. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21460. /**
  21461. * Registers for this mesh a javascript function called just before the rendering process
  21462. * @param func defines the function to call before rendering this mesh
  21463. * @returns the current mesh
  21464. */
  21465. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21466. /**
  21467. * Disposes a previously registered javascript function called before the rendering
  21468. * @param func defines the function to remove
  21469. * @returns the current mesh
  21470. */
  21471. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21472. /**
  21473. * Registers for this mesh a javascript function called just after the rendering is complete
  21474. * @param func defines the function to call after rendering this mesh
  21475. * @returns the current mesh
  21476. */
  21477. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21478. /**
  21479. * Disposes a previously registered javascript function called after the rendering.
  21480. * @param func defines the function to remove
  21481. * @returns the current mesh
  21482. */
  21483. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21484. /** @hidden */
  21485. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21486. /** @hidden */
  21487. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21488. /** @hidden */
  21489. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21490. /** @hidden */
  21491. _freeze(): void;
  21492. /** @hidden */
  21493. _unFreeze(): void;
  21494. /**
  21495. * 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
  21496. * @param subMesh defines the subMesh to render
  21497. * @param enableAlphaMode defines if alpha mode can be changed
  21498. * @returns the current mesh
  21499. */
  21500. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21501. private _onBeforeDraw;
  21502. /**
  21503. * Renormalize the mesh and patch it up if there are no weights
  21504. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21505. * However in the case of zero weights then we set just a single influence to 1.
  21506. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21507. */
  21508. cleanMatrixWeights(): void;
  21509. private normalizeSkinFourWeights;
  21510. private normalizeSkinWeightsAndExtra;
  21511. /**
  21512. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21513. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21514. * the user know there was an issue with importing the mesh
  21515. * @returns a validation object with skinned, valid and report string
  21516. */
  21517. validateSkinning(): {
  21518. skinned: boolean;
  21519. valid: boolean;
  21520. report: string;
  21521. };
  21522. /** @hidden */
  21523. _checkDelayState(): Mesh;
  21524. private _queueLoad;
  21525. /**
  21526. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21527. * A mesh is in the frustum if its bounding box intersects the frustum
  21528. * @param frustumPlanes defines the frustum to test
  21529. * @returns true if the mesh is in the frustum planes
  21530. */
  21531. isInFrustum(frustumPlanes: Plane[]): boolean;
  21532. /**
  21533. * Sets the mesh material by the material or multiMaterial `id` property
  21534. * @param id is a string identifying the material or the multiMaterial
  21535. * @returns the current mesh
  21536. */
  21537. setMaterialByID(id: string): Mesh;
  21538. /**
  21539. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21540. * @returns an array of IAnimatable
  21541. */
  21542. getAnimatables(): IAnimatable[];
  21543. /**
  21544. * Modifies the mesh geometry according to the passed transformation matrix.
  21545. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21546. * The mesh normals are modified using the same transformation.
  21547. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21548. * @param transform defines the transform matrix to use
  21549. * @see http://doc.babylonjs.com/resources/baking_transformations
  21550. * @returns the current mesh
  21551. */
  21552. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21553. /**
  21554. * Modifies the mesh geometry according to its own current World Matrix.
  21555. * The mesh World Matrix is then reset.
  21556. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21557. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21558. * @see http://doc.babylonjs.com/resources/baking_transformations
  21559. * @returns the current mesh
  21560. */
  21561. bakeCurrentTransformIntoVertices(): Mesh;
  21562. /** @hidden */
  21563. readonly _positions: Nullable<Vector3[]>;
  21564. /** @hidden */
  21565. _resetPointsArrayCache(): Mesh;
  21566. /** @hidden */
  21567. _generatePointsArray(): boolean;
  21568. /**
  21569. * Returns a new Mesh object generated from the current mesh properties.
  21570. * This method must not get confused with createInstance()
  21571. * @param name is a string, the name given to the new mesh
  21572. * @param newParent can be any Node object (default `null`)
  21573. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21574. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21575. * @returns a new mesh
  21576. */
  21577. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21578. /**
  21579. * Releases resources associated with this mesh.
  21580. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21581. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21582. */
  21583. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21584. /**
  21585. * Modifies the mesh geometry according to a displacement map.
  21586. * 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.
  21587. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21588. * @param url is a string, the URL from the image file is to be downloaded.
  21589. * @param minHeight is the lower limit of the displacement.
  21590. * @param maxHeight is the upper limit of the displacement.
  21591. * @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.
  21592. * @param uvOffset is an optional vector2 used to offset UV.
  21593. * @param uvScale is an optional vector2 used to scale UV.
  21594. * @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.
  21595. * @returns the Mesh.
  21596. */
  21597. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21598. /**
  21599. * Modifies the mesh geometry according to a displacementMap buffer.
  21600. * 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.
  21601. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21602. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21603. * @param heightMapWidth is the width of the buffer image.
  21604. * @param heightMapHeight is the height of the buffer image.
  21605. * @param minHeight is the lower limit of the displacement.
  21606. * @param maxHeight is the upper limit of the displacement.
  21607. * @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.
  21608. * @param uvOffset is an optional vector2 used to offset UV.
  21609. * @param uvScale is an optional vector2 used to scale UV.
  21610. * @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.
  21611. * @returns the Mesh.
  21612. */
  21613. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21614. /**
  21615. * Modify the mesh to get a flat shading rendering.
  21616. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21617. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21618. * @returns current mesh
  21619. */
  21620. convertToFlatShadedMesh(): Mesh;
  21621. /**
  21622. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21623. * In other words, more vertices, no more indices and a single bigger VBO.
  21624. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21625. * @returns current mesh
  21626. */
  21627. convertToUnIndexedMesh(): Mesh;
  21628. /**
  21629. * Inverses facet orientations.
  21630. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21631. * @param flipNormals will also inverts the normals
  21632. * @returns current mesh
  21633. */
  21634. flipFaces(flipNormals?: boolean): Mesh;
  21635. /**
  21636. * Increase the number of facets and hence vertices in a mesh
  21637. * Vertex normals are interpolated from existing vertex normals
  21638. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21639. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21640. */
  21641. increaseVertices(numberPerEdge: number): void;
  21642. /**
  21643. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21644. * This will undo any application of covertToFlatShadedMesh
  21645. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21646. */
  21647. forceSharedVertices(): void;
  21648. /** @hidden */
  21649. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21650. /** @hidden */
  21651. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21652. /**
  21653. * Creates a new InstancedMesh object from the mesh model.
  21654. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21655. * @param name defines the name of the new instance
  21656. * @returns a new InstancedMesh
  21657. */
  21658. createInstance(name: string): InstancedMesh;
  21659. /**
  21660. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21661. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21662. * @returns the current mesh
  21663. */
  21664. synchronizeInstances(): Mesh;
  21665. /**
  21666. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21667. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21668. * This should be used together with the simplification to avoid disappearing triangles.
  21669. * @param successCallback an optional success callback to be called after the optimization finished.
  21670. * @returns the current mesh
  21671. */
  21672. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21673. /**
  21674. * Serialize current mesh
  21675. * @param serializationObject defines the object which will receive the serialization data
  21676. */
  21677. serialize(serializationObject: any): void;
  21678. /** @hidden */
  21679. _syncGeometryWithMorphTargetManager(): void;
  21680. /** @hidden */
  21681. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21682. /**
  21683. * Returns a new Mesh object parsed from the source provided.
  21684. * @param parsedMesh is the source
  21685. * @param scene defines the hosting scene
  21686. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21687. * @returns a new Mesh
  21688. */
  21689. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21690. /**
  21691. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21692. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21693. * @param name defines the name of the mesh to create
  21694. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21695. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21696. * @param closePath creates a seam between the first and the last points of each path of the path array
  21697. * @param offset is taken in account only if the `pathArray` is containing a single path
  21698. * @param scene defines the hosting scene
  21699. * @param updatable defines if the mesh must be flagged as updatable
  21700. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21701. * @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)
  21702. * @returns a new Mesh
  21703. */
  21704. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21705. /**
  21706. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21707. * @param name defines the name of the mesh to create
  21708. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21709. * @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
  21710. * @param scene defines the hosting scene
  21711. * @param updatable defines if the mesh must be flagged as updatable
  21712. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21713. * @returns a new Mesh
  21714. */
  21715. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21716. /**
  21717. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21718. * @param name defines the name of the mesh to create
  21719. * @param size sets the size (float) of each box side (default 1)
  21720. * @param scene defines the hosting scene
  21721. * @param updatable defines if the mesh must be flagged as updatable
  21722. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21723. * @returns a new Mesh
  21724. */
  21725. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21726. /**
  21727. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21728. * @param name defines the name of the mesh to create
  21729. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21730. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21731. * @param scene defines the hosting scene
  21732. * @param updatable defines if the mesh must be flagged as updatable
  21733. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21734. * @returns a new Mesh
  21735. */
  21736. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21737. /**
  21738. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21739. * @param name defines the name of the mesh to create
  21740. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21741. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21742. * @param scene defines the hosting scene
  21743. * @returns a new Mesh
  21744. */
  21745. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21746. /**
  21747. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21748. * @param name defines the name of the mesh to create
  21749. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21750. * @param diameterTop set the top cap diameter (floats, default 1)
  21751. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21752. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21753. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21754. * @param scene defines the hosting scene
  21755. * @param updatable defines if the mesh must be flagged as updatable
  21756. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21757. * @returns a new Mesh
  21758. */
  21759. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21760. /**
  21761. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21762. * @param name defines the name of the mesh to create
  21763. * @param diameter sets the diameter size (float) of the torus (default 1)
  21764. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21765. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21766. * @param scene defines the hosting scene
  21767. * @param updatable defines if the mesh must be flagged as updatable
  21768. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21769. * @returns a new Mesh
  21770. */
  21771. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21772. /**
  21773. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21774. * @param name defines the name of the mesh to create
  21775. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21776. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21777. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21778. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21779. * @param p the number of windings on X axis (positive integers, default 2)
  21780. * @param q the number of windings on Y axis (positive integers, default 3)
  21781. * @param scene defines the hosting scene
  21782. * @param updatable defines if the mesh must be flagged as updatable
  21783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21784. * @returns a new Mesh
  21785. */
  21786. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21787. /**
  21788. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21789. * @param name defines the name of the mesh to create
  21790. * @param points is an array successive Vector3
  21791. * @param scene defines the hosting scene
  21792. * @param updatable defines if the mesh must be flagged as updatable
  21793. * @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).
  21794. * @returns a new Mesh
  21795. */
  21796. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21797. /**
  21798. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21799. * @param name defines the name of the mesh to create
  21800. * @param points is an array successive Vector3
  21801. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21802. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21803. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21804. * @param scene defines the hosting scene
  21805. * @param updatable defines if the mesh must be flagged as updatable
  21806. * @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)
  21807. * @returns a new Mesh
  21808. */
  21809. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21810. /**
  21811. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21812. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21813. * 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.
  21814. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21815. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21816. * Remember you can only change the shape positions, not their number when updating a polygon.
  21817. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21818. * @param name defines the name of the mesh to create
  21819. * @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
  21820. * @param scene defines the hosting scene
  21821. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21822. * @param updatable defines if the mesh must be flagged as updatable
  21823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21824. * @param earcutInjection can be used to inject your own earcut reference
  21825. * @returns a new Mesh
  21826. */
  21827. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21828. /**
  21829. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21830. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21831. * @param name defines the name of the mesh to create
  21832. * @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
  21833. * @param depth defines the height of extrusion
  21834. * @param scene defines the hosting scene
  21835. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21836. * @param updatable defines if the mesh must be flagged as updatable
  21837. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21838. * @param earcutInjection can be used to inject your own earcut reference
  21839. * @returns a new Mesh
  21840. */
  21841. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21842. /**
  21843. * Creates an extruded shape mesh.
  21844. * 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
  21845. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21846. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21847. * @param name defines the name of the mesh to create
  21848. * @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
  21849. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21850. * @param scale is the value to scale the shape
  21851. * @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
  21852. * @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
  21853. * @param scene defines the hosting scene
  21854. * @param updatable defines if the mesh must be flagged as updatable
  21855. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21856. * @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)
  21857. * @returns a new Mesh
  21858. */
  21859. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21860. /**
  21861. * Creates an custom extruded shape mesh.
  21862. * The custom extrusion is a parametric shape.
  21863. * It has no predefined shape. Its final shape will depend on the input parameters.
  21864. * Please consider using the same method from the MeshBuilder class instead
  21865. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21866. * @param name defines the name of the mesh to create
  21867. * @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
  21868. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21869. * @param scaleFunction is a custom Javascript function called on each path point
  21870. * @param rotationFunction is a custom Javascript function called on each path point
  21871. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21872. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21873. * @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
  21874. * @param scene defines the hosting scene
  21875. * @param updatable defines if the mesh must be flagged as updatable
  21876. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21877. * @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)
  21878. * @returns a new Mesh
  21879. */
  21880. 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;
  21881. /**
  21882. * Creates lathe mesh.
  21883. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21884. * Please consider using the same method from the MeshBuilder class instead
  21885. * @param name defines the name of the mesh to create
  21886. * @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
  21887. * @param radius is the radius value of the lathe
  21888. * @param tessellation is the side number of the lathe.
  21889. * @param scene defines the hosting scene
  21890. * @param updatable defines if the mesh must be flagged as updatable
  21891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21892. * @returns a new Mesh
  21893. */
  21894. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21895. /**
  21896. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21897. * @param name defines the name of the mesh to create
  21898. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21899. * @param scene defines the hosting scene
  21900. * @param updatable defines if the mesh must be flagged as updatable
  21901. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21902. * @returns a new Mesh
  21903. */
  21904. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21905. /**
  21906. * Creates a ground mesh.
  21907. * Please consider using the same method from the MeshBuilder class instead
  21908. * @param name defines the name of the mesh to create
  21909. * @param width set the width of the ground
  21910. * @param height set the height of the ground
  21911. * @param subdivisions sets the number of subdivisions per side
  21912. * @param scene defines the hosting scene
  21913. * @param updatable defines if the mesh must be flagged as updatable
  21914. * @returns a new Mesh
  21915. */
  21916. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21917. /**
  21918. * Creates a tiled ground mesh.
  21919. * Please consider using the same method from the MeshBuilder class instead
  21920. * @param name defines the name of the mesh to create
  21921. * @param xmin set the ground minimum X coordinate
  21922. * @param zmin set the ground minimum Y coordinate
  21923. * @param xmax set the ground maximum X coordinate
  21924. * @param zmax set the ground maximum Z coordinate
  21925. * @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
  21926. * @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
  21927. * @param scene defines the hosting scene
  21928. * @param updatable defines if the mesh must be flagged as updatable
  21929. * @returns a new Mesh
  21930. */
  21931. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21932. w: number;
  21933. h: number;
  21934. }, precision: {
  21935. w: number;
  21936. h: number;
  21937. }, scene: Scene, updatable?: boolean): Mesh;
  21938. /**
  21939. * Creates a ground mesh from a height map.
  21940. * Please consider using the same method from the MeshBuilder class instead
  21941. * @see http://doc.babylonjs.com/babylon101/height_map
  21942. * @param name defines the name of the mesh to create
  21943. * @param url sets the URL of the height map image resource
  21944. * @param width set the ground width size
  21945. * @param height set the ground height size
  21946. * @param subdivisions sets the number of subdivision per side
  21947. * @param minHeight is the minimum altitude on the ground
  21948. * @param maxHeight is the maximum altitude on the ground
  21949. * @param scene defines the hosting scene
  21950. * @param updatable defines if the mesh must be flagged as updatable
  21951. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21952. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21953. * @returns a new Mesh
  21954. */
  21955. 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;
  21956. /**
  21957. * Creates a tube mesh.
  21958. * The tube is a parametric shape.
  21959. * It has no predefined shape. Its final shape will depend on the input parameters.
  21960. * Please consider using the same method from the MeshBuilder class instead
  21961. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21962. * @param name defines the name of the mesh to create
  21963. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21964. * @param radius sets the tube radius size
  21965. * @param tessellation is the number of sides on the tubular surface
  21966. * @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
  21967. * @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
  21968. * @param scene defines the hosting scene
  21969. * @param updatable defines if the mesh must be flagged as updatable
  21970. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21971. * @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)
  21972. * @returns a new Mesh
  21973. */
  21974. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21975. (i: number, distance: number): number;
  21976. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21977. /**
  21978. * Creates a polyhedron mesh.
  21979. * Please consider using the same method from the MeshBuilder class instead.
  21980. * * 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
  21981. * * The parameter `size` (positive float, default 1) sets the polygon size
  21982. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21983. * * 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`
  21984. * * 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
  21985. * * 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)`)
  21986. * * 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
  21987. * * 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
  21988. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21989. * * If you create a double-sided mesh, you can choose what parts of 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
  21990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21991. * @param name defines the name of the mesh to create
  21992. * @param options defines the options used to create the mesh
  21993. * @param scene defines the hosting scene
  21994. * @returns a new Mesh
  21995. */
  21996. static CreatePolyhedron(name: string, options: {
  21997. type?: number;
  21998. size?: number;
  21999. sizeX?: number;
  22000. sizeY?: number;
  22001. sizeZ?: number;
  22002. custom?: any;
  22003. faceUV?: Vector4[];
  22004. faceColors?: Color4[];
  22005. updatable?: boolean;
  22006. sideOrientation?: number;
  22007. }, scene: Scene): Mesh;
  22008. /**
  22009. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22010. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22011. * * 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`)
  22012. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22013. * * 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
  22014. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22015. * * If you create a double-sided mesh, you can choose what parts of 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
  22016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22017. * @param name defines the name of the mesh
  22018. * @param options defines the options used to create the mesh
  22019. * @param scene defines the hosting scene
  22020. * @returns a new Mesh
  22021. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22022. */
  22023. static CreateIcoSphere(name: string, options: {
  22024. radius?: number;
  22025. flat?: boolean;
  22026. subdivisions?: number;
  22027. sideOrientation?: number;
  22028. updatable?: boolean;
  22029. }, scene: Scene): Mesh;
  22030. /**
  22031. * Creates a decal mesh.
  22032. * Please consider using the same method from the MeshBuilder class instead.
  22033. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22034. * @param name defines the name of the mesh
  22035. * @param sourceMesh defines the mesh receiving the decal
  22036. * @param position sets the position of the decal in world coordinates
  22037. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22038. * @param size sets the decal scaling
  22039. * @param angle sets the angle to rotate the decal
  22040. * @returns a new Mesh
  22041. */
  22042. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22043. /**
  22044. * Prepare internal position array for software CPU skinning
  22045. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22046. */
  22047. setPositionsForCPUSkinning(): Float32Array;
  22048. /**
  22049. * Prepare internal normal array for software CPU skinning
  22050. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22051. */
  22052. setNormalsForCPUSkinning(): Float32Array;
  22053. /**
  22054. * Updates the vertex buffer by applying transformation from the bones
  22055. * @param skeleton defines the skeleton to apply to current mesh
  22056. * @returns the current mesh
  22057. */
  22058. applySkeleton(skeleton: Skeleton): Mesh;
  22059. /**
  22060. * 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
  22061. * @param meshes defines the list of meshes to scan
  22062. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22063. */
  22064. static MinMax(meshes: AbstractMesh[]): {
  22065. min: Vector3;
  22066. max: Vector3;
  22067. };
  22068. /**
  22069. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22070. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22071. * @returns a vector3
  22072. */
  22073. static Center(meshesOrMinMaxVector: {
  22074. min: Vector3;
  22075. max: Vector3;
  22076. } | AbstractMesh[]): Vector3;
  22077. /**
  22078. * Merge the array of meshes into a single mesh for performance reasons.
  22079. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22080. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22081. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22082. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22083. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22084. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22085. * @returns a new mesh
  22086. */
  22087. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22088. /** @hidden */
  22089. addInstance(instance: InstancedMesh): void;
  22090. /** @hidden */
  22091. removeInstance(instance: InstancedMesh): void;
  22092. }
  22093. }
  22094. declare module "babylonjs/Materials/material" {
  22095. import { IAnimatable } from "babylonjs/Misc/tools";
  22096. import { SmartArray } from "babylonjs/Misc/smartArray";
  22097. import { Observable } from "babylonjs/Misc/observable";
  22098. import { Nullable } from "babylonjs/types";
  22099. import { Scene } from "babylonjs/scene";
  22100. import { Matrix } from "babylonjs/Maths/math";
  22101. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22103. import { Mesh } from "babylonjs/Meshes/mesh";
  22104. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22105. import { Effect } from "babylonjs/Materials/effect";
  22106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22107. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22108. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22109. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22110. import { Animation } from "babylonjs/Animations/animation";
  22111. /**
  22112. * Base class for the main features of a material in Babylon.js
  22113. */
  22114. export class Material implements IAnimatable {
  22115. /**
  22116. * Returns the triangle fill mode
  22117. */
  22118. static readonly TriangleFillMode: number;
  22119. /**
  22120. * Returns the wireframe mode
  22121. */
  22122. static readonly WireFrameFillMode: number;
  22123. /**
  22124. * Returns the point fill mode
  22125. */
  22126. static readonly PointFillMode: number;
  22127. /**
  22128. * Returns the point list draw mode
  22129. */
  22130. static readonly PointListDrawMode: number;
  22131. /**
  22132. * Returns the line list draw mode
  22133. */
  22134. static readonly LineListDrawMode: number;
  22135. /**
  22136. * Returns the line loop draw mode
  22137. */
  22138. static readonly LineLoopDrawMode: number;
  22139. /**
  22140. * Returns the line strip draw mode
  22141. */
  22142. static readonly LineStripDrawMode: number;
  22143. /**
  22144. * Returns the triangle strip draw mode
  22145. */
  22146. static readonly TriangleStripDrawMode: number;
  22147. /**
  22148. * Returns the triangle fan draw mode
  22149. */
  22150. static readonly TriangleFanDrawMode: number;
  22151. /**
  22152. * Stores the clock-wise side orientation
  22153. */
  22154. static readonly ClockWiseSideOrientation: number;
  22155. /**
  22156. * Stores the counter clock-wise side orientation
  22157. */
  22158. static readonly CounterClockWiseSideOrientation: number;
  22159. /**
  22160. * The dirty texture flag value
  22161. */
  22162. static readonly TextureDirtyFlag: number;
  22163. /**
  22164. * The dirty light flag value
  22165. */
  22166. static readonly LightDirtyFlag: number;
  22167. /**
  22168. * The dirty fresnel flag value
  22169. */
  22170. static readonly FresnelDirtyFlag: number;
  22171. /**
  22172. * The dirty attribute flag value
  22173. */
  22174. static readonly AttributesDirtyFlag: number;
  22175. /**
  22176. * The dirty misc flag value
  22177. */
  22178. static readonly MiscDirtyFlag: number;
  22179. /**
  22180. * The all dirty flag value
  22181. */
  22182. static readonly AllDirtyFlag: number;
  22183. /**
  22184. * The ID of the material
  22185. */
  22186. id: string;
  22187. /**
  22188. * Gets or sets the unique id of the material
  22189. */
  22190. uniqueId: number;
  22191. /**
  22192. * The name of the material
  22193. */
  22194. name: string;
  22195. /**
  22196. * Gets or sets user defined metadata
  22197. */
  22198. metadata: any;
  22199. /**
  22200. * For internal use only. Please do not use.
  22201. */
  22202. reservedDataStore: any;
  22203. /**
  22204. * Specifies if the ready state should be checked on each call
  22205. */
  22206. checkReadyOnEveryCall: boolean;
  22207. /**
  22208. * Specifies if the ready state should be checked once
  22209. */
  22210. checkReadyOnlyOnce: boolean;
  22211. /**
  22212. * The state of the material
  22213. */
  22214. state: string;
  22215. /**
  22216. * The alpha value of the material
  22217. */
  22218. protected _alpha: number;
  22219. /**
  22220. * List of inspectable custom properties (used by the Inspector)
  22221. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22222. */
  22223. inspectableCustomProperties: IInspectable[];
  22224. /**
  22225. * Sets the alpha value of the material
  22226. */
  22227. /**
  22228. * Gets the alpha value of the material
  22229. */
  22230. alpha: number;
  22231. /**
  22232. * Specifies if back face culling is enabled
  22233. */
  22234. protected _backFaceCulling: boolean;
  22235. /**
  22236. * Sets the back-face culling state
  22237. */
  22238. /**
  22239. * Gets the back-face culling state
  22240. */
  22241. backFaceCulling: boolean;
  22242. /**
  22243. * Stores the value for side orientation
  22244. */
  22245. sideOrientation: number;
  22246. /**
  22247. * Callback triggered when the material is compiled
  22248. */
  22249. onCompiled: (effect: Effect) => void;
  22250. /**
  22251. * Callback triggered when an error occurs
  22252. */
  22253. onError: (effect: Effect, errors: string) => void;
  22254. /**
  22255. * Callback triggered to get the render target textures
  22256. */
  22257. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22258. /**
  22259. * Gets a boolean indicating that current material needs to register RTT
  22260. */
  22261. readonly hasRenderTargetTextures: boolean;
  22262. /**
  22263. * Specifies if the material should be serialized
  22264. */
  22265. doNotSerialize: boolean;
  22266. /**
  22267. * @hidden
  22268. */
  22269. _storeEffectOnSubMeshes: boolean;
  22270. /**
  22271. * Stores the animations for the material
  22272. */
  22273. animations: Array<Animation>;
  22274. /**
  22275. * An event triggered when the material is disposed
  22276. */
  22277. onDisposeObservable: Observable<Material>;
  22278. /**
  22279. * An observer which watches for dispose events
  22280. */
  22281. private _onDisposeObserver;
  22282. private _onUnBindObservable;
  22283. /**
  22284. * Called during a dispose event
  22285. */
  22286. onDispose: () => void;
  22287. private _onBindObservable;
  22288. /**
  22289. * An event triggered when the material is bound
  22290. */
  22291. readonly onBindObservable: Observable<AbstractMesh>;
  22292. /**
  22293. * An observer which watches for bind events
  22294. */
  22295. private _onBindObserver;
  22296. /**
  22297. * Called during a bind event
  22298. */
  22299. onBind: (Mesh: AbstractMesh) => void;
  22300. /**
  22301. * An event triggered when the material is unbound
  22302. */
  22303. readonly onUnBindObservable: Observable<Material>;
  22304. /**
  22305. * Stores the value of the alpha mode
  22306. */
  22307. private _alphaMode;
  22308. /**
  22309. * Sets the value of the alpha mode.
  22310. *
  22311. * | Value | Type | Description |
  22312. * | --- | --- | --- |
  22313. * | 0 | ALPHA_DISABLE | |
  22314. * | 1 | ALPHA_ADD | |
  22315. * | 2 | ALPHA_COMBINE | |
  22316. * | 3 | ALPHA_SUBTRACT | |
  22317. * | 4 | ALPHA_MULTIPLY | |
  22318. * | 5 | ALPHA_MAXIMIZED | |
  22319. * | 6 | ALPHA_ONEONE | |
  22320. * | 7 | ALPHA_PREMULTIPLIED | |
  22321. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22322. * | 9 | ALPHA_INTERPOLATE | |
  22323. * | 10 | ALPHA_SCREENMODE | |
  22324. *
  22325. */
  22326. /**
  22327. * Gets the value of the alpha mode
  22328. */
  22329. alphaMode: number;
  22330. /**
  22331. * Stores the state of the need depth pre-pass value
  22332. */
  22333. private _needDepthPrePass;
  22334. /**
  22335. * Sets the need depth pre-pass value
  22336. */
  22337. /**
  22338. * Gets the depth pre-pass value
  22339. */
  22340. needDepthPrePass: boolean;
  22341. /**
  22342. * Specifies if depth writing should be disabled
  22343. */
  22344. disableDepthWrite: boolean;
  22345. /**
  22346. * Specifies if depth writing should be forced
  22347. */
  22348. forceDepthWrite: boolean;
  22349. /**
  22350. * Specifies if there should be a separate pass for culling
  22351. */
  22352. separateCullingPass: boolean;
  22353. /**
  22354. * Stores the state specifing if fog should be enabled
  22355. */
  22356. private _fogEnabled;
  22357. /**
  22358. * Sets the state for enabling fog
  22359. */
  22360. /**
  22361. * Gets the value of the fog enabled state
  22362. */
  22363. fogEnabled: boolean;
  22364. /**
  22365. * Stores the size of points
  22366. */
  22367. pointSize: number;
  22368. /**
  22369. * Stores the z offset value
  22370. */
  22371. zOffset: number;
  22372. /**
  22373. * Gets a value specifying if wireframe mode is enabled
  22374. */
  22375. /**
  22376. * Sets the state of wireframe mode
  22377. */
  22378. wireframe: boolean;
  22379. /**
  22380. * Gets the value specifying if point clouds are enabled
  22381. */
  22382. /**
  22383. * Sets the state of point cloud mode
  22384. */
  22385. pointsCloud: boolean;
  22386. /**
  22387. * Gets the material fill mode
  22388. */
  22389. /**
  22390. * Sets the material fill mode
  22391. */
  22392. fillMode: number;
  22393. /**
  22394. * @hidden
  22395. * Stores the effects for the material
  22396. */
  22397. _effect: Nullable<Effect>;
  22398. /**
  22399. * @hidden
  22400. * Specifies if the material was previously ready
  22401. */
  22402. _wasPreviouslyReady: boolean;
  22403. /**
  22404. * Specifies if uniform buffers should be used
  22405. */
  22406. private _useUBO;
  22407. /**
  22408. * Stores a reference to the scene
  22409. */
  22410. private _scene;
  22411. /**
  22412. * Stores the fill mode state
  22413. */
  22414. private _fillMode;
  22415. /**
  22416. * Specifies if the depth write state should be cached
  22417. */
  22418. private _cachedDepthWriteState;
  22419. /**
  22420. * Stores the uniform buffer
  22421. */
  22422. protected _uniformBuffer: UniformBuffer;
  22423. /** @hidden */
  22424. _indexInSceneMaterialArray: number;
  22425. /** @hidden */
  22426. meshMap: Nullable<{
  22427. [id: string]: AbstractMesh | undefined;
  22428. }>;
  22429. /**
  22430. * Creates a material instance
  22431. * @param name defines the name of the material
  22432. * @param scene defines the scene to reference
  22433. * @param doNotAdd specifies if the material should be added to the scene
  22434. */
  22435. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22436. /**
  22437. * Returns a string representation of the current material
  22438. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22439. * @returns a string with material information
  22440. */
  22441. toString(fullDetails?: boolean): string;
  22442. /**
  22443. * Gets the class name of the material
  22444. * @returns a string with the class name of the material
  22445. */
  22446. getClassName(): string;
  22447. /**
  22448. * Specifies if updates for the material been locked
  22449. */
  22450. readonly isFrozen: boolean;
  22451. /**
  22452. * Locks updates for the material
  22453. */
  22454. freeze(): void;
  22455. /**
  22456. * Unlocks updates for the material
  22457. */
  22458. unfreeze(): void;
  22459. /**
  22460. * Specifies if the material is ready to be used
  22461. * @param mesh defines the mesh to check
  22462. * @param useInstances specifies if instances should be used
  22463. * @returns a boolean indicating if the material is ready to be used
  22464. */
  22465. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22466. /**
  22467. * Specifies that the submesh is ready to be used
  22468. * @param mesh defines the mesh to check
  22469. * @param subMesh defines which submesh to check
  22470. * @param useInstances specifies that instances should be used
  22471. * @returns a boolean indicating that the submesh is ready or not
  22472. */
  22473. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22474. /**
  22475. * Returns the material effect
  22476. * @returns the effect associated with the material
  22477. */
  22478. getEffect(): Nullable<Effect>;
  22479. /**
  22480. * Returns the current scene
  22481. * @returns a Scene
  22482. */
  22483. getScene(): Scene;
  22484. /**
  22485. * Specifies if the material will require alpha blending
  22486. * @returns a boolean specifying if alpha blending is needed
  22487. */
  22488. needAlphaBlending(): boolean;
  22489. /**
  22490. * Specifies if the mesh will require alpha blending
  22491. * @param mesh defines the mesh to check
  22492. * @returns a boolean specifying if alpha blending is needed for the mesh
  22493. */
  22494. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22495. /**
  22496. * Specifies if this material should be rendered in alpha test mode
  22497. * @returns a boolean specifying if an alpha test is needed.
  22498. */
  22499. needAlphaTesting(): boolean;
  22500. /**
  22501. * Gets the texture used for the alpha test
  22502. * @returns the texture to use for alpha testing
  22503. */
  22504. getAlphaTestTexture(): Nullable<BaseTexture>;
  22505. /**
  22506. * Marks the material to indicate that it needs to be re-calculated
  22507. */
  22508. markDirty(): void;
  22509. /** @hidden */
  22510. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22511. /**
  22512. * Binds the material to the mesh
  22513. * @param world defines the world transformation matrix
  22514. * @param mesh defines the mesh to bind the material to
  22515. */
  22516. bind(world: Matrix, mesh?: Mesh): void;
  22517. /**
  22518. * Binds the submesh to the material
  22519. * @param world defines the world transformation matrix
  22520. * @param mesh defines the mesh containing the submesh
  22521. * @param subMesh defines the submesh to bind the material to
  22522. */
  22523. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22524. /**
  22525. * Binds the world matrix to the material
  22526. * @param world defines the world transformation matrix
  22527. */
  22528. bindOnlyWorldMatrix(world: Matrix): void;
  22529. /**
  22530. * Binds the scene's uniform buffer to the effect.
  22531. * @param effect defines the effect to bind to the scene uniform buffer
  22532. * @param sceneUbo defines the uniform buffer storing scene data
  22533. */
  22534. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22535. /**
  22536. * Binds the view matrix to the effect
  22537. * @param effect defines the effect to bind the view matrix to
  22538. */
  22539. bindView(effect: Effect): void;
  22540. /**
  22541. * Binds the view projection matrix to the effect
  22542. * @param effect defines the effect to bind the view projection matrix to
  22543. */
  22544. bindViewProjection(effect: Effect): void;
  22545. /**
  22546. * Specifies if material alpha testing should be turned on for the mesh
  22547. * @param mesh defines the mesh to check
  22548. */
  22549. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22550. /**
  22551. * Processes to execute after binding the material to a mesh
  22552. * @param mesh defines the rendered mesh
  22553. */
  22554. protected _afterBind(mesh?: Mesh): void;
  22555. /**
  22556. * Unbinds the material from the mesh
  22557. */
  22558. unbind(): void;
  22559. /**
  22560. * Gets the active textures from the material
  22561. * @returns an array of textures
  22562. */
  22563. getActiveTextures(): BaseTexture[];
  22564. /**
  22565. * Specifies if the material uses a texture
  22566. * @param texture defines the texture to check against the material
  22567. * @returns a boolean specifying if the material uses the texture
  22568. */
  22569. hasTexture(texture: BaseTexture): boolean;
  22570. /**
  22571. * Makes a duplicate of the material, and gives it a new name
  22572. * @param name defines the new name for the duplicated material
  22573. * @returns the cloned material
  22574. */
  22575. clone(name: string): Nullable<Material>;
  22576. /**
  22577. * Gets the meshes bound to the material
  22578. * @returns an array of meshes bound to the material
  22579. */
  22580. getBindedMeshes(): AbstractMesh[];
  22581. /**
  22582. * Force shader compilation
  22583. * @param mesh defines the mesh associated with this material
  22584. * @param onCompiled defines a function to execute once the material is compiled
  22585. * @param options defines the options to configure the compilation
  22586. */
  22587. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22588. clipPlane: boolean;
  22589. }>): void;
  22590. /**
  22591. * Force shader compilation
  22592. * @param mesh defines the mesh that will use this material
  22593. * @param options defines additional options for compiling the shaders
  22594. * @returns a promise that resolves when the compilation completes
  22595. */
  22596. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22597. clipPlane: boolean;
  22598. }>): Promise<void>;
  22599. private static readonly _ImageProcessingDirtyCallBack;
  22600. private static readonly _TextureDirtyCallBack;
  22601. private static readonly _FresnelDirtyCallBack;
  22602. private static readonly _MiscDirtyCallBack;
  22603. private static readonly _LightsDirtyCallBack;
  22604. private static readonly _AttributeDirtyCallBack;
  22605. private static _FresnelAndMiscDirtyCallBack;
  22606. private static _TextureAndMiscDirtyCallBack;
  22607. private static readonly _DirtyCallbackArray;
  22608. private static readonly _RunDirtyCallBacks;
  22609. /**
  22610. * Marks a define in the material to indicate that it needs to be re-computed
  22611. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22612. */
  22613. markAsDirty(flag: number): void;
  22614. /**
  22615. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22616. * @param func defines a function which checks material defines against the submeshes
  22617. */
  22618. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22619. /**
  22620. * Indicates that image processing needs to be re-calculated for all submeshes
  22621. */
  22622. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22623. /**
  22624. * Indicates that textures need to be re-calculated for all submeshes
  22625. */
  22626. protected _markAllSubMeshesAsTexturesDirty(): void;
  22627. /**
  22628. * Indicates that fresnel needs to be re-calculated for all submeshes
  22629. */
  22630. protected _markAllSubMeshesAsFresnelDirty(): void;
  22631. /**
  22632. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22633. */
  22634. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22635. /**
  22636. * Indicates that lights need to be re-calculated for all submeshes
  22637. */
  22638. protected _markAllSubMeshesAsLightsDirty(): void;
  22639. /**
  22640. * Indicates that attributes need to be re-calculated for all submeshes
  22641. */
  22642. protected _markAllSubMeshesAsAttributesDirty(): void;
  22643. /**
  22644. * Indicates that misc needs to be re-calculated for all submeshes
  22645. */
  22646. protected _markAllSubMeshesAsMiscDirty(): void;
  22647. /**
  22648. * Indicates that textures and misc need to be re-calculated for all submeshes
  22649. */
  22650. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22651. /**
  22652. * Disposes the material
  22653. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22654. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22655. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22656. */
  22657. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22658. /** @hidden */
  22659. private releaseVertexArrayObject;
  22660. /**
  22661. * Serializes this material
  22662. * @returns the serialized material object
  22663. */
  22664. serialize(): any;
  22665. /**
  22666. * Creates a material from parsed material data
  22667. * @param parsedMaterial defines parsed material data
  22668. * @param scene defines the hosting scene
  22669. * @param rootUrl defines the root URL to use to load textures
  22670. * @returns a new material
  22671. */
  22672. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22673. }
  22674. }
  22675. declare module "babylonjs/Meshes/subMesh" {
  22676. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22677. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22678. import { Engine } from "babylonjs/Engines/engine";
  22679. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22680. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22681. import { Effect } from "babylonjs/Materials/effect";
  22682. import { Collider } from "babylonjs/Collisions/collider";
  22683. import { Material } from "babylonjs/Materials/material";
  22684. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22686. import { Mesh } from "babylonjs/Meshes/mesh";
  22687. import { Ray } from "babylonjs/Culling/ray";
  22688. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22689. /**
  22690. * Base class for submeshes
  22691. */
  22692. export class BaseSubMesh {
  22693. /** @hidden */
  22694. _materialDefines: Nullable<MaterialDefines>;
  22695. /** @hidden */
  22696. _materialEffect: Nullable<Effect>;
  22697. /**
  22698. * Gets associated effect
  22699. */
  22700. readonly effect: Nullable<Effect>;
  22701. /**
  22702. * Sets associated effect (effect used to render this submesh)
  22703. * @param effect defines the effect to associate with
  22704. * @param defines defines the set of defines used to compile this effect
  22705. */
  22706. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22707. }
  22708. /**
  22709. * Defines a subdivision inside a mesh
  22710. */
  22711. export class SubMesh extends BaseSubMesh implements ICullable {
  22712. /** the material index to use */
  22713. materialIndex: number;
  22714. /** vertex index start */
  22715. verticesStart: number;
  22716. /** vertices count */
  22717. verticesCount: number;
  22718. /** index start */
  22719. indexStart: number;
  22720. /** indices count */
  22721. indexCount: number;
  22722. /** @hidden */
  22723. _linesIndexCount: number;
  22724. private _mesh;
  22725. private _renderingMesh;
  22726. private _boundingInfo;
  22727. private _linesIndexBuffer;
  22728. /** @hidden */
  22729. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22730. /** @hidden */
  22731. _trianglePlanes: Plane[];
  22732. /** @hidden */
  22733. _lastColliderTransformMatrix: Matrix;
  22734. /** @hidden */
  22735. _renderId: number;
  22736. /** @hidden */
  22737. _alphaIndex: number;
  22738. /** @hidden */
  22739. _distanceToCamera: number;
  22740. /** @hidden */
  22741. _id: number;
  22742. private _currentMaterial;
  22743. /**
  22744. * Add a new submesh to a mesh
  22745. * @param materialIndex defines the material index to use
  22746. * @param verticesStart defines vertex index start
  22747. * @param verticesCount defines vertices count
  22748. * @param indexStart defines index start
  22749. * @param indexCount defines indices count
  22750. * @param mesh defines the parent mesh
  22751. * @param renderingMesh defines an optional rendering mesh
  22752. * @param createBoundingBox defines if bounding box should be created for this submesh
  22753. * @returns the new submesh
  22754. */
  22755. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22756. /**
  22757. * Creates a new submesh
  22758. * @param materialIndex defines the material index to use
  22759. * @param verticesStart defines vertex index start
  22760. * @param verticesCount defines vertices count
  22761. * @param indexStart defines index start
  22762. * @param indexCount defines indices count
  22763. * @param mesh defines the parent mesh
  22764. * @param renderingMesh defines an optional rendering mesh
  22765. * @param createBoundingBox defines if bounding box should be created for this submesh
  22766. */
  22767. constructor(
  22768. /** the material index to use */
  22769. materialIndex: number,
  22770. /** vertex index start */
  22771. verticesStart: number,
  22772. /** vertices count */
  22773. verticesCount: number,
  22774. /** index start */
  22775. indexStart: number,
  22776. /** indices count */
  22777. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22778. /**
  22779. * Returns true if this submesh covers the entire parent mesh
  22780. * @ignorenaming
  22781. */
  22782. readonly IsGlobal: boolean;
  22783. /**
  22784. * Returns the submesh BoudingInfo object
  22785. * @returns current bounding info (or mesh's one if the submesh is global)
  22786. */
  22787. getBoundingInfo(): BoundingInfo;
  22788. /**
  22789. * Sets the submesh BoundingInfo
  22790. * @param boundingInfo defines the new bounding info to use
  22791. * @returns the SubMesh
  22792. */
  22793. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22794. /**
  22795. * Returns the mesh of the current submesh
  22796. * @return the parent mesh
  22797. */
  22798. getMesh(): AbstractMesh;
  22799. /**
  22800. * Returns the rendering mesh of the submesh
  22801. * @returns the rendering mesh (could be different from parent mesh)
  22802. */
  22803. getRenderingMesh(): Mesh;
  22804. /**
  22805. * Returns the submesh material
  22806. * @returns null or the current material
  22807. */
  22808. getMaterial(): Nullable<Material>;
  22809. /**
  22810. * Sets a new updated BoundingInfo object to the submesh
  22811. * @returns the SubMesh
  22812. */
  22813. refreshBoundingInfo(): SubMesh;
  22814. /** @hidden */
  22815. _checkCollision(collider: Collider): boolean;
  22816. /**
  22817. * Updates the submesh BoundingInfo
  22818. * @param world defines the world matrix to use to update the bounding info
  22819. * @returns the submesh
  22820. */
  22821. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22822. /**
  22823. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22824. * @param frustumPlanes defines the frustum planes
  22825. * @returns true if the submesh is intersecting with the frustum
  22826. */
  22827. isInFrustum(frustumPlanes: Plane[]): boolean;
  22828. /**
  22829. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22830. * @param frustumPlanes defines the frustum planes
  22831. * @returns true if the submesh is inside the frustum
  22832. */
  22833. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22834. /**
  22835. * Renders the submesh
  22836. * @param enableAlphaMode defines if alpha needs to be used
  22837. * @returns the submesh
  22838. */
  22839. render(enableAlphaMode: boolean): SubMesh;
  22840. /**
  22841. * @hidden
  22842. */
  22843. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22844. /**
  22845. * Checks if the submesh intersects with a ray
  22846. * @param ray defines the ray to test
  22847. * @returns true is the passed ray intersects the submesh bounding box
  22848. */
  22849. canIntersects(ray: Ray): boolean;
  22850. /**
  22851. * Intersects current submesh with a ray
  22852. * @param ray defines the ray to test
  22853. * @param positions defines mesh's positions array
  22854. * @param indices defines mesh's indices array
  22855. * @param fastCheck defines if only bounding info should be used
  22856. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22857. * @returns intersection info or null if no intersection
  22858. */
  22859. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22860. /** @hidden */
  22861. private _intersectLines;
  22862. /** @hidden */
  22863. private _intersectTriangles;
  22864. /** @hidden */
  22865. _rebuild(): void;
  22866. /**
  22867. * Creates a new submesh from the passed mesh
  22868. * @param newMesh defines the new hosting mesh
  22869. * @param newRenderingMesh defines an optional rendering mesh
  22870. * @returns the new submesh
  22871. */
  22872. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22873. /**
  22874. * Release associated resources
  22875. */
  22876. dispose(): void;
  22877. /**
  22878. * Gets the class name
  22879. * @returns the string "SubMesh".
  22880. */
  22881. getClassName(): string;
  22882. /**
  22883. * Creates a new submesh from indices data
  22884. * @param materialIndex the index of the main mesh material
  22885. * @param startIndex the index where to start the copy in the mesh indices array
  22886. * @param indexCount the number of indices to copy then from the startIndex
  22887. * @param mesh the main mesh to create the submesh from
  22888. * @param renderingMesh the optional rendering mesh
  22889. * @returns a new submesh
  22890. */
  22891. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22892. }
  22893. }
  22894. declare module "babylonjs/Meshes/geometry" {
  22895. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22896. import { Scene } from "babylonjs/scene";
  22897. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22898. import { Engine } from "babylonjs/Engines/engine";
  22899. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22900. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22901. import { Effect } from "babylonjs/Materials/effect";
  22902. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22903. import { Mesh } from "babylonjs/Meshes/mesh";
  22904. /**
  22905. * Class used to store geometry data (vertex buffers + index buffer)
  22906. */
  22907. export class Geometry implements IGetSetVerticesData {
  22908. /**
  22909. * Gets or sets the ID of the geometry
  22910. */
  22911. id: string;
  22912. /**
  22913. * Gets or sets the unique ID of the geometry
  22914. */
  22915. uniqueId: number;
  22916. /**
  22917. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22918. */
  22919. delayLoadState: number;
  22920. /**
  22921. * Gets the file containing the data to load when running in delay load state
  22922. */
  22923. delayLoadingFile: Nullable<string>;
  22924. /**
  22925. * Callback called when the geometry is updated
  22926. */
  22927. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22928. private _scene;
  22929. private _engine;
  22930. private _meshes;
  22931. private _totalVertices;
  22932. /** @hidden */
  22933. _indices: IndicesArray;
  22934. /** @hidden */
  22935. _vertexBuffers: {
  22936. [key: string]: VertexBuffer;
  22937. };
  22938. private _isDisposed;
  22939. private _extend;
  22940. private _boundingBias;
  22941. /** @hidden */
  22942. _delayInfo: Array<string>;
  22943. private _indexBuffer;
  22944. private _indexBufferIsUpdatable;
  22945. /** @hidden */
  22946. _boundingInfo: Nullable<BoundingInfo>;
  22947. /** @hidden */
  22948. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22949. /** @hidden */
  22950. _softwareSkinningFrameId: number;
  22951. private _vertexArrayObjects;
  22952. private _updatable;
  22953. /** @hidden */
  22954. _positions: Nullable<Vector3[]>;
  22955. /**
  22956. * 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
  22957. */
  22958. /**
  22959. * 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
  22960. */
  22961. boundingBias: Vector2;
  22962. /**
  22963. * Static function used to attach a new empty geometry to a mesh
  22964. * @param mesh defines the mesh to attach the geometry to
  22965. * @returns the new Geometry
  22966. */
  22967. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22968. /**
  22969. * Creates a new geometry
  22970. * @param id defines the unique ID
  22971. * @param scene defines the hosting scene
  22972. * @param vertexData defines the VertexData used to get geometry data
  22973. * @param updatable defines if geometry must be updatable (false by default)
  22974. * @param mesh defines the mesh that will be associated with the geometry
  22975. */
  22976. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22977. /**
  22978. * Gets the current extend of the geometry
  22979. */
  22980. readonly extend: {
  22981. minimum: Vector3;
  22982. maximum: Vector3;
  22983. };
  22984. /**
  22985. * Gets the hosting scene
  22986. * @returns the hosting Scene
  22987. */
  22988. getScene(): Scene;
  22989. /**
  22990. * Gets the hosting engine
  22991. * @returns the hosting Engine
  22992. */
  22993. getEngine(): Engine;
  22994. /**
  22995. * Defines if the geometry is ready to use
  22996. * @returns true if the geometry is ready to be used
  22997. */
  22998. isReady(): boolean;
  22999. /**
  23000. * Gets a value indicating that the geometry should not be serialized
  23001. */
  23002. readonly doNotSerialize: boolean;
  23003. /** @hidden */
  23004. _rebuild(): void;
  23005. /**
  23006. * Affects all geometry data in one call
  23007. * @param vertexData defines the geometry data
  23008. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23009. */
  23010. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23011. /**
  23012. * Set specific vertex data
  23013. * @param kind defines the data kind (Position, normal, etc...)
  23014. * @param data defines the vertex data to use
  23015. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23016. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23017. */
  23018. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23019. /**
  23020. * Removes a specific vertex data
  23021. * @param kind defines the data kind (Position, normal, etc...)
  23022. */
  23023. removeVerticesData(kind: string): void;
  23024. /**
  23025. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23026. * @param buffer defines the vertex buffer to use
  23027. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23028. */
  23029. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23030. /**
  23031. * Update a specific vertex buffer
  23032. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23033. * It will do nothing if the buffer is not updatable
  23034. * @param kind defines the data kind (Position, normal, etc...)
  23035. * @param data defines the data to use
  23036. * @param offset defines the offset in the target buffer where to store the data
  23037. * @param useBytes set to true if the offset is in bytes
  23038. */
  23039. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23040. /**
  23041. * Update a specific vertex buffer
  23042. * This function will create a new buffer if the current one is not updatable
  23043. * @param kind defines the data kind (Position, normal, etc...)
  23044. * @param data defines the data to use
  23045. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23046. */
  23047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23048. private _updateBoundingInfo;
  23049. /** @hidden */
  23050. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23051. /**
  23052. * Gets total number of vertices
  23053. * @returns the total number of vertices
  23054. */
  23055. getTotalVertices(): number;
  23056. /**
  23057. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23058. * @param kind defines the data kind (Position, normal, etc...)
  23059. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23060. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23061. * @returns a float array containing vertex data
  23062. */
  23063. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23064. /**
  23065. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23066. * @param kind defines the data kind (Position, normal, etc...)
  23067. * @returns true if the vertex buffer with the specified kind is updatable
  23068. */
  23069. isVertexBufferUpdatable(kind: string): boolean;
  23070. /**
  23071. * Gets a specific vertex buffer
  23072. * @param kind defines the data kind (Position, normal, etc...)
  23073. * @returns a VertexBuffer
  23074. */
  23075. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23076. /**
  23077. * Returns all vertex buffers
  23078. * @return an object holding all vertex buffers indexed by kind
  23079. */
  23080. getVertexBuffers(): Nullable<{
  23081. [key: string]: VertexBuffer;
  23082. }>;
  23083. /**
  23084. * Gets a boolean indicating if specific vertex buffer is present
  23085. * @param kind defines the data kind (Position, normal, etc...)
  23086. * @returns true if data is present
  23087. */
  23088. isVerticesDataPresent(kind: string): boolean;
  23089. /**
  23090. * Gets a list of all attached data kinds (Position, normal, etc...)
  23091. * @returns a list of string containing all kinds
  23092. */
  23093. getVerticesDataKinds(): string[];
  23094. /**
  23095. * Update index buffer
  23096. * @param indices defines the indices to store in the index buffer
  23097. * @param offset defines the offset in the target buffer where to store the data
  23098. * @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)
  23099. */
  23100. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23101. /**
  23102. * Creates a new index buffer
  23103. * @param indices defines the indices to store in the index buffer
  23104. * @param totalVertices defines the total number of vertices (could be null)
  23105. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23106. */
  23107. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23108. /**
  23109. * Return the total number of indices
  23110. * @returns the total number of indices
  23111. */
  23112. getTotalIndices(): number;
  23113. /**
  23114. * Gets the index buffer array
  23115. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23117. * @returns the index buffer array
  23118. */
  23119. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23120. /**
  23121. * Gets the index buffer
  23122. * @return the index buffer
  23123. */
  23124. getIndexBuffer(): Nullable<WebGLBuffer>;
  23125. /** @hidden */
  23126. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23127. /**
  23128. * Release the associated resources for a specific mesh
  23129. * @param mesh defines the source mesh
  23130. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23131. */
  23132. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23133. /**
  23134. * Apply current geometry to a given mesh
  23135. * @param mesh defines the mesh to apply geometry to
  23136. */
  23137. applyToMesh(mesh: Mesh): void;
  23138. private _updateExtend;
  23139. private _applyToMesh;
  23140. private notifyUpdate;
  23141. /**
  23142. * Load the geometry if it was flagged as delay loaded
  23143. * @param scene defines the hosting scene
  23144. * @param onLoaded defines a callback called when the geometry is loaded
  23145. */
  23146. load(scene: Scene, onLoaded?: () => void): void;
  23147. private _queueLoad;
  23148. /**
  23149. * Invert the geometry to move from a right handed system to a left handed one.
  23150. */
  23151. toLeftHanded(): void;
  23152. /** @hidden */
  23153. _resetPointsArrayCache(): void;
  23154. /** @hidden */
  23155. _generatePointsArray(): boolean;
  23156. /**
  23157. * Gets a value indicating if the geometry is disposed
  23158. * @returns true if the geometry was disposed
  23159. */
  23160. isDisposed(): boolean;
  23161. private _disposeVertexArrayObjects;
  23162. /**
  23163. * Free all associated resources
  23164. */
  23165. dispose(): void;
  23166. /**
  23167. * Clone the current geometry into a new geometry
  23168. * @param id defines the unique ID of the new geometry
  23169. * @returns a new geometry object
  23170. */
  23171. copy(id: string): Geometry;
  23172. /**
  23173. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23174. * @return a JSON representation of the current geometry data (without the vertices data)
  23175. */
  23176. serialize(): any;
  23177. private toNumberArray;
  23178. /**
  23179. * Serialize all vertices data into a JSON oject
  23180. * @returns a JSON representation of the current geometry data
  23181. */
  23182. serializeVerticeData(): any;
  23183. /**
  23184. * Extracts a clone of a mesh geometry
  23185. * @param mesh defines the source mesh
  23186. * @param id defines the unique ID of the new geometry object
  23187. * @returns the new geometry object
  23188. */
  23189. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23190. /**
  23191. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23192. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23193. * Be aware Math.random() could cause collisions, but:
  23194. * "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"
  23195. * @returns a string containing a new GUID
  23196. */
  23197. static RandomId(): string;
  23198. /** @hidden */
  23199. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23200. private static _CleanMatricesWeights;
  23201. /**
  23202. * Create a new geometry from persisted data (Using .babylon file format)
  23203. * @param parsedVertexData defines the persisted data
  23204. * @param scene defines the hosting scene
  23205. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23206. * @returns the new geometry object
  23207. */
  23208. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23209. }
  23210. }
  23211. declare module "babylonjs/Meshes/mesh.vertexData" {
  23212. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23213. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23214. import { Geometry } from "babylonjs/Meshes/geometry";
  23215. import { Mesh } from "babylonjs/Meshes/mesh";
  23216. /**
  23217. * Define an interface for all classes that will get and set the data on vertices
  23218. */
  23219. export interface IGetSetVerticesData {
  23220. /**
  23221. * Gets a boolean indicating if specific vertex data is present
  23222. * @param kind defines the vertex data kind to use
  23223. * @returns true is data kind is present
  23224. */
  23225. isVerticesDataPresent(kind: string): boolean;
  23226. /**
  23227. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23228. * @param kind defines the data kind (Position, normal, etc...)
  23229. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23230. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23231. * @returns a float array containing vertex data
  23232. */
  23233. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23234. /**
  23235. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23236. * @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.
  23237. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23238. * @returns the indices array or an empty array if the mesh has no geometry
  23239. */
  23240. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23241. /**
  23242. * Set specific vertex data
  23243. * @param kind defines the data kind (Position, normal, etc...)
  23244. * @param data defines the vertex data to use
  23245. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23246. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23247. */
  23248. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23249. /**
  23250. * Update a specific associated vertex buffer
  23251. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23252. * - VertexBuffer.PositionKind
  23253. * - VertexBuffer.UVKind
  23254. * - VertexBuffer.UV2Kind
  23255. * - VertexBuffer.UV3Kind
  23256. * - VertexBuffer.UV4Kind
  23257. * - VertexBuffer.UV5Kind
  23258. * - VertexBuffer.UV6Kind
  23259. * - VertexBuffer.ColorKind
  23260. * - VertexBuffer.MatricesIndicesKind
  23261. * - VertexBuffer.MatricesIndicesExtraKind
  23262. * - VertexBuffer.MatricesWeightsKind
  23263. * - VertexBuffer.MatricesWeightsExtraKind
  23264. * @param data defines the data source
  23265. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23266. * @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)
  23267. */
  23268. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23269. /**
  23270. * Creates a new index buffer
  23271. * @param indices defines the indices to store in the index buffer
  23272. * @param totalVertices defines the total number of vertices (could be null)
  23273. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23274. */
  23275. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23276. }
  23277. /**
  23278. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23279. */
  23280. export class VertexData {
  23281. /**
  23282. * Mesh side orientation : usually the external or front surface
  23283. */
  23284. static readonly FRONTSIDE: number;
  23285. /**
  23286. * Mesh side orientation : usually the internal or back surface
  23287. */
  23288. static readonly BACKSIDE: number;
  23289. /**
  23290. * Mesh side orientation : both internal and external or front and back surfaces
  23291. */
  23292. static readonly DOUBLESIDE: number;
  23293. /**
  23294. * Mesh side orientation : by default, `FRONTSIDE`
  23295. */
  23296. static readonly DEFAULTSIDE: number;
  23297. /**
  23298. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23299. */
  23300. positions: Nullable<FloatArray>;
  23301. /**
  23302. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23303. */
  23304. normals: Nullable<FloatArray>;
  23305. /**
  23306. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23307. */
  23308. tangents: Nullable<FloatArray>;
  23309. /**
  23310. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23311. */
  23312. uvs: Nullable<FloatArray>;
  23313. /**
  23314. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23315. */
  23316. uvs2: Nullable<FloatArray>;
  23317. /**
  23318. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23319. */
  23320. uvs3: Nullable<FloatArray>;
  23321. /**
  23322. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23323. */
  23324. uvs4: Nullable<FloatArray>;
  23325. /**
  23326. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23327. */
  23328. uvs5: Nullable<FloatArray>;
  23329. /**
  23330. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23331. */
  23332. uvs6: Nullable<FloatArray>;
  23333. /**
  23334. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23335. */
  23336. colors: Nullable<FloatArray>;
  23337. /**
  23338. * 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).
  23339. */
  23340. matricesIndices: Nullable<FloatArray>;
  23341. /**
  23342. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23343. */
  23344. matricesWeights: Nullable<FloatArray>;
  23345. /**
  23346. * An array extending the number of possible indices
  23347. */
  23348. matricesIndicesExtra: Nullable<FloatArray>;
  23349. /**
  23350. * An array extending the number of possible weights when the number of indices is extended
  23351. */
  23352. matricesWeightsExtra: Nullable<FloatArray>;
  23353. /**
  23354. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23355. */
  23356. indices: Nullable<IndicesArray>;
  23357. /**
  23358. * Uses the passed data array to set the set the values for the specified kind of data
  23359. * @param data a linear array of floating numbers
  23360. * @param kind the type of data that is being set, eg positions, colors etc
  23361. */
  23362. set(data: FloatArray, kind: string): void;
  23363. /**
  23364. * Associates the vertexData to the passed Mesh.
  23365. * Sets it as updatable or not (default `false`)
  23366. * @param mesh the mesh the vertexData is applied to
  23367. * @param updatable when used and having the value true allows new data to update the vertexData
  23368. * @returns the VertexData
  23369. */
  23370. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23371. /**
  23372. * Associates the vertexData to the passed Geometry.
  23373. * Sets it as updatable or not (default `false`)
  23374. * @param geometry the geometry the vertexData is applied to
  23375. * @param updatable when used and having the value true allows new data to update the vertexData
  23376. * @returns VertexData
  23377. */
  23378. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23379. /**
  23380. * Updates the associated mesh
  23381. * @param mesh the mesh to be updated
  23382. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23383. * @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
  23384. * @returns VertexData
  23385. */
  23386. updateMesh(mesh: Mesh): VertexData;
  23387. /**
  23388. * Updates the associated geometry
  23389. * @param geometry the geometry to be updated
  23390. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23391. * @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
  23392. * @returns VertexData.
  23393. */
  23394. updateGeometry(geometry: Geometry): VertexData;
  23395. private _applyTo;
  23396. private _update;
  23397. /**
  23398. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23399. * @param matrix the transforming matrix
  23400. * @returns the VertexData
  23401. */
  23402. transform(matrix: Matrix): VertexData;
  23403. /**
  23404. * Merges the passed VertexData into the current one
  23405. * @param other the VertexData to be merged into the current one
  23406. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23407. * @returns the modified VertexData
  23408. */
  23409. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23410. private _mergeElement;
  23411. private _validate;
  23412. /**
  23413. * Serializes the VertexData
  23414. * @returns a serialized object
  23415. */
  23416. serialize(): any;
  23417. /**
  23418. * Extracts the vertexData from a mesh
  23419. * @param mesh the mesh from which to extract the VertexData
  23420. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23421. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23422. * @returns the object VertexData associated to the passed mesh
  23423. */
  23424. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23425. /**
  23426. * Extracts the vertexData from the geometry
  23427. * @param geometry the geometry from which to extract the VertexData
  23428. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23429. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23430. * @returns the object VertexData associated to the passed mesh
  23431. */
  23432. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23433. private static _ExtractFrom;
  23434. /**
  23435. * Creates the VertexData for a Ribbon
  23436. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23437. * * pathArray array of paths, each of which an array of successive Vector3
  23438. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23439. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23440. * * 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
  23441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23442. * * 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)
  23443. * * 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)
  23444. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23445. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23446. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23447. * @returns the VertexData of the ribbon
  23448. */
  23449. static CreateRibbon(options: {
  23450. pathArray: Vector3[][];
  23451. closeArray?: boolean;
  23452. closePath?: boolean;
  23453. offset?: number;
  23454. sideOrientation?: number;
  23455. frontUVs?: Vector4;
  23456. backUVs?: Vector4;
  23457. invertUV?: boolean;
  23458. uvs?: Vector2[];
  23459. colors?: Color4[];
  23460. }): VertexData;
  23461. /**
  23462. * Creates the VertexData for a box
  23463. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23464. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23465. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23466. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23467. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23468. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23469. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23471. * * 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)
  23472. * * 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)
  23473. * @returns the VertexData of the box
  23474. */
  23475. static CreateBox(options: {
  23476. size?: number;
  23477. width?: number;
  23478. height?: number;
  23479. depth?: number;
  23480. faceUV?: Vector4[];
  23481. faceColors?: Color4[];
  23482. sideOrientation?: number;
  23483. frontUVs?: Vector4;
  23484. backUVs?: Vector4;
  23485. }): VertexData;
  23486. /**
  23487. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23488. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23489. * * segments sets the number of horizontal strips optional, default 32
  23490. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23491. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23492. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23493. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23494. * * 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
  23495. * * 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
  23496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23497. * * 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)
  23498. * * 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)
  23499. * @returns the VertexData of the ellipsoid
  23500. */
  23501. static CreateSphere(options: {
  23502. segments?: number;
  23503. diameter?: number;
  23504. diameterX?: number;
  23505. diameterY?: number;
  23506. diameterZ?: number;
  23507. arc?: number;
  23508. slice?: number;
  23509. sideOrientation?: number;
  23510. frontUVs?: Vector4;
  23511. backUVs?: Vector4;
  23512. }): VertexData;
  23513. /**
  23514. * Creates the VertexData for a cylinder, cone or prism
  23515. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23516. * * height sets the height (y direction) of the cylinder, optional, default 2
  23517. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23518. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23519. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23520. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23521. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23522. * * 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
  23523. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23524. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23525. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23526. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23528. * * 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)
  23529. * * 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)
  23530. * @returns the VertexData of the cylinder, cone or prism
  23531. */
  23532. static CreateCylinder(options: {
  23533. height?: number;
  23534. diameterTop?: number;
  23535. diameterBottom?: number;
  23536. diameter?: number;
  23537. tessellation?: number;
  23538. subdivisions?: number;
  23539. arc?: number;
  23540. faceColors?: Color4[];
  23541. faceUV?: Vector4[];
  23542. hasRings?: boolean;
  23543. enclose?: boolean;
  23544. sideOrientation?: number;
  23545. frontUVs?: Vector4;
  23546. backUVs?: Vector4;
  23547. }): VertexData;
  23548. /**
  23549. * Creates the VertexData for a torus
  23550. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23551. * * diameter the diameter of the torus, optional default 1
  23552. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23553. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23554. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23555. * * 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)
  23556. * * 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)
  23557. * @returns the VertexData of the torus
  23558. */
  23559. static CreateTorus(options: {
  23560. diameter?: number;
  23561. thickness?: number;
  23562. tessellation?: number;
  23563. sideOrientation?: number;
  23564. frontUVs?: Vector4;
  23565. backUVs?: Vector4;
  23566. }): VertexData;
  23567. /**
  23568. * Creates the VertexData of the LineSystem
  23569. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23570. * - lines an array of lines, each line being an array of successive Vector3
  23571. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23572. * @returns the VertexData of the LineSystem
  23573. */
  23574. static CreateLineSystem(options: {
  23575. lines: Vector3[][];
  23576. colors?: Nullable<Color4[][]>;
  23577. }): VertexData;
  23578. /**
  23579. * Create the VertexData for a DashedLines
  23580. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23581. * - points an array successive Vector3
  23582. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23583. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23584. * - dashNb the intended total number of dashes, optional, default 200
  23585. * @returns the VertexData for the DashedLines
  23586. */
  23587. static CreateDashedLines(options: {
  23588. points: Vector3[];
  23589. dashSize?: number;
  23590. gapSize?: number;
  23591. dashNb?: number;
  23592. }): VertexData;
  23593. /**
  23594. * Creates the VertexData for a Ground
  23595. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23596. * - width the width (x direction) of the ground, optional, default 1
  23597. * - height the height (z direction) of the ground, optional, default 1
  23598. * - subdivisions the number of subdivisions per side, optional, default 1
  23599. * @returns the VertexData of the Ground
  23600. */
  23601. static CreateGround(options: {
  23602. width?: number;
  23603. height?: number;
  23604. subdivisions?: number;
  23605. subdivisionsX?: number;
  23606. subdivisionsY?: number;
  23607. }): VertexData;
  23608. /**
  23609. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23610. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23611. * * xmin the ground minimum X coordinate, optional, default -1
  23612. * * zmin the ground minimum Z coordinate, optional, default -1
  23613. * * xmax the ground maximum X coordinate, optional, default 1
  23614. * * zmax the ground maximum Z coordinate, optional, default 1
  23615. * * 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}
  23616. * * 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}
  23617. * @returns the VertexData of the TiledGround
  23618. */
  23619. static CreateTiledGround(options: {
  23620. xmin: number;
  23621. zmin: number;
  23622. xmax: number;
  23623. zmax: number;
  23624. subdivisions?: {
  23625. w: number;
  23626. h: number;
  23627. };
  23628. precision?: {
  23629. w: number;
  23630. h: number;
  23631. };
  23632. }): VertexData;
  23633. /**
  23634. * Creates the VertexData of the Ground designed from a heightmap
  23635. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23636. * * width the width (x direction) of the ground
  23637. * * height the height (z direction) of the ground
  23638. * * subdivisions the number of subdivisions per side
  23639. * * minHeight the minimum altitude on the ground, optional, default 0
  23640. * * maxHeight the maximum altitude on the ground, optional default 1
  23641. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23642. * * buffer the array holding the image color data
  23643. * * bufferWidth the width of image
  23644. * * bufferHeight the height of image
  23645. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23646. * @returns the VertexData of the Ground designed from a heightmap
  23647. */
  23648. static CreateGroundFromHeightMap(options: {
  23649. width: number;
  23650. height: number;
  23651. subdivisions: number;
  23652. minHeight: number;
  23653. maxHeight: number;
  23654. colorFilter: Color3;
  23655. buffer: Uint8Array;
  23656. bufferWidth: number;
  23657. bufferHeight: number;
  23658. alphaFilter: number;
  23659. }): VertexData;
  23660. /**
  23661. * Creates the VertexData for a Plane
  23662. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23663. * * size sets the width and height of the plane to the value of size, optional default 1
  23664. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23665. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23666. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23667. * * 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)
  23668. * * 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)
  23669. * @returns the VertexData of the box
  23670. */
  23671. static CreatePlane(options: {
  23672. size?: number;
  23673. width?: number;
  23674. height?: number;
  23675. sideOrientation?: number;
  23676. frontUVs?: Vector4;
  23677. backUVs?: Vector4;
  23678. }): VertexData;
  23679. /**
  23680. * Creates the VertexData of the Disc or regular Polygon
  23681. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23682. * * radius the radius of the disc, optional default 0.5
  23683. * * tessellation the number of polygon sides, optional, default 64
  23684. * * 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
  23685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23686. * * 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)
  23687. * * 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)
  23688. * @returns the VertexData of the box
  23689. */
  23690. static CreateDisc(options: {
  23691. radius?: number;
  23692. tessellation?: number;
  23693. arc?: number;
  23694. sideOrientation?: number;
  23695. frontUVs?: Vector4;
  23696. backUVs?: Vector4;
  23697. }): VertexData;
  23698. /**
  23699. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23700. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23701. * @param polygon a mesh built from polygonTriangulation.build()
  23702. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23703. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23704. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23705. * @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)
  23706. * @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)
  23707. * @returns the VertexData of the Polygon
  23708. */
  23709. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23710. /**
  23711. * Creates the VertexData of the IcoSphere
  23712. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23713. * * radius the radius of the IcoSphere, optional default 1
  23714. * * radiusX allows stretching in the x direction, optional, default radius
  23715. * * radiusY allows stretching in the y direction, optional, default radius
  23716. * * radiusZ allows stretching in the z direction, optional, default radius
  23717. * * flat when true creates a flat shaded mesh, optional, default true
  23718. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23720. * * 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)
  23721. * * 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)
  23722. * @returns the VertexData of the IcoSphere
  23723. */
  23724. static CreateIcoSphere(options: {
  23725. radius?: number;
  23726. radiusX?: number;
  23727. radiusY?: number;
  23728. radiusZ?: number;
  23729. flat?: boolean;
  23730. subdivisions?: number;
  23731. sideOrientation?: number;
  23732. frontUVs?: Vector4;
  23733. backUVs?: Vector4;
  23734. }): VertexData;
  23735. /**
  23736. * Creates the VertexData for a Polyhedron
  23737. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23738. * * type provided types are:
  23739. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23740. * * 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)
  23741. * * size the size of the IcoSphere, optional default 1
  23742. * * sizeX allows stretching in the x direction, optional, default size
  23743. * * sizeY allows stretching in the y direction, optional, default size
  23744. * * sizeZ allows stretching in the z direction, optional, default size
  23745. * * 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
  23746. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23747. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23748. * * flat when true creates a flat shaded mesh, optional, default true
  23749. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23750. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23751. * * 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)
  23752. * * 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)
  23753. * @returns the VertexData of the Polyhedron
  23754. */
  23755. static CreatePolyhedron(options: {
  23756. type?: number;
  23757. size?: number;
  23758. sizeX?: number;
  23759. sizeY?: number;
  23760. sizeZ?: number;
  23761. custom?: any;
  23762. faceUV?: Vector4[];
  23763. faceColors?: Color4[];
  23764. flat?: boolean;
  23765. sideOrientation?: number;
  23766. frontUVs?: Vector4;
  23767. backUVs?: Vector4;
  23768. }): VertexData;
  23769. /**
  23770. * Creates the VertexData for a TorusKnot
  23771. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23772. * * radius the radius of the torus knot, optional, default 2
  23773. * * tube the thickness of the tube, optional, default 0.5
  23774. * * radialSegments the number of sides on each tube segments, optional, default 32
  23775. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23776. * * p the number of windings around the z axis, optional, default 2
  23777. * * q the number of windings around the x axis, optional, default 3
  23778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23779. * * 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)
  23780. * * 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)
  23781. * @returns the VertexData of the Torus Knot
  23782. */
  23783. static CreateTorusKnot(options: {
  23784. radius?: number;
  23785. tube?: number;
  23786. radialSegments?: number;
  23787. tubularSegments?: number;
  23788. p?: number;
  23789. q?: number;
  23790. sideOrientation?: number;
  23791. frontUVs?: Vector4;
  23792. backUVs?: Vector4;
  23793. }): VertexData;
  23794. /**
  23795. * Compute normals for given positions and indices
  23796. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23797. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23798. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23799. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23800. * * facetNormals : optional array of facet normals (vector3)
  23801. * * facetPositions : optional array of facet positions (vector3)
  23802. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23803. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23804. * * bInfo : optional bounding info, required for facetPartitioning computation
  23805. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23806. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23807. * * useRightHandedSystem: optional boolean to for right handed system computation
  23808. * * depthSort : optional boolean to enable the facet depth sort computation
  23809. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23810. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23811. */
  23812. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23813. facetNormals?: any;
  23814. facetPositions?: any;
  23815. facetPartitioning?: any;
  23816. ratio?: number;
  23817. bInfo?: any;
  23818. bbSize?: Vector3;
  23819. subDiv?: any;
  23820. useRightHandedSystem?: boolean;
  23821. depthSort?: boolean;
  23822. distanceTo?: Vector3;
  23823. depthSortedFacets?: any;
  23824. }): void;
  23825. /** @hidden */
  23826. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23827. /**
  23828. * Applies VertexData created from the imported parameters to the geometry
  23829. * @param parsedVertexData the parsed data from an imported file
  23830. * @param geometry the geometry to apply the VertexData to
  23831. */
  23832. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23833. }
  23834. }
  23835. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23836. import { Nullable } from "babylonjs/types";
  23837. import { Scene } from "babylonjs/scene";
  23838. import { Vector4 } from "babylonjs/Maths/math";
  23839. import { Mesh } from "babylonjs/Meshes/mesh";
  23840. /**
  23841. * Class containing static functions to help procedurally build meshes
  23842. */
  23843. export class DiscBuilder {
  23844. /**
  23845. * Creates a plane polygonal mesh. By default, this is a disc
  23846. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23847. * * 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
  23848. * * 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
  23849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23852. * @param name defines the name of the mesh
  23853. * @param options defines the options used to create the mesh
  23854. * @param scene defines the hosting scene
  23855. * @returns the plane polygonal mesh
  23856. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23857. */
  23858. static CreateDisc(name: string, options: {
  23859. radius?: number;
  23860. tessellation?: number;
  23861. arc?: number;
  23862. updatable?: boolean;
  23863. sideOrientation?: number;
  23864. frontUVs?: Vector4;
  23865. backUVs?: Vector4;
  23866. }, scene?: Nullable<Scene>): Mesh;
  23867. }
  23868. }
  23869. declare module "babylonjs/Particles/solidParticleSystem" {
  23870. import { Vector3 } from "babylonjs/Maths/math";
  23871. import { Mesh } from "babylonjs/Meshes/mesh";
  23872. import { Scene, IDisposable } from "babylonjs/scene";
  23873. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23874. /**
  23875. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23876. *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.
  23877. * The SPS is also a particle system. It provides some methods to manage the particles.
  23878. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23879. *
  23880. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23881. */
  23882. export class SolidParticleSystem implements IDisposable {
  23883. /**
  23884. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23885. * Example : var p = SPS.particles[i];
  23886. */
  23887. particles: SolidParticle[];
  23888. /**
  23889. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23890. */
  23891. nbParticles: number;
  23892. /**
  23893. * If the particles must ever face the camera (default false). Useful for planar particles.
  23894. */
  23895. billboard: boolean;
  23896. /**
  23897. * Recompute normals when adding a shape
  23898. */
  23899. recomputeNormals: boolean;
  23900. /**
  23901. * This a counter ofr your own usage. It's not set by any SPS functions.
  23902. */
  23903. counter: number;
  23904. /**
  23905. * The SPS name. This name is also given to the underlying mesh.
  23906. */
  23907. name: string;
  23908. /**
  23909. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23910. */
  23911. mesh: Mesh;
  23912. /**
  23913. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23914. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23915. */
  23916. vars: any;
  23917. /**
  23918. * This array is populated when the SPS is set as 'pickable'.
  23919. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23920. * Each element of this array is an object `{idx: int, faceId: int}`.
  23921. * `idx` is the picked particle index in the `SPS.particles` array
  23922. * `faceId` is the picked face index counted within this particle.
  23923. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23924. */
  23925. pickedParticles: {
  23926. idx: number;
  23927. faceId: number;
  23928. }[];
  23929. /**
  23930. * This array is populated when `enableDepthSort` is set to true.
  23931. * Each element of this array is an instance of the class DepthSortedParticle.
  23932. */
  23933. depthSortedParticles: DepthSortedParticle[];
  23934. /**
  23935. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23936. * @hidden
  23937. */
  23938. _bSphereOnly: boolean;
  23939. /**
  23940. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23941. * @hidden
  23942. */
  23943. _bSphereRadiusFactor: number;
  23944. private _scene;
  23945. private _positions;
  23946. private _indices;
  23947. private _normals;
  23948. private _colors;
  23949. private _uvs;
  23950. private _indices32;
  23951. private _positions32;
  23952. private _normals32;
  23953. private _fixedNormal32;
  23954. private _colors32;
  23955. private _uvs32;
  23956. private _index;
  23957. private _updatable;
  23958. private _pickable;
  23959. private _isVisibilityBoxLocked;
  23960. private _alwaysVisible;
  23961. private _depthSort;
  23962. private _shapeCounter;
  23963. private _copy;
  23964. private _color;
  23965. private _computeParticleColor;
  23966. private _computeParticleTexture;
  23967. private _computeParticleRotation;
  23968. private _computeParticleVertex;
  23969. private _computeBoundingBox;
  23970. private _depthSortParticles;
  23971. private _camera;
  23972. private _mustUnrotateFixedNormals;
  23973. private _particlesIntersect;
  23974. private _needs32Bits;
  23975. /**
  23976. * Creates a SPS (Solid Particle System) object.
  23977. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23978. * @param scene (Scene) is the scene in which the SPS is added.
  23979. * @param options defines the options of the sps e.g.
  23980. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23981. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23982. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23983. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23984. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23985. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23986. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23987. */
  23988. constructor(name: string, scene: Scene, options?: {
  23989. updatable?: boolean;
  23990. isPickable?: boolean;
  23991. enableDepthSort?: boolean;
  23992. particleIntersection?: boolean;
  23993. boundingSphereOnly?: boolean;
  23994. bSphereRadiusFactor?: number;
  23995. });
  23996. /**
  23997. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23998. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23999. * @returns the created mesh
  24000. */
  24001. buildMesh(): Mesh;
  24002. /**
  24003. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24004. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24005. * Thus the particles generated from `digest()` have their property `position` set yet.
  24006. * @param mesh ( Mesh ) is the mesh to be digested
  24007. * @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
  24008. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24009. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24010. * @returns the current SPS
  24011. */
  24012. digest(mesh: Mesh, options?: {
  24013. facetNb?: number;
  24014. number?: number;
  24015. delta?: number;
  24016. }): SolidParticleSystem;
  24017. private _unrotateFixedNormals;
  24018. private _resetCopy;
  24019. private _meshBuilder;
  24020. private _posToShape;
  24021. private _uvsToShapeUV;
  24022. private _addParticle;
  24023. /**
  24024. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24025. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24026. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24027. * @param nb (positive integer) the number of particles to be created from this model
  24028. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24029. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24030. * @returns the number of shapes in the system
  24031. */
  24032. addShape(mesh: Mesh, nb: number, options?: {
  24033. positionFunction?: any;
  24034. vertexFunction?: any;
  24035. }): number;
  24036. private _rebuildParticle;
  24037. /**
  24038. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24039. * @returns the SPS.
  24040. */
  24041. rebuildMesh(): SolidParticleSystem;
  24042. /**
  24043. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24044. * This method calls `updateParticle()` for each particle of the SPS.
  24045. * For an animated SPS, it is usually called within the render loop.
  24046. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24047. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24048. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24049. * @returns the SPS.
  24050. */
  24051. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24052. /**
  24053. * Disposes the SPS.
  24054. */
  24055. dispose(): void;
  24056. /**
  24057. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24058. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24059. * @returns the SPS.
  24060. */
  24061. refreshVisibleSize(): SolidParticleSystem;
  24062. /**
  24063. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24064. * @param size the size (float) of the visibility box
  24065. * note : this doesn't lock the SPS mesh bounding box.
  24066. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24067. */
  24068. setVisibilityBox(size: number): void;
  24069. /**
  24070. * Gets whether the SPS as always visible or not
  24071. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24072. */
  24073. /**
  24074. * Sets the SPS as always visible or not
  24075. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24076. */
  24077. isAlwaysVisible: boolean;
  24078. /**
  24079. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24080. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24081. */
  24082. /**
  24083. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24084. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24085. */
  24086. isVisibilityBoxLocked: boolean;
  24087. /**
  24088. * Tells to `setParticles()` to compute the particle rotations or not.
  24089. * Default value : true. The SPS is faster when it's set to false.
  24090. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24091. */
  24092. /**
  24093. * Gets if `setParticles()` computes the particle rotations or not.
  24094. * Default value : true. The SPS is faster when it's set to false.
  24095. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24096. */
  24097. computeParticleRotation: boolean;
  24098. /**
  24099. * Tells to `setParticles()` to compute the particle colors or not.
  24100. * Default value : true. The SPS is faster when it's set to false.
  24101. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24102. */
  24103. /**
  24104. * Gets if `setParticles()` computes the particle colors or not.
  24105. * Default value : true. The SPS is faster when it's set to false.
  24106. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24107. */
  24108. computeParticleColor: boolean;
  24109. /**
  24110. * Gets if `setParticles()` computes the particle textures or not.
  24111. * Default value : true. The SPS is faster when it's set to false.
  24112. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24113. */
  24114. computeParticleTexture: boolean;
  24115. /**
  24116. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24117. * Default value : false. The SPS is faster when it's set to false.
  24118. * Note : the particle custom vertex positions aren't stored values.
  24119. */
  24120. /**
  24121. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24122. * Default value : false. The SPS is faster when it's set to false.
  24123. * Note : the particle custom vertex positions aren't stored values.
  24124. */
  24125. computeParticleVertex: boolean;
  24126. /**
  24127. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24128. */
  24129. /**
  24130. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24131. */
  24132. computeBoundingBox: boolean;
  24133. /**
  24134. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24135. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24136. * Default : `true`
  24137. */
  24138. /**
  24139. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24140. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24141. * Default : `true`
  24142. */
  24143. depthSortParticles: boolean;
  24144. /**
  24145. * This function does nothing. It may be overwritten to set all the particle first values.
  24146. * The SPS doesn't call this function, you may have to call it by your own.
  24147. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24148. */
  24149. initParticles(): void;
  24150. /**
  24151. * This function does nothing. It may be overwritten to recycle a particle.
  24152. * The SPS doesn't call this function, you may have to call it by your own.
  24153. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24154. * @param particle The particle to recycle
  24155. * @returns the recycled particle
  24156. */
  24157. recycleParticle(particle: SolidParticle): SolidParticle;
  24158. /**
  24159. * Updates a particle : this function should be overwritten by the user.
  24160. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24161. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24162. * @example : just set a particle position or velocity and recycle conditions
  24163. * @param particle The particle to update
  24164. * @returns the updated particle
  24165. */
  24166. updateParticle(particle: SolidParticle): SolidParticle;
  24167. /**
  24168. * Updates a vertex of a particle : it can be overwritten by the user.
  24169. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24170. * @param particle the current particle
  24171. * @param vertex the current index of the current particle
  24172. * @param pt the index of the current vertex in the particle shape
  24173. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24174. * @example : just set a vertex particle position
  24175. * @returns the updated vertex
  24176. */
  24177. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24178. /**
  24179. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24180. * This does nothing and may be overwritten by the user.
  24181. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24182. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24183. * @param update the boolean update value actually passed to setParticles()
  24184. */
  24185. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24186. /**
  24187. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24188. * This will be passed three parameters.
  24189. * This does nothing and may be overwritten by the user.
  24190. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24191. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24192. * @param update the boolean update value actually passed to setParticles()
  24193. */
  24194. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24195. }
  24196. }
  24197. declare module "babylonjs/Particles/solidParticle" {
  24198. import { Nullable } from "babylonjs/types";
  24199. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24200. import { Mesh } from "babylonjs/Meshes/mesh";
  24201. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24202. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24203. /**
  24204. * Represents one particle of a solid particle system.
  24205. */
  24206. export class SolidParticle {
  24207. /**
  24208. * particle global index
  24209. */
  24210. idx: number;
  24211. /**
  24212. * The color of the particle
  24213. */
  24214. color: Nullable<Color4>;
  24215. /**
  24216. * The world space position of the particle.
  24217. */
  24218. position: Vector3;
  24219. /**
  24220. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24221. */
  24222. rotation: Vector3;
  24223. /**
  24224. * The world space rotation quaternion of the particle.
  24225. */
  24226. rotationQuaternion: Nullable<Quaternion>;
  24227. /**
  24228. * The scaling of the particle.
  24229. */
  24230. scaling: Vector3;
  24231. /**
  24232. * The uvs of the particle.
  24233. */
  24234. uvs: Vector4;
  24235. /**
  24236. * The current speed of the particle.
  24237. */
  24238. velocity: Vector3;
  24239. /**
  24240. * The pivot point in the particle local space.
  24241. */
  24242. pivot: Vector3;
  24243. /**
  24244. * Must the particle be translated from its pivot point in its local space ?
  24245. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24246. * Default : false
  24247. */
  24248. translateFromPivot: boolean;
  24249. /**
  24250. * Is the particle active or not ?
  24251. */
  24252. alive: boolean;
  24253. /**
  24254. * Is the particle visible or not ?
  24255. */
  24256. isVisible: boolean;
  24257. /**
  24258. * Index of this particle in the global "positions" array (Internal use)
  24259. * @hidden
  24260. */
  24261. _pos: number;
  24262. /**
  24263. * @hidden Index of this particle in the global "indices" array (Internal use)
  24264. */
  24265. _ind: number;
  24266. /**
  24267. * @hidden ModelShape of this particle (Internal use)
  24268. */
  24269. _model: ModelShape;
  24270. /**
  24271. * ModelShape id of this particle
  24272. */
  24273. shapeId: number;
  24274. /**
  24275. * Index of the particle in its shape id (Internal use)
  24276. */
  24277. idxInShape: number;
  24278. /**
  24279. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24280. */
  24281. _modelBoundingInfo: BoundingInfo;
  24282. /**
  24283. * @hidden Particle BoundingInfo object (Internal use)
  24284. */
  24285. _boundingInfo: BoundingInfo;
  24286. /**
  24287. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24288. */
  24289. _sps: SolidParticleSystem;
  24290. /**
  24291. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24292. */
  24293. _stillInvisible: boolean;
  24294. /**
  24295. * @hidden Last computed particle rotation matrix
  24296. */
  24297. _rotationMatrix: number[];
  24298. /**
  24299. * Parent particle Id, if any.
  24300. * Default null.
  24301. */
  24302. parentId: Nullable<number>;
  24303. /**
  24304. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24305. * The possible values are :
  24306. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24307. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24308. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24309. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24310. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24311. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24312. * */
  24313. cullingStrategy: number;
  24314. /**
  24315. * @hidden Internal global position in the SPS.
  24316. */
  24317. _globalPosition: Vector3;
  24318. /**
  24319. * Creates a Solid Particle object.
  24320. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24321. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24322. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24323. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24324. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24325. * @param shapeId (integer) is the model shape identifier in the SPS.
  24326. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24327. * @param sps defines the sps it is associated to
  24328. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24329. */
  24330. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24331. /**
  24332. * Legacy support, changed scale to scaling
  24333. */
  24334. /**
  24335. * Legacy support, changed scale to scaling
  24336. */
  24337. scale: Vector3;
  24338. /**
  24339. * Legacy support, changed quaternion to rotationQuaternion
  24340. */
  24341. /**
  24342. * Legacy support, changed quaternion to rotationQuaternion
  24343. */
  24344. quaternion: Nullable<Quaternion>;
  24345. /**
  24346. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24347. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24348. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24349. * @returns true if it intersects
  24350. */
  24351. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24352. /**
  24353. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24354. * A particle is in the frustum if its bounding box intersects the frustum
  24355. * @param frustumPlanes defines the frustum to test
  24356. * @returns true if the particle is in the frustum planes
  24357. */
  24358. isInFrustum(frustumPlanes: Plane[]): boolean;
  24359. /**
  24360. * get the rotation matrix of the particle
  24361. * @hidden
  24362. */
  24363. getRotationMatrix(m: Matrix): void;
  24364. }
  24365. /**
  24366. * Represents the shape of the model used by one particle of a solid particle system.
  24367. * SPS internal tool, don't use it manually.
  24368. */
  24369. export class ModelShape {
  24370. /**
  24371. * The shape id
  24372. * @hidden
  24373. */
  24374. shapeID: number;
  24375. /**
  24376. * flat array of model positions (internal use)
  24377. * @hidden
  24378. */
  24379. _shape: Vector3[];
  24380. /**
  24381. * flat array of model UVs (internal use)
  24382. * @hidden
  24383. */
  24384. _shapeUV: number[];
  24385. /**
  24386. * length of the shape in the model indices array (internal use)
  24387. * @hidden
  24388. */
  24389. _indicesLength: number;
  24390. /**
  24391. * Custom position function (internal use)
  24392. * @hidden
  24393. */
  24394. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24395. /**
  24396. * Custom vertex function (internal use)
  24397. * @hidden
  24398. */
  24399. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24400. /**
  24401. * 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.
  24402. * SPS internal tool, don't use it manually.
  24403. * @hidden
  24404. */
  24405. 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>);
  24406. }
  24407. /**
  24408. * Represents a Depth Sorted Particle in the solid particle system.
  24409. */
  24410. export class DepthSortedParticle {
  24411. /**
  24412. * Index of the particle in the "indices" array
  24413. */
  24414. ind: number;
  24415. /**
  24416. * Length of the particle shape in the "indices" array
  24417. */
  24418. indicesLength: number;
  24419. /**
  24420. * Squared distance from the particle to the camera
  24421. */
  24422. sqDistance: number;
  24423. }
  24424. }
  24425. declare module "babylonjs/Meshes/abstractMesh" {
  24426. import { Observable } from "babylonjs/Misc/observable";
  24427. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24428. import { Camera } from "babylonjs/Cameras/camera";
  24429. import { Scene, IDisposable } from "babylonjs/scene";
  24430. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24431. import { Node } from "babylonjs/node";
  24432. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24433. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24434. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24435. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24436. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24437. import { Material } from "babylonjs/Materials/material";
  24438. import { Light } from "babylonjs/Lights/light";
  24439. import { Skeleton } from "babylonjs/Bones/skeleton";
  24440. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24441. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24442. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24443. import { Ray } from "babylonjs/Culling/ray";
  24444. import { Collider } from "babylonjs/Collisions/collider";
  24445. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24446. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24447. /**
  24448. * Class used to store all common mesh properties
  24449. */
  24450. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24451. /** No occlusion */
  24452. static OCCLUSION_TYPE_NONE: number;
  24453. /** Occlusion set to optimisitic */
  24454. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24455. /** Occlusion set to strict */
  24456. static OCCLUSION_TYPE_STRICT: number;
  24457. /** Use an accurante occlusion algorithm */
  24458. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24459. /** Use a conservative occlusion algorithm */
  24460. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24461. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24462. * Test order :
  24463. * Is the bounding sphere outside the frustum ?
  24464. * If not, are the bounding box vertices outside the frustum ?
  24465. * It not, then the cullable object is in the frustum.
  24466. */
  24467. static readonly CULLINGSTRATEGY_STANDARD: number;
  24468. /** Culling strategy : Bounding Sphere Only.
  24469. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24470. * It's also less accurate than the standard because some not visible objects can still be selected.
  24471. * Test : is the bounding sphere outside the frustum ?
  24472. * If not, then the cullable object is in the frustum.
  24473. */
  24474. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24475. /** Culling strategy : Optimistic Inclusion.
  24476. * This in an inclusion test first, then the standard exclusion test.
  24477. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24478. * 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.
  24479. * Anyway, it's as accurate as the standard strategy.
  24480. * Test :
  24481. * Is the cullable object bounding sphere center in the frustum ?
  24482. * If not, apply the default culling strategy.
  24483. */
  24484. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24485. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24486. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24487. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24488. * 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.
  24489. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24490. * Test :
  24491. * Is the cullable object bounding sphere center in the frustum ?
  24492. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24493. */
  24494. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24495. /**
  24496. * No billboard
  24497. */
  24498. static readonly BILLBOARDMODE_NONE: number;
  24499. /** Billboard on X axis */
  24500. static readonly BILLBOARDMODE_X: number;
  24501. /** Billboard on Y axis */
  24502. static readonly BILLBOARDMODE_Y: number;
  24503. /** Billboard on Z axis */
  24504. static readonly BILLBOARDMODE_Z: number;
  24505. /** Billboard on all axes */
  24506. static readonly BILLBOARDMODE_ALL: number;
  24507. private _facetData;
  24508. /**
  24509. * The culling strategy to use to check whether the mesh must be rendered or not.
  24510. * This value can be changed at any time and will be used on the next render mesh selection.
  24511. * The possible values are :
  24512. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24513. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24514. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24515. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24516. * Please read each static variable documentation to get details about the culling process.
  24517. * */
  24518. cullingStrategy: number;
  24519. /**
  24520. * Gets the number of facets in the mesh
  24521. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24522. */
  24523. readonly facetNb: number;
  24524. /**
  24525. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24527. */
  24528. partitioningSubdivisions: number;
  24529. /**
  24530. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24531. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24533. */
  24534. partitioningBBoxRatio: number;
  24535. /**
  24536. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24537. * Works only for updatable meshes.
  24538. * Doesn't work with multi-materials
  24539. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24540. */
  24541. mustDepthSortFacets: boolean;
  24542. /**
  24543. * The location (Vector3) where the facet depth sort must be computed from.
  24544. * By default, the active camera position.
  24545. * Used only when facet depth sort is enabled
  24546. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24547. */
  24548. facetDepthSortFrom: Vector3;
  24549. /**
  24550. * gets a boolean indicating if facetData is enabled
  24551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24552. */
  24553. readonly isFacetDataEnabled: boolean;
  24554. /** @hidden */
  24555. _updateNonUniformScalingState(value: boolean): boolean;
  24556. /**
  24557. * An event triggered when this mesh collides with another one
  24558. */
  24559. onCollideObservable: Observable<AbstractMesh>;
  24560. private _onCollideObserver;
  24561. /** Set a function to call when this mesh collides with another one */
  24562. onCollide: () => void;
  24563. /**
  24564. * An event triggered when the collision's position changes
  24565. */
  24566. onCollisionPositionChangeObservable: Observable<Vector3>;
  24567. private _onCollisionPositionChangeObserver;
  24568. /** Set a function to call when the collision's position changes */
  24569. onCollisionPositionChange: () => void;
  24570. /**
  24571. * An event triggered when material is changed
  24572. */
  24573. onMaterialChangedObservable: Observable<AbstractMesh>;
  24574. /**
  24575. * Gets or sets the orientation for POV movement & rotation
  24576. */
  24577. definedFacingForward: boolean;
  24578. /** @hidden */
  24579. _occlusionQuery: Nullable<WebGLQuery>;
  24580. private _visibility;
  24581. /** @hidden */
  24582. _isActive: boolean;
  24583. /** @hidden */
  24584. _renderingGroup: RenderingGroup;
  24585. /**
  24586. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24587. */
  24588. /**
  24589. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24590. */
  24591. visibility: number;
  24592. /** Gets or sets the alpha index used to sort transparent meshes
  24593. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24594. */
  24595. alphaIndex: number;
  24596. /**
  24597. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24598. */
  24599. isVisible: boolean;
  24600. /**
  24601. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24602. */
  24603. isPickable: boolean;
  24604. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24605. showSubMeshesBoundingBox: boolean;
  24606. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24607. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24608. */
  24609. isBlocker: boolean;
  24610. /**
  24611. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24612. */
  24613. enablePointerMoveEvents: boolean;
  24614. /**
  24615. * Specifies the rendering group id for this mesh (0 by default)
  24616. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24617. */
  24618. renderingGroupId: number;
  24619. private _material;
  24620. /** Gets or sets current material */
  24621. material: Nullable<Material>;
  24622. private _receiveShadows;
  24623. /**
  24624. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24625. * @see http://doc.babylonjs.com/babylon101/shadows
  24626. */
  24627. receiveShadows: boolean;
  24628. /** Defines color to use when rendering outline */
  24629. outlineColor: Color3;
  24630. /** Define width to use when rendering outline */
  24631. outlineWidth: number;
  24632. /** Defines color to use when rendering overlay */
  24633. overlayColor: Color3;
  24634. /** Defines alpha to use when rendering overlay */
  24635. overlayAlpha: number;
  24636. private _hasVertexAlpha;
  24637. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24638. hasVertexAlpha: boolean;
  24639. private _useVertexColors;
  24640. /** 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) */
  24641. useVertexColors: boolean;
  24642. private _computeBonesUsingShaders;
  24643. /**
  24644. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24645. */
  24646. computeBonesUsingShaders: boolean;
  24647. private _numBoneInfluencers;
  24648. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24649. numBoneInfluencers: number;
  24650. private _applyFog;
  24651. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24652. applyFog: boolean;
  24653. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24654. useOctreeForRenderingSelection: boolean;
  24655. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24656. useOctreeForPicking: boolean;
  24657. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24658. useOctreeForCollisions: boolean;
  24659. private _layerMask;
  24660. /**
  24661. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24662. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24663. */
  24664. layerMask: number;
  24665. /**
  24666. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24667. */
  24668. alwaysSelectAsActiveMesh: boolean;
  24669. /**
  24670. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24671. */
  24672. doNotSyncBoundingInfo: boolean;
  24673. /**
  24674. * Gets or sets the current action manager
  24675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24676. */
  24677. actionManager: Nullable<AbstractActionManager>;
  24678. private _checkCollisions;
  24679. private _collisionMask;
  24680. private _collisionGroup;
  24681. /**
  24682. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24683. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24684. */
  24685. ellipsoid: Vector3;
  24686. /**
  24687. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24688. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24689. */
  24690. ellipsoidOffset: Vector3;
  24691. private _collider;
  24692. private _oldPositionForCollisions;
  24693. private _diffPositionForCollisions;
  24694. /**
  24695. * Gets or sets a collision mask used to mask collisions (default is -1).
  24696. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24697. */
  24698. collisionMask: number;
  24699. /**
  24700. * Gets or sets the current collision group mask (-1 by default).
  24701. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24702. */
  24703. collisionGroup: number;
  24704. /**
  24705. * Defines edge width used when edgesRenderer is enabled
  24706. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24707. */
  24708. edgesWidth: number;
  24709. /**
  24710. * Defines edge color used when edgesRenderer is enabled
  24711. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24712. */
  24713. edgesColor: Color4;
  24714. /** @hidden */
  24715. _edgesRenderer: Nullable<IEdgesRenderer>;
  24716. /** @hidden */
  24717. _masterMesh: Nullable<AbstractMesh>;
  24718. /** @hidden */
  24719. _boundingInfo: Nullable<BoundingInfo>;
  24720. /** @hidden */
  24721. _renderId: number;
  24722. /**
  24723. * Gets or sets the list of subMeshes
  24724. * @see http://doc.babylonjs.com/how_to/multi_materials
  24725. */
  24726. subMeshes: SubMesh[];
  24727. /** @hidden */
  24728. _intersectionsInProgress: AbstractMesh[];
  24729. /** @hidden */
  24730. _unIndexed: boolean;
  24731. /** @hidden */
  24732. _lightSources: Light[];
  24733. /** @hidden */
  24734. readonly _positions: Nullable<Vector3[]>;
  24735. /** @hidden */
  24736. _waitingActions: any;
  24737. /** @hidden */
  24738. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24739. private _skeleton;
  24740. /** @hidden */
  24741. _bonesTransformMatrices: Nullable<Float32Array>;
  24742. /**
  24743. * Gets or sets a skeleton to apply skining transformations
  24744. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24745. */
  24746. skeleton: Nullable<Skeleton>;
  24747. /**
  24748. * An event triggered when the mesh is rebuilt.
  24749. */
  24750. onRebuildObservable: Observable<AbstractMesh>;
  24751. /**
  24752. * Creates a new AbstractMesh
  24753. * @param name defines the name of the mesh
  24754. * @param scene defines the hosting scene
  24755. */
  24756. constructor(name: string, scene?: Nullable<Scene>);
  24757. /**
  24758. * Returns the string "AbstractMesh"
  24759. * @returns "AbstractMesh"
  24760. */
  24761. getClassName(): string;
  24762. /**
  24763. * Gets a string representation of the current mesh
  24764. * @param fullDetails defines a boolean indicating if full details must be included
  24765. * @returns a string representation of the current mesh
  24766. */
  24767. toString(fullDetails?: boolean): string;
  24768. /**
  24769. * @hidden
  24770. */
  24771. protected _getEffectiveParent(): Nullable<Node>;
  24772. /** @hidden */
  24773. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24774. /** @hidden */
  24775. _rebuild(): void;
  24776. /** @hidden */
  24777. _resyncLightSources(): void;
  24778. /** @hidden */
  24779. _resyncLighSource(light: Light): void;
  24780. /** @hidden */
  24781. _unBindEffect(): void;
  24782. /** @hidden */
  24783. _removeLightSource(light: Light): void;
  24784. private _markSubMeshesAsDirty;
  24785. /** @hidden */
  24786. _markSubMeshesAsLightDirty(): void;
  24787. /** @hidden */
  24788. _markSubMeshesAsAttributesDirty(): void;
  24789. /** @hidden */
  24790. _markSubMeshesAsMiscDirty(): void;
  24791. /**
  24792. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24793. */
  24794. scaling: Vector3;
  24795. /**
  24796. * Returns true if the mesh is blocked. Implemented by child classes
  24797. */
  24798. readonly isBlocked: boolean;
  24799. /**
  24800. * Returns the mesh itself by default. Implemented by child classes
  24801. * @param camera defines the camera to use to pick the right LOD level
  24802. * @returns the currentAbstractMesh
  24803. */
  24804. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24805. /**
  24806. * Returns 0 by default. Implemented by child classes
  24807. * @returns an integer
  24808. */
  24809. getTotalVertices(): number;
  24810. /**
  24811. * Returns a positive integer : the total number of indices in this mesh geometry.
  24812. * @returns the numner of indices or zero if the mesh has no geometry.
  24813. */
  24814. getTotalIndices(): number;
  24815. /**
  24816. * Returns null by default. Implemented by child classes
  24817. * @returns null
  24818. */
  24819. getIndices(): Nullable<IndicesArray>;
  24820. /**
  24821. * Returns the array of the requested vertex data kind. Implemented by child classes
  24822. * @param kind defines the vertex data kind to use
  24823. * @returns null
  24824. */
  24825. getVerticesData(kind: string): Nullable<FloatArray>;
  24826. /**
  24827. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24828. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24829. * Note that a new underlying VertexBuffer object is created each call.
  24830. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24831. * @param kind defines vertex data kind:
  24832. * * VertexBuffer.PositionKind
  24833. * * VertexBuffer.UVKind
  24834. * * VertexBuffer.UV2Kind
  24835. * * VertexBuffer.UV3Kind
  24836. * * VertexBuffer.UV4Kind
  24837. * * VertexBuffer.UV5Kind
  24838. * * VertexBuffer.UV6Kind
  24839. * * VertexBuffer.ColorKind
  24840. * * VertexBuffer.MatricesIndicesKind
  24841. * * VertexBuffer.MatricesIndicesExtraKind
  24842. * * VertexBuffer.MatricesWeightsKind
  24843. * * VertexBuffer.MatricesWeightsExtraKind
  24844. * @param data defines the data source
  24845. * @param updatable defines if the data must be flagged as updatable (or static)
  24846. * @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
  24847. * @returns the current mesh
  24848. */
  24849. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24850. /**
  24851. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24852. * If the mesh has no geometry, it is simply returned as it is.
  24853. * @param kind defines vertex data kind:
  24854. * * VertexBuffer.PositionKind
  24855. * * VertexBuffer.UVKind
  24856. * * VertexBuffer.UV2Kind
  24857. * * VertexBuffer.UV3Kind
  24858. * * VertexBuffer.UV4Kind
  24859. * * VertexBuffer.UV5Kind
  24860. * * VertexBuffer.UV6Kind
  24861. * * VertexBuffer.ColorKind
  24862. * * VertexBuffer.MatricesIndicesKind
  24863. * * VertexBuffer.MatricesIndicesExtraKind
  24864. * * VertexBuffer.MatricesWeightsKind
  24865. * * VertexBuffer.MatricesWeightsExtraKind
  24866. * @param data defines the data source
  24867. * @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
  24868. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24869. * @returns the current mesh
  24870. */
  24871. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24872. /**
  24873. * Sets the mesh indices,
  24874. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24875. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24876. * @param totalVertices Defines the total number of vertices
  24877. * @returns the current mesh
  24878. */
  24879. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24880. /**
  24881. * Gets a boolean indicating if specific vertex data is present
  24882. * @param kind defines the vertex data kind to use
  24883. * @returns true is data kind is present
  24884. */
  24885. isVerticesDataPresent(kind: string): boolean;
  24886. /**
  24887. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24888. * @returns a BoundingInfo
  24889. */
  24890. getBoundingInfo(): BoundingInfo;
  24891. /**
  24892. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24893. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24894. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24895. * @returns the current mesh
  24896. */
  24897. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24898. /**
  24899. * Overwrite the current bounding info
  24900. * @param boundingInfo defines the new bounding info
  24901. * @returns the current mesh
  24902. */
  24903. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24904. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24905. readonly useBones: boolean;
  24906. /** @hidden */
  24907. _preActivate(): void;
  24908. /** @hidden */
  24909. _preActivateForIntermediateRendering(renderId: number): void;
  24910. /** @hidden */
  24911. _activate(renderId: number): boolean;
  24912. /** @hidden */
  24913. _freeze(): void;
  24914. /** @hidden */
  24915. _unFreeze(): void;
  24916. /**
  24917. * Gets the current world matrix
  24918. * @returns a Matrix
  24919. */
  24920. getWorldMatrix(): Matrix;
  24921. /** @hidden */
  24922. _getWorldMatrixDeterminant(): number;
  24923. /**
  24924. * Perform relative position change from the point of view of behind the front of the mesh.
  24925. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24926. * Supports definition of mesh facing forward or backward
  24927. * @param amountRight defines the distance on the right axis
  24928. * @param amountUp defines the distance on the up axis
  24929. * @param amountForward defines the distance on the forward axis
  24930. * @returns the current mesh
  24931. */
  24932. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24933. /**
  24934. * Calculate relative position change from the point of view of behind the front of the mesh.
  24935. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24936. * Supports definition of mesh facing forward or backward
  24937. * @param amountRight defines the distance on the right axis
  24938. * @param amountUp defines the distance on the up axis
  24939. * @param amountForward defines the distance on the forward axis
  24940. * @returns the new displacement vector
  24941. */
  24942. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24943. /**
  24944. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24945. * Supports definition of mesh facing forward or backward
  24946. * @param flipBack defines the flip
  24947. * @param twirlClockwise defines the twirl
  24948. * @param tiltRight defines the tilt
  24949. * @returns the current mesh
  24950. */
  24951. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24952. /**
  24953. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24954. * Supports definition of mesh facing forward or backward.
  24955. * @param flipBack defines the flip
  24956. * @param twirlClockwise defines the twirl
  24957. * @param tiltRight defines the tilt
  24958. * @returns the new rotation vector
  24959. */
  24960. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24961. /**
  24962. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24963. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24964. * @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
  24965. * @returns the new bounding vectors
  24966. */
  24967. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24968. min: Vector3;
  24969. max: Vector3;
  24970. };
  24971. /**
  24972. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24973. * This means the mesh underlying bounding box and sphere are recomputed.
  24974. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24975. * @returns the current mesh
  24976. */
  24977. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24978. /** @hidden */
  24979. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24980. /** @hidden */
  24981. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24982. /** @hidden */
  24983. _updateBoundingInfo(): AbstractMesh;
  24984. /** @hidden */
  24985. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24986. /** @hidden */
  24987. protected _afterComputeWorldMatrix(): void;
  24988. /** @hidden */
  24989. readonly _effectiveMesh: AbstractMesh;
  24990. /**
  24991. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24992. * A mesh is in the frustum if its bounding box intersects the frustum
  24993. * @param frustumPlanes defines the frustum to test
  24994. * @returns true if the mesh is in the frustum planes
  24995. */
  24996. isInFrustum(frustumPlanes: Plane[]): boolean;
  24997. /**
  24998. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24999. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25000. * @param frustumPlanes defines the frustum to test
  25001. * @returns true if the mesh is completely in the frustum planes
  25002. */
  25003. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25004. /**
  25005. * True if the mesh intersects another mesh or a SolidParticle object
  25006. * @param mesh defines a target mesh or SolidParticle to test
  25007. * @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)
  25008. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25009. * @returns true if there is an intersection
  25010. */
  25011. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25012. /**
  25013. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25014. * @param point defines the point to test
  25015. * @returns true if there is an intersection
  25016. */
  25017. intersectsPoint(point: Vector3): boolean;
  25018. /**
  25019. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25020. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25021. */
  25022. checkCollisions: boolean;
  25023. /**
  25024. * Gets Collider object used to compute collisions (not physics)
  25025. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25026. */
  25027. readonly collider: Collider;
  25028. /**
  25029. * Move the mesh using collision engine
  25030. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25031. * @param displacement defines the requested displacement vector
  25032. * @returns the current mesh
  25033. */
  25034. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25035. private _onCollisionPositionChange;
  25036. /** @hidden */
  25037. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25038. /** @hidden */
  25039. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25040. /** @hidden */
  25041. _checkCollision(collider: Collider): AbstractMesh;
  25042. /** @hidden */
  25043. _generatePointsArray(): boolean;
  25044. /**
  25045. * Checks if the passed Ray intersects with the mesh
  25046. * @param ray defines the ray to use
  25047. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25048. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25049. * @returns the picking info
  25050. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25051. */
  25052. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25053. /**
  25054. * Clones the current mesh
  25055. * @param name defines the mesh name
  25056. * @param newParent defines the new mesh parent
  25057. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25058. * @returns the new mesh
  25059. */
  25060. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25061. /**
  25062. * Disposes all the submeshes of the current meshnp
  25063. * @returns the current mesh
  25064. */
  25065. releaseSubMeshes(): AbstractMesh;
  25066. /**
  25067. * Releases resources associated with this abstract mesh.
  25068. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25069. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25070. */
  25071. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25072. /**
  25073. * Adds the passed mesh as a child to the current mesh
  25074. * @param mesh defines the child mesh
  25075. * @returns the current mesh
  25076. */
  25077. addChild(mesh: AbstractMesh): AbstractMesh;
  25078. /**
  25079. * Removes the passed mesh from the current mesh children list
  25080. * @param mesh defines the child mesh
  25081. * @returns the current mesh
  25082. */
  25083. removeChild(mesh: AbstractMesh): AbstractMesh;
  25084. /** @hidden */
  25085. private _initFacetData;
  25086. /**
  25087. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25088. * This method can be called within the render loop.
  25089. * 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
  25090. * @returns the current mesh
  25091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25092. */
  25093. updateFacetData(): AbstractMesh;
  25094. /**
  25095. * Returns the facetLocalNormals array.
  25096. * The normals are expressed in the mesh local spac
  25097. * @returns an array of Vector3
  25098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25099. */
  25100. getFacetLocalNormals(): Vector3[];
  25101. /**
  25102. * Returns the facetLocalPositions array.
  25103. * The facet positions are expressed in the mesh local space
  25104. * @returns an array of Vector3
  25105. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25106. */
  25107. getFacetLocalPositions(): Vector3[];
  25108. /**
  25109. * Returns the facetLocalPartioning array
  25110. * @returns an array of array of numbers
  25111. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25112. */
  25113. getFacetLocalPartitioning(): number[][];
  25114. /**
  25115. * Returns the i-th facet position in the world system.
  25116. * This method allocates a new Vector3 per call
  25117. * @param i defines the facet index
  25118. * @returns a new Vector3
  25119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25120. */
  25121. getFacetPosition(i: number): Vector3;
  25122. /**
  25123. * Sets the reference Vector3 with the i-th facet position in the world system
  25124. * @param i defines the facet index
  25125. * @param ref defines the target vector
  25126. * @returns the current mesh
  25127. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25128. */
  25129. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25130. /**
  25131. * Returns the i-th facet normal in the world system.
  25132. * This method allocates a new Vector3 per call
  25133. * @param i defines the facet index
  25134. * @returns a new Vector3
  25135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25136. */
  25137. getFacetNormal(i: number): Vector3;
  25138. /**
  25139. * Sets the reference Vector3 with the i-th facet normal in the world system
  25140. * @param i defines the facet index
  25141. * @param ref defines the target vector
  25142. * @returns the current mesh
  25143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25144. */
  25145. getFacetNormalToRef(i: number, ref: Vector3): this;
  25146. /**
  25147. * 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)
  25148. * @param x defines x coordinate
  25149. * @param y defines y coordinate
  25150. * @param z defines z coordinate
  25151. * @returns the array of facet indexes
  25152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25153. */
  25154. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25155. /**
  25156. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25157. * @param projected sets as the (x,y,z) world projection on the facet
  25158. * @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
  25159. * @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
  25160. * @param x defines x coordinate
  25161. * @param y defines y coordinate
  25162. * @param z defines z coordinate
  25163. * @returns the face index if found (or null instead)
  25164. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25165. */
  25166. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25167. /**
  25168. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25169. * @param projected sets as the (x,y,z) local projection on the facet
  25170. * @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
  25171. * @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
  25172. * @param x defines x coordinate
  25173. * @param y defines y coordinate
  25174. * @param z defines z coordinate
  25175. * @returns the face index if found (or null instead)
  25176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25177. */
  25178. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25179. /**
  25180. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25181. * @returns the parameters
  25182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25183. */
  25184. getFacetDataParameters(): any;
  25185. /**
  25186. * Disables the feature FacetData and frees the related memory
  25187. * @returns the current mesh
  25188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25189. */
  25190. disableFacetData(): AbstractMesh;
  25191. /**
  25192. * Updates the AbstractMesh indices array
  25193. * @param indices defines the data source
  25194. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25195. * @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)
  25196. * @returns the current mesh
  25197. */
  25198. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25199. /**
  25200. * Creates new normals data for the mesh
  25201. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25202. * @returns the current mesh
  25203. */
  25204. createNormals(updatable: boolean): AbstractMesh;
  25205. /**
  25206. * Align the mesh with a normal
  25207. * @param normal defines the normal to use
  25208. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25209. * @returns the current mesh
  25210. */
  25211. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25212. /** @hidden */
  25213. _checkOcclusionQuery(): boolean;
  25214. }
  25215. }
  25216. declare module "babylonjs/Actions/actionEvent" {
  25217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25218. import { Nullable } from "babylonjs/types";
  25219. import { Sprite } from "babylonjs/Sprites/sprite";
  25220. import { Scene } from "babylonjs/scene";
  25221. import { Vector2 } from "babylonjs/Maths/math";
  25222. /**
  25223. * Interface used to define ActionEvent
  25224. */
  25225. export interface IActionEvent {
  25226. /** The mesh or sprite that triggered the action */
  25227. source: any;
  25228. /** The X mouse cursor position at the time of the event */
  25229. pointerX: number;
  25230. /** The Y mouse cursor position at the time of the event */
  25231. pointerY: number;
  25232. /** The mesh that is currently pointed at (can be null) */
  25233. meshUnderPointer: Nullable<AbstractMesh>;
  25234. /** the original (browser) event that triggered the ActionEvent */
  25235. sourceEvent?: any;
  25236. /** additional data for the event */
  25237. additionalData?: any;
  25238. }
  25239. /**
  25240. * ActionEvent is the event being sent when an action is triggered.
  25241. */
  25242. export class ActionEvent implements IActionEvent {
  25243. /** The mesh or sprite that triggered the action */
  25244. source: any;
  25245. /** The X mouse cursor position at the time of the event */
  25246. pointerX: number;
  25247. /** The Y mouse cursor position at the time of the event */
  25248. pointerY: number;
  25249. /** The mesh that is currently pointed at (can be null) */
  25250. meshUnderPointer: Nullable<AbstractMesh>;
  25251. /** the original (browser) event that triggered the ActionEvent */
  25252. sourceEvent?: any;
  25253. /** additional data for the event */
  25254. additionalData?: any;
  25255. /**
  25256. * Creates a new ActionEvent
  25257. * @param source The mesh or sprite that triggered the action
  25258. * @param pointerX The X mouse cursor position at the time of the event
  25259. * @param pointerY The Y mouse cursor position at the time of the event
  25260. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25261. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25262. * @param additionalData additional data for the event
  25263. */
  25264. constructor(
  25265. /** The mesh or sprite that triggered the action */
  25266. source: any,
  25267. /** The X mouse cursor position at the time of the event */
  25268. pointerX: number,
  25269. /** The Y mouse cursor position at the time of the event */
  25270. pointerY: number,
  25271. /** The mesh that is currently pointed at (can be null) */
  25272. meshUnderPointer: Nullable<AbstractMesh>,
  25273. /** the original (browser) event that triggered the ActionEvent */
  25274. sourceEvent?: any,
  25275. /** additional data for the event */
  25276. additionalData?: any);
  25277. /**
  25278. * Helper function to auto-create an ActionEvent from a source mesh.
  25279. * @param source The source mesh that triggered the event
  25280. * @param evt The original (browser) event
  25281. * @param additionalData additional data for the event
  25282. * @returns the new ActionEvent
  25283. */
  25284. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25285. /**
  25286. * Helper function to auto-create an ActionEvent from a source sprite
  25287. * @param source The source sprite that triggered the event
  25288. * @param scene Scene associated with the sprite
  25289. * @param evt The original (browser) event
  25290. * @param additionalData additional data for the event
  25291. * @returns the new ActionEvent
  25292. */
  25293. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25294. /**
  25295. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25296. * @param scene the scene where the event occurred
  25297. * @param evt The original (browser) event
  25298. * @returns the new ActionEvent
  25299. */
  25300. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25301. /**
  25302. * Helper function to auto-create an ActionEvent from a primitive
  25303. * @param prim defines the target primitive
  25304. * @param pointerPos defines the pointer position
  25305. * @param evt The original (browser) event
  25306. * @param additionalData additional data for the event
  25307. * @returns the new ActionEvent
  25308. */
  25309. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25310. }
  25311. }
  25312. declare module "babylonjs/Actions/abstractActionManager" {
  25313. import { IDisposable } from "babylonjs/scene";
  25314. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25315. import { IAction } from "babylonjs/Actions/action";
  25316. import { Nullable } from "babylonjs/types";
  25317. /**
  25318. * Abstract class used to decouple action Manager from scene and meshes.
  25319. * Do not instantiate.
  25320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25321. */
  25322. export abstract class AbstractActionManager implements IDisposable {
  25323. /** Gets the list of active triggers */
  25324. static Triggers: {
  25325. [key: string]: number;
  25326. };
  25327. /** Gets the cursor to use when hovering items */
  25328. hoverCursor: string;
  25329. /** Gets the list of actions */
  25330. actions: IAction[];
  25331. /**
  25332. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25333. */
  25334. isRecursive: boolean;
  25335. /**
  25336. * Releases all associated resources
  25337. */
  25338. abstract dispose(): void;
  25339. /**
  25340. * Does this action manager has pointer triggers
  25341. */
  25342. abstract readonly hasPointerTriggers: boolean;
  25343. /**
  25344. * Does this action manager has pick triggers
  25345. */
  25346. abstract readonly hasPickTriggers: boolean;
  25347. /**
  25348. * Process a specific trigger
  25349. * @param trigger defines the trigger to process
  25350. * @param evt defines the event details to be processed
  25351. */
  25352. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25353. /**
  25354. * Does this action manager handles actions of any of the given triggers
  25355. * @param triggers defines the triggers to be tested
  25356. * @return a boolean indicating whether one (or more) of the triggers is handled
  25357. */
  25358. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25359. /**
  25360. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25361. * speed.
  25362. * @param triggerA defines the trigger to be tested
  25363. * @param triggerB defines the trigger to be tested
  25364. * @return a boolean indicating whether one (or more) of the triggers is handled
  25365. */
  25366. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25367. /**
  25368. * Does this action manager handles actions of a given trigger
  25369. * @param trigger defines the trigger to be tested
  25370. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25371. * @return whether the trigger is handled
  25372. */
  25373. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25374. /**
  25375. * Serialize this manager to a JSON object
  25376. * @param name defines the property name to store this manager
  25377. * @returns a JSON representation of this manager
  25378. */
  25379. abstract serialize(name: string): any;
  25380. /**
  25381. * Registers an action to this action manager
  25382. * @param action defines the action to be registered
  25383. * @return the action amended (prepared) after registration
  25384. */
  25385. abstract registerAction(action: IAction): Nullable<IAction>;
  25386. /**
  25387. * Unregisters an action to this action manager
  25388. * @param action defines the action to be unregistered
  25389. * @return a boolean indicating whether the action has been unregistered
  25390. */
  25391. abstract unregisterAction(action: IAction): Boolean;
  25392. /**
  25393. * Does exist one action manager with at least one trigger
  25394. **/
  25395. static readonly HasTriggers: boolean;
  25396. /**
  25397. * Does exist one action manager with at least one pick trigger
  25398. **/
  25399. static readonly HasPickTriggers: boolean;
  25400. /**
  25401. * Does exist one action manager that handles actions of a given trigger
  25402. * @param trigger defines the trigger to be tested
  25403. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25404. **/
  25405. static HasSpecificTrigger(trigger: number): boolean;
  25406. }
  25407. }
  25408. declare module "babylonjs/node" {
  25409. import { Scene } from "babylonjs/scene";
  25410. import { Nullable } from "babylonjs/types";
  25411. import { Matrix } from "babylonjs/Maths/math";
  25412. import { Engine } from "babylonjs/Engines/engine";
  25413. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25414. import { Observable } from "babylonjs/Misc/observable";
  25415. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25416. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25417. import { Animatable } from "babylonjs/Animations/animatable";
  25418. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25419. import { Animation } from "babylonjs/Animations/animation";
  25420. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25422. /**
  25423. * Defines how a node can be built from a string name.
  25424. */
  25425. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25426. /**
  25427. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25428. */
  25429. export class Node implements IBehaviorAware<Node> {
  25430. /** @hidden */
  25431. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25432. private static _NodeConstructors;
  25433. /**
  25434. * Add a new node constructor
  25435. * @param type defines the type name of the node to construct
  25436. * @param constructorFunc defines the constructor function
  25437. */
  25438. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25439. /**
  25440. * Returns a node constructor based on type name
  25441. * @param type defines the type name
  25442. * @param name defines the new node name
  25443. * @param scene defines the hosting scene
  25444. * @param options defines optional options to transmit to constructors
  25445. * @returns the new constructor or null
  25446. */
  25447. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25448. /**
  25449. * Gets or sets the name of the node
  25450. */
  25451. name: string;
  25452. /**
  25453. * Gets or sets the id of the node
  25454. */
  25455. id: string;
  25456. /**
  25457. * Gets or sets the unique id of the node
  25458. */
  25459. uniqueId: number;
  25460. /**
  25461. * Gets or sets a string used to store user defined state for the node
  25462. */
  25463. state: string;
  25464. /**
  25465. * Gets or sets an object used to store user defined information for the node
  25466. */
  25467. metadata: any;
  25468. /**
  25469. * For internal use only. Please do not use.
  25470. */
  25471. reservedDataStore: any;
  25472. /**
  25473. * List of inspectable custom properties (used by the Inspector)
  25474. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25475. */
  25476. inspectableCustomProperties: IInspectable[];
  25477. /**
  25478. * Gets or sets a boolean used to define if the node must be serialized
  25479. */
  25480. doNotSerialize: boolean;
  25481. /** @hidden */
  25482. _isDisposed: boolean;
  25483. /**
  25484. * Gets a list of Animations associated with the node
  25485. */
  25486. animations: import("babylonjs/Animations/animation").Animation[];
  25487. protected _ranges: {
  25488. [name: string]: Nullable<AnimationRange>;
  25489. };
  25490. /**
  25491. * Callback raised when the node is ready to be used
  25492. */
  25493. onReady: (node: Node) => void;
  25494. private _isEnabled;
  25495. private _isParentEnabled;
  25496. private _isReady;
  25497. /** @hidden */
  25498. _currentRenderId: number;
  25499. private _parentUpdateId;
  25500. /** @hidden */
  25501. _childUpdateId: number;
  25502. /** @hidden */
  25503. _waitingParentId: Nullable<string>;
  25504. /** @hidden */
  25505. _scene: Scene;
  25506. /** @hidden */
  25507. _cache: any;
  25508. private _parentNode;
  25509. private _children;
  25510. /** @hidden */
  25511. _worldMatrix: Matrix;
  25512. /** @hidden */
  25513. _worldMatrixDeterminant: number;
  25514. /** @hidden */
  25515. _worldMatrixDeterminantIsDirty: boolean;
  25516. /** @hidden */
  25517. private _sceneRootNodesIndex;
  25518. /**
  25519. * Gets a boolean indicating if the node has been disposed
  25520. * @returns true if the node was disposed
  25521. */
  25522. isDisposed(): boolean;
  25523. /**
  25524. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25525. * @see https://doc.babylonjs.com/how_to/parenting
  25526. */
  25527. parent: Nullable<Node>;
  25528. private addToSceneRootNodes;
  25529. private removeFromSceneRootNodes;
  25530. private _animationPropertiesOverride;
  25531. /**
  25532. * Gets or sets the animation properties override
  25533. */
  25534. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25535. /**
  25536. * Gets a string idenfifying the name of the class
  25537. * @returns "Node" string
  25538. */
  25539. getClassName(): string;
  25540. /** @hidden */
  25541. readonly _isNode: boolean;
  25542. /**
  25543. * An event triggered when the mesh is disposed
  25544. */
  25545. onDisposeObservable: Observable<Node>;
  25546. private _onDisposeObserver;
  25547. /**
  25548. * Sets a callback that will be raised when the node will be disposed
  25549. */
  25550. onDispose: () => void;
  25551. /**
  25552. * Creates a new Node
  25553. * @param name the name and id to be given to this node
  25554. * @param scene the scene this node will be added to
  25555. * @param addToRootNodes the node will be added to scene.rootNodes
  25556. */
  25557. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25558. /**
  25559. * Gets the scene of the node
  25560. * @returns a scene
  25561. */
  25562. getScene(): Scene;
  25563. /**
  25564. * Gets the engine of the node
  25565. * @returns a Engine
  25566. */
  25567. getEngine(): Engine;
  25568. private _behaviors;
  25569. /**
  25570. * Attach a behavior to the node
  25571. * @see http://doc.babylonjs.com/features/behaviour
  25572. * @param behavior defines the behavior to attach
  25573. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25574. * @returns the current Node
  25575. */
  25576. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25577. /**
  25578. * Remove an attached behavior
  25579. * @see http://doc.babylonjs.com/features/behaviour
  25580. * @param behavior defines the behavior to attach
  25581. * @returns the current Node
  25582. */
  25583. removeBehavior(behavior: Behavior<Node>): Node;
  25584. /**
  25585. * Gets the list of attached behaviors
  25586. * @see http://doc.babylonjs.com/features/behaviour
  25587. */
  25588. readonly behaviors: Behavior<Node>[];
  25589. /**
  25590. * Gets an attached behavior by name
  25591. * @param name defines the name of the behavior to look for
  25592. * @see http://doc.babylonjs.com/features/behaviour
  25593. * @returns null if behavior was not found else the requested behavior
  25594. */
  25595. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25596. /**
  25597. * Returns the latest update of the World matrix
  25598. * @returns a Matrix
  25599. */
  25600. getWorldMatrix(): Matrix;
  25601. /** @hidden */
  25602. _getWorldMatrixDeterminant(): number;
  25603. /**
  25604. * Returns directly the latest state of the mesh World matrix.
  25605. * A Matrix is returned.
  25606. */
  25607. readonly worldMatrixFromCache: Matrix;
  25608. /** @hidden */
  25609. _initCache(): void;
  25610. /** @hidden */
  25611. updateCache(force?: boolean): void;
  25612. /** @hidden */
  25613. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25614. /** @hidden */
  25615. _updateCache(ignoreParentClass?: boolean): void;
  25616. /** @hidden */
  25617. _isSynchronized(): boolean;
  25618. /** @hidden */
  25619. _markSyncedWithParent(): void;
  25620. /** @hidden */
  25621. isSynchronizedWithParent(): boolean;
  25622. /** @hidden */
  25623. isSynchronized(): boolean;
  25624. /**
  25625. * Is this node ready to be used/rendered
  25626. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25627. * @return true if the node is ready
  25628. */
  25629. isReady(completeCheck?: boolean): boolean;
  25630. /**
  25631. * Is this node enabled?
  25632. * 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
  25633. * @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
  25634. * @return whether this node (and its parent) is enabled
  25635. */
  25636. isEnabled(checkAncestors?: boolean): boolean;
  25637. /** @hidden */
  25638. protected _syncParentEnabledState(): void;
  25639. /**
  25640. * Set the enabled state of this node
  25641. * @param value defines the new enabled state
  25642. */
  25643. setEnabled(value: boolean): void;
  25644. /**
  25645. * Is this node a descendant of the given node?
  25646. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25647. * @param ancestor defines the parent node to inspect
  25648. * @returns a boolean indicating if this node is a descendant of the given node
  25649. */
  25650. isDescendantOf(ancestor: Node): boolean;
  25651. /** @hidden */
  25652. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25653. /**
  25654. * Will return all nodes that have this node as ascendant
  25655. * @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
  25656. * @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
  25657. * @return all children nodes of all types
  25658. */
  25659. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25660. /**
  25661. * Get all child-meshes of this node
  25662. * @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)
  25663. * @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
  25664. * @returns an array of AbstractMesh
  25665. */
  25666. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25667. /**
  25668. * Get all direct children of this node
  25669. * @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
  25670. * @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)
  25671. * @returns an array of Node
  25672. */
  25673. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25674. /** @hidden */
  25675. _setReady(state: boolean): void;
  25676. /**
  25677. * Get an animation by name
  25678. * @param name defines the name of the animation to look for
  25679. * @returns null if not found else the requested animation
  25680. */
  25681. getAnimationByName(name: string): Nullable<Animation>;
  25682. /**
  25683. * Creates an animation range for this node
  25684. * @param name defines the name of the range
  25685. * @param from defines the starting key
  25686. * @param to defines the end key
  25687. */
  25688. createAnimationRange(name: string, from: number, to: number): void;
  25689. /**
  25690. * Delete a specific animation range
  25691. * @param name defines the name of the range to delete
  25692. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25693. */
  25694. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25695. /**
  25696. * Get an animation range by name
  25697. * @param name defines the name of the animation range to look for
  25698. * @returns null if not found else the requested animation range
  25699. */
  25700. getAnimationRange(name: string): Nullable<AnimationRange>;
  25701. /**
  25702. * Gets the list of all animation ranges defined on this node
  25703. * @returns an array
  25704. */
  25705. getAnimationRanges(): Nullable<AnimationRange>[];
  25706. /**
  25707. * Will start the animation sequence
  25708. * @param name defines the range frames for animation sequence
  25709. * @param loop defines if the animation should loop (false by default)
  25710. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25711. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25712. * @returns the object created for this animation. If range does not exist, it will return null
  25713. */
  25714. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25715. /**
  25716. * Serialize animation ranges into a JSON compatible object
  25717. * @returns serialization object
  25718. */
  25719. serializeAnimationRanges(): any;
  25720. /**
  25721. * Computes the world matrix of the node
  25722. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25723. * @returns the world matrix
  25724. */
  25725. computeWorldMatrix(force?: boolean): Matrix;
  25726. /**
  25727. * Releases resources associated with this node.
  25728. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25729. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25730. */
  25731. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25732. /**
  25733. * Parse animation range data from a serialization object and store them into a given node
  25734. * @param node defines where to store the animation ranges
  25735. * @param parsedNode defines the serialization object to read data from
  25736. * @param scene defines the hosting scene
  25737. */
  25738. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25739. }
  25740. }
  25741. declare module "babylonjs/Animations/animation" {
  25742. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25743. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25744. import { Nullable } from "babylonjs/types";
  25745. import { Scene } from "babylonjs/scene";
  25746. import { IAnimatable } from "babylonjs/Misc/tools";
  25747. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25748. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25749. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25750. import { Node } from "babylonjs/node";
  25751. import { Animatable } from "babylonjs/Animations/animatable";
  25752. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25753. /**
  25754. * @hidden
  25755. */
  25756. export class _IAnimationState {
  25757. key: number;
  25758. repeatCount: number;
  25759. workValue?: any;
  25760. loopMode?: number;
  25761. offsetValue?: any;
  25762. highLimitValue?: any;
  25763. }
  25764. /**
  25765. * Class used to store any kind of animation
  25766. */
  25767. export class Animation {
  25768. /**Name of the animation */
  25769. name: string;
  25770. /**Property to animate */
  25771. targetProperty: string;
  25772. /**The frames per second of the animation */
  25773. framePerSecond: number;
  25774. /**The data type of the animation */
  25775. dataType: number;
  25776. /**The loop mode of the animation */
  25777. loopMode?: number | undefined;
  25778. /**Specifies if blending should be enabled */
  25779. enableBlending?: boolean | undefined;
  25780. /**
  25781. * Use matrix interpolation instead of using direct key value when animating matrices
  25782. */
  25783. static AllowMatricesInterpolation: boolean;
  25784. /**
  25785. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25786. */
  25787. static AllowMatrixDecomposeForInterpolation: boolean;
  25788. /**
  25789. * Stores the key frames of the animation
  25790. */
  25791. private _keys;
  25792. /**
  25793. * Stores the easing function of the animation
  25794. */
  25795. private _easingFunction;
  25796. /**
  25797. * @hidden Internal use only
  25798. */
  25799. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25800. /**
  25801. * The set of event that will be linked to this animation
  25802. */
  25803. private _events;
  25804. /**
  25805. * Stores an array of target property paths
  25806. */
  25807. targetPropertyPath: string[];
  25808. /**
  25809. * Stores the blending speed of the animation
  25810. */
  25811. blendingSpeed: number;
  25812. /**
  25813. * Stores the animation ranges for the animation
  25814. */
  25815. private _ranges;
  25816. /**
  25817. * @hidden Internal use
  25818. */
  25819. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25820. /**
  25821. * Sets up an animation
  25822. * @param property The property to animate
  25823. * @param animationType The animation type to apply
  25824. * @param framePerSecond The frames per second of the animation
  25825. * @param easingFunction The easing function used in the animation
  25826. * @returns The created animation
  25827. */
  25828. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25829. /**
  25830. * Create and start an animation on a node
  25831. * @param name defines the name of the global animation that will be run on all nodes
  25832. * @param node defines the root node where the animation will take place
  25833. * @param targetProperty defines property to animate
  25834. * @param framePerSecond defines the number of frame per second yo use
  25835. * @param totalFrame defines the number of frames in total
  25836. * @param from defines the initial value
  25837. * @param to defines the final value
  25838. * @param loopMode defines which loop mode you want to use (off by default)
  25839. * @param easingFunction defines the easing function to use (linear by default)
  25840. * @param onAnimationEnd defines the callback to call when animation end
  25841. * @returns the animatable created for this animation
  25842. */
  25843. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25844. /**
  25845. * Create and start an animation on a node and its descendants
  25846. * @param name defines the name of the global animation that will be run on all nodes
  25847. * @param node defines the root node where the animation will take place
  25848. * @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
  25849. * @param targetProperty defines property to animate
  25850. * @param framePerSecond defines the number of frame per second to use
  25851. * @param totalFrame defines the number of frames in total
  25852. * @param from defines the initial value
  25853. * @param to defines the final value
  25854. * @param loopMode defines which loop mode you want to use (off by default)
  25855. * @param easingFunction defines the easing function to use (linear by default)
  25856. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25857. * @returns the list of animatables created for all nodes
  25858. * @example https://www.babylonjs-playground.com/#MH0VLI
  25859. */
  25860. 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[]>;
  25861. /**
  25862. * Creates a new animation, merges it with the existing animations and starts it
  25863. * @param name Name of the animation
  25864. * @param node Node which contains the scene that begins the animations
  25865. * @param targetProperty Specifies which property to animate
  25866. * @param framePerSecond The frames per second of the animation
  25867. * @param totalFrame The total number of frames
  25868. * @param from The frame at the beginning of the animation
  25869. * @param to The frame at the end of the animation
  25870. * @param loopMode Specifies the loop mode of the animation
  25871. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25872. * @param onAnimationEnd Callback to run once the animation is complete
  25873. * @returns Nullable animation
  25874. */
  25875. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25876. /**
  25877. * Transition property of an host to the target Value
  25878. * @param property The property to transition
  25879. * @param targetValue The target Value of the property
  25880. * @param host The object where the property to animate belongs
  25881. * @param scene Scene used to run the animation
  25882. * @param frameRate Framerate (in frame/s) to use
  25883. * @param transition The transition type we want to use
  25884. * @param duration The duration of the animation, in milliseconds
  25885. * @param onAnimationEnd Callback trigger at the end of the animation
  25886. * @returns Nullable animation
  25887. */
  25888. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25889. /**
  25890. * Return the array of runtime animations currently using this animation
  25891. */
  25892. readonly runtimeAnimations: RuntimeAnimation[];
  25893. /**
  25894. * Specifies if any of the runtime animations are currently running
  25895. */
  25896. readonly hasRunningRuntimeAnimations: boolean;
  25897. /**
  25898. * Initializes the animation
  25899. * @param name Name of the animation
  25900. * @param targetProperty Property to animate
  25901. * @param framePerSecond The frames per second of the animation
  25902. * @param dataType The data type of the animation
  25903. * @param loopMode The loop mode of the animation
  25904. * @param enableBlending Specifies if blending should be enabled
  25905. */
  25906. constructor(
  25907. /**Name of the animation */
  25908. name: string,
  25909. /**Property to animate */
  25910. targetProperty: string,
  25911. /**The frames per second of the animation */
  25912. framePerSecond: number,
  25913. /**The data type of the animation */
  25914. dataType: number,
  25915. /**The loop mode of the animation */
  25916. loopMode?: number | undefined,
  25917. /**Specifies if blending should be enabled */
  25918. enableBlending?: boolean | undefined);
  25919. /**
  25920. * Converts the animation to a string
  25921. * @param fullDetails support for multiple levels of logging within scene loading
  25922. * @returns String form of the animation
  25923. */
  25924. toString(fullDetails?: boolean): string;
  25925. /**
  25926. * Add an event to this animation
  25927. * @param event Event to add
  25928. */
  25929. addEvent(event: AnimationEvent): void;
  25930. /**
  25931. * Remove all events found at the given frame
  25932. * @param frame The frame to remove events from
  25933. */
  25934. removeEvents(frame: number): void;
  25935. /**
  25936. * Retrieves all the events from the animation
  25937. * @returns Events from the animation
  25938. */
  25939. getEvents(): AnimationEvent[];
  25940. /**
  25941. * Creates an animation range
  25942. * @param name Name of the animation range
  25943. * @param from Starting frame of the animation range
  25944. * @param to Ending frame of the animation
  25945. */
  25946. createRange(name: string, from: number, to: number): void;
  25947. /**
  25948. * Deletes an animation range by name
  25949. * @param name Name of the animation range to delete
  25950. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25951. */
  25952. deleteRange(name: string, deleteFrames?: boolean): void;
  25953. /**
  25954. * Gets the animation range by name, or null if not defined
  25955. * @param name Name of the animation range
  25956. * @returns Nullable animation range
  25957. */
  25958. getRange(name: string): Nullable<AnimationRange>;
  25959. /**
  25960. * Gets the key frames from the animation
  25961. * @returns The key frames of the animation
  25962. */
  25963. getKeys(): Array<IAnimationKey>;
  25964. /**
  25965. * Gets the highest frame rate of the animation
  25966. * @returns Highest frame rate of the animation
  25967. */
  25968. getHighestFrame(): number;
  25969. /**
  25970. * Gets the easing function of the animation
  25971. * @returns Easing function of the animation
  25972. */
  25973. getEasingFunction(): IEasingFunction;
  25974. /**
  25975. * Sets the easing function of the animation
  25976. * @param easingFunction A custom mathematical formula for animation
  25977. */
  25978. setEasingFunction(easingFunction: EasingFunction): void;
  25979. /**
  25980. * Interpolates a scalar linearly
  25981. * @param startValue Start value of the animation curve
  25982. * @param endValue End value of the animation curve
  25983. * @param gradient Scalar amount to interpolate
  25984. * @returns Interpolated scalar value
  25985. */
  25986. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25987. /**
  25988. * Interpolates a scalar cubically
  25989. * @param startValue Start value of the animation curve
  25990. * @param outTangent End tangent of the animation
  25991. * @param endValue End value of the animation curve
  25992. * @param inTangent Start tangent of the animation curve
  25993. * @param gradient Scalar amount to interpolate
  25994. * @returns Interpolated scalar value
  25995. */
  25996. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25997. /**
  25998. * Interpolates a quaternion using a spherical linear interpolation
  25999. * @param startValue Start value of the animation curve
  26000. * @param endValue End value of the animation curve
  26001. * @param gradient Scalar amount to interpolate
  26002. * @returns Interpolated quaternion value
  26003. */
  26004. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26005. /**
  26006. * Interpolates a quaternion cubically
  26007. * @param startValue Start value of the animation curve
  26008. * @param outTangent End tangent of the animation curve
  26009. * @param endValue End value of the animation curve
  26010. * @param inTangent Start tangent of the animation curve
  26011. * @param gradient Scalar amount to interpolate
  26012. * @returns Interpolated quaternion value
  26013. */
  26014. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26015. /**
  26016. * Interpolates a Vector3 linearl
  26017. * @param startValue Start value of the animation curve
  26018. * @param endValue End value of the animation curve
  26019. * @param gradient Scalar amount to interpolate
  26020. * @returns Interpolated scalar value
  26021. */
  26022. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26023. /**
  26024. * Interpolates a Vector3 cubically
  26025. * @param startValue Start value of the animation curve
  26026. * @param outTangent End tangent of the animation
  26027. * @param endValue End value of the animation curve
  26028. * @param inTangent Start tangent of the animation curve
  26029. * @param gradient Scalar amount to interpolate
  26030. * @returns InterpolatedVector3 value
  26031. */
  26032. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26033. /**
  26034. * Interpolates a Vector2 linearly
  26035. * @param startValue Start value of the animation curve
  26036. * @param endValue End value of the animation curve
  26037. * @param gradient Scalar amount to interpolate
  26038. * @returns Interpolated Vector2 value
  26039. */
  26040. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26041. /**
  26042. * Interpolates a Vector2 cubically
  26043. * @param startValue Start value of the animation curve
  26044. * @param outTangent End tangent of the animation
  26045. * @param endValue End value of the animation curve
  26046. * @param inTangent Start tangent of the animation curve
  26047. * @param gradient Scalar amount to interpolate
  26048. * @returns Interpolated Vector2 value
  26049. */
  26050. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26051. /**
  26052. * Interpolates a size linearly
  26053. * @param startValue Start value of the animation curve
  26054. * @param endValue End value of the animation curve
  26055. * @param gradient Scalar amount to interpolate
  26056. * @returns Interpolated Size value
  26057. */
  26058. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26059. /**
  26060. * Interpolates a Color3 linearly
  26061. * @param startValue Start value of the animation curve
  26062. * @param endValue End value of the animation curve
  26063. * @param gradient Scalar amount to interpolate
  26064. * @returns Interpolated Color3 value
  26065. */
  26066. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26067. /**
  26068. * @hidden Internal use only
  26069. */
  26070. _getKeyValue(value: any): any;
  26071. /**
  26072. * @hidden Internal use only
  26073. */
  26074. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26075. /**
  26076. * Defines the function to use to interpolate matrices
  26077. * @param startValue defines the start matrix
  26078. * @param endValue defines the end matrix
  26079. * @param gradient defines the gradient between both matrices
  26080. * @param result defines an optional target matrix where to store the interpolation
  26081. * @returns the interpolated matrix
  26082. */
  26083. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26084. /**
  26085. * Makes a copy of the animation
  26086. * @returns Cloned animation
  26087. */
  26088. clone(): Animation;
  26089. /**
  26090. * Sets the key frames of the animation
  26091. * @param values The animation key frames to set
  26092. */
  26093. setKeys(values: Array<IAnimationKey>): void;
  26094. /**
  26095. * Serializes the animation to an object
  26096. * @returns Serialized object
  26097. */
  26098. serialize(): any;
  26099. /**
  26100. * Float animation type
  26101. */
  26102. private static _ANIMATIONTYPE_FLOAT;
  26103. /**
  26104. * Vector3 animation type
  26105. */
  26106. private static _ANIMATIONTYPE_VECTOR3;
  26107. /**
  26108. * Quaternion animation type
  26109. */
  26110. private static _ANIMATIONTYPE_QUATERNION;
  26111. /**
  26112. * Matrix animation type
  26113. */
  26114. private static _ANIMATIONTYPE_MATRIX;
  26115. /**
  26116. * Color3 animation type
  26117. */
  26118. private static _ANIMATIONTYPE_COLOR3;
  26119. /**
  26120. * Vector2 animation type
  26121. */
  26122. private static _ANIMATIONTYPE_VECTOR2;
  26123. /**
  26124. * Size animation type
  26125. */
  26126. private static _ANIMATIONTYPE_SIZE;
  26127. /**
  26128. * Relative Loop Mode
  26129. */
  26130. private static _ANIMATIONLOOPMODE_RELATIVE;
  26131. /**
  26132. * Cycle Loop Mode
  26133. */
  26134. private static _ANIMATIONLOOPMODE_CYCLE;
  26135. /**
  26136. * Constant Loop Mode
  26137. */
  26138. private static _ANIMATIONLOOPMODE_CONSTANT;
  26139. /**
  26140. * Get the float animation type
  26141. */
  26142. static readonly ANIMATIONTYPE_FLOAT: number;
  26143. /**
  26144. * Get the Vector3 animation type
  26145. */
  26146. static readonly ANIMATIONTYPE_VECTOR3: number;
  26147. /**
  26148. * Get the Vector2 animation type
  26149. */
  26150. static readonly ANIMATIONTYPE_VECTOR2: number;
  26151. /**
  26152. * Get the Size animation type
  26153. */
  26154. static readonly ANIMATIONTYPE_SIZE: number;
  26155. /**
  26156. * Get the Quaternion animation type
  26157. */
  26158. static readonly ANIMATIONTYPE_QUATERNION: number;
  26159. /**
  26160. * Get the Matrix animation type
  26161. */
  26162. static readonly ANIMATIONTYPE_MATRIX: number;
  26163. /**
  26164. * Get the Color3 animation type
  26165. */
  26166. static readonly ANIMATIONTYPE_COLOR3: number;
  26167. /**
  26168. * Get the Relative Loop Mode
  26169. */
  26170. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26171. /**
  26172. * Get the Cycle Loop Mode
  26173. */
  26174. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26175. /**
  26176. * Get the Constant Loop Mode
  26177. */
  26178. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26179. /** @hidden */
  26180. static _UniversalLerp(left: any, right: any, amount: number): any;
  26181. /**
  26182. * Parses an animation object and creates an animation
  26183. * @param parsedAnimation Parsed animation object
  26184. * @returns Animation object
  26185. */
  26186. static Parse(parsedAnimation: any): Animation;
  26187. /**
  26188. * Appends the serialized animations from the source animations
  26189. * @param source Source containing the animations
  26190. * @param destination Target to store the animations
  26191. */
  26192. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26193. }
  26194. }
  26195. declare module "babylonjs/Materials/Textures/baseTexture" {
  26196. import { Observable } from "babylonjs/Misc/observable";
  26197. import { IAnimatable } from "babylonjs/Misc/tools";
  26198. import { Nullable } from "babylonjs/types";
  26199. import { Scene } from "babylonjs/scene";
  26200. import { Matrix, ISize } from "babylonjs/Maths/math";
  26201. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26202. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26203. /**
  26204. * Base class of all the textures in babylon.
  26205. * It groups all the common properties the materials, post process, lights... might need
  26206. * in order to make a correct use of the texture.
  26207. */
  26208. export class BaseTexture implements IAnimatable {
  26209. /**
  26210. * Default anisotropic filtering level for the application.
  26211. * It is set to 4 as a good tradeoff between perf and quality.
  26212. */
  26213. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26214. /**
  26215. * Gets or sets the unique id of the texture
  26216. */
  26217. uniqueId: number;
  26218. /**
  26219. * Define the name of the texture.
  26220. */
  26221. name: string;
  26222. /**
  26223. * Gets or sets an object used to store user defined information.
  26224. */
  26225. metadata: any;
  26226. /**
  26227. * For internal use only. Please do not use.
  26228. */
  26229. reservedDataStore: any;
  26230. private _hasAlpha;
  26231. /**
  26232. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26233. */
  26234. hasAlpha: boolean;
  26235. /**
  26236. * Defines if the alpha value should be determined via the rgb values.
  26237. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26238. */
  26239. getAlphaFromRGB: boolean;
  26240. /**
  26241. * Intensity or strength of the texture.
  26242. * It is commonly used by materials to fine tune the intensity of the texture
  26243. */
  26244. level: number;
  26245. /**
  26246. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26247. * This is part of the texture as textures usually maps to one uv set.
  26248. */
  26249. coordinatesIndex: number;
  26250. private _coordinatesMode;
  26251. /**
  26252. * How a texture is mapped.
  26253. *
  26254. * | Value | Type | Description |
  26255. * | ----- | ----------------------------------- | ----------- |
  26256. * | 0 | EXPLICIT_MODE | |
  26257. * | 1 | SPHERICAL_MODE | |
  26258. * | 2 | PLANAR_MODE | |
  26259. * | 3 | CUBIC_MODE | |
  26260. * | 4 | PROJECTION_MODE | |
  26261. * | 5 | SKYBOX_MODE | |
  26262. * | 6 | INVCUBIC_MODE | |
  26263. * | 7 | EQUIRECTANGULAR_MODE | |
  26264. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26265. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26266. */
  26267. coordinatesMode: number;
  26268. /**
  26269. * | Value | Type | Description |
  26270. * | ----- | ------------------ | ----------- |
  26271. * | 0 | CLAMP_ADDRESSMODE | |
  26272. * | 1 | WRAP_ADDRESSMODE | |
  26273. * | 2 | MIRROR_ADDRESSMODE | |
  26274. */
  26275. wrapU: number;
  26276. /**
  26277. * | Value | Type | Description |
  26278. * | ----- | ------------------ | ----------- |
  26279. * | 0 | CLAMP_ADDRESSMODE | |
  26280. * | 1 | WRAP_ADDRESSMODE | |
  26281. * | 2 | MIRROR_ADDRESSMODE | |
  26282. */
  26283. wrapV: number;
  26284. /**
  26285. * | Value | Type | Description |
  26286. * | ----- | ------------------ | ----------- |
  26287. * | 0 | CLAMP_ADDRESSMODE | |
  26288. * | 1 | WRAP_ADDRESSMODE | |
  26289. * | 2 | MIRROR_ADDRESSMODE | |
  26290. */
  26291. wrapR: number;
  26292. /**
  26293. * With compliant hardware and browser (supporting anisotropic filtering)
  26294. * this defines the level of anisotropic filtering in the texture.
  26295. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26296. */
  26297. anisotropicFilteringLevel: number;
  26298. /**
  26299. * Define if the texture is a cube texture or if false a 2d texture.
  26300. */
  26301. isCube: boolean;
  26302. /**
  26303. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26304. */
  26305. is3D: boolean;
  26306. /**
  26307. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26308. * HDR texture are usually stored in linear space.
  26309. * This only impacts the PBR and Background materials
  26310. */
  26311. gammaSpace: boolean;
  26312. /**
  26313. * Gets whether or not the texture contains RGBD data.
  26314. */
  26315. readonly isRGBD: boolean;
  26316. /**
  26317. * Is Z inverted in the texture (useful in a cube texture).
  26318. */
  26319. invertZ: boolean;
  26320. /**
  26321. * Are mip maps generated for this texture or not.
  26322. */
  26323. readonly noMipmap: boolean;
  26324. /**
  26325. * @hidden
  26326. */
  26327. lodLevelInAlpha: boolean;
  26328. /**
  26329. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26330. */
  26331. lodGenerationOffset: number;
  26332. /**
  26333. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26334. */
  26335. lodGenerationScale: number;
  26336. /**
  26337. * Define if the texture is a render target.
  26338. */
  26339. isRenderTarget: boolean;
  26340. /**
  26341. * Define the unique id of the texture in the scene.
  26342. */
  26343. readonly uid: string;
  26344. /**
  26345. * Return a string representation of the texture.
  26346. * @returns the texture as a string
  26347. */
  26348. toString(): string;
  26349. /**
  26350. * Get the class name of the texture.
  26351. * @returns "BaseTexture"
  26352. */
  26353. getClassName(): string;
  26354. /**
  26355. * Define the list of animation attached to the texture.
  26356. */
  26357. animations: import("babylonjs/Animations/animation").Animation[];
  26358. /**
  26359. * An event triggered when the texture is disposed.
  26360. */
  26361. onDisposeObservable: Observable<BaseTexture>;
  26362. private _onDisposeObserver;
  26363. /**
  26364. * Callback triggered when the texture has been disposed.
  26365. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26366. */
  26367. onDispose: () => void;
  26368. /**
  26369. * Define the current state of the loading sequence when in delayed load mode.
  26370. */
  26371. delayLoadState: number;
  26372. private _scene;
  26373. /** @hidden */
  26374. _texture: Nullable<InternalTexture>;
  26375. private _uid;
  26376. /**
  26377. * Define if the texture is preventinga material to render or not.
  26378. * If not and the texture is not ready, the engine will use a default black texture instead.
  26379. */
  26380. readonly isBlocking: boolean;
  26381. /**
  26382. * Instantiates a new BaseTexture.
  26383. * Base class of all the textures in babylon.
  26384. * It groups all the common properties the materials, post process, lights... might need
  26385. * in order to make a correct use of the texture.
  26386. * @param scene Define the scene the texture blongs to
  26387. */
  26388. constructor(scene: Nullable<Scene>);
  26389. /**
  26390. * Get the scene the texture belongs to.
  26391. * @returns the scene or null if undefined
  26392. */
  26393. getScene(): Nullable<Scene>;
  26394. /**
  26395. * Get the texture transform matrix used to offset tile the texture for istance.
  26396. * @returns the transformation matrix
  26397. */
  26398. getTextureMatrix(): Matrix;
  26399. /**
  26400. * Get the texture reflection matrix used to rotate/transform the reflection.
  26401. * @returns the reflection matrix
  26402. */
  26403. getReflectionTextureMatrix(): Matrix;
  26404. /**
  26405. * Get the underlying lower level texture from Babylon.
  26406. * @returns the insternal texture
  26407. */
  26408. getInternalTexture(): Nullable<InternalTexture>;
  26409. /**
  26410. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26411. * @returns true if ready or not blocking
  26412. */
  26413. isReadyOrNotBlocking(): boolean;
  26414. /**
  26415. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26416. * @returns true if fully ready
  26417. */
  26418. isReady(): boolean;
  26419. private _cachedSize;
  26420. /**
  26421. * Get the size of the texture.
  26422. * @returns the texture size.
  26423. */
  26424. getSize(): ISize;
  26425. /**
  26426. * Get the base size of the texture.
  26427. * It can be different from the size if the texture has been resized for POT for instance
  26428. * @returns the base size
  26429. */
  26430. getBaseSize(): ISize;
  26431. /**
  26432. * Update the sampling mode of the texture.
  26433. * Default is Trilinear mode.
  26434. *
  26435. * | Value | Type | Description |
  26436. * | ----- | ------------------ | ----------- |
  26437. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26438. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26439. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26440. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26441. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26442. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26443. * | 7 | NEAREST_LINEAR | |
  26444. * | 8 | NEAREST_NEAREST | |
  26445. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26446. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26447. * | 11 | LINEAR_LINEAR | |
  26448. * | 12 | LINEAR_NEAREST | |
  26449. *
  26450. * > _mag_: magnification filter (close to the viewer)
  26451. * > _min_: minification filter (far from the viewer)
  26452. * > _mip_: filter used between mip map levels
  26453. *@param samplingMode Define the new sampling mode of the texture
  26454. */
  26455. updateSamplingMode(samplingMode: number): void;
  26456. /**
  26457. * Scales the texture if is `canRescale()`
  26458. * @param ratio the resize factor we want to use to rescale
  26459. */
  26460. scale(ratio: number): void;
  26461. /**
  26462. * Get if the texture can rescale.
  26463. */
  26464. readonly canRescale: boolean;
  26465. /** @hidden */
  26466. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26467. /** @hidden */
  26468. _rebuild(): void;
  26469. /**
  26470. * Triggers the load sequence in delayed load mode.
  26471. */
  26472. delayLoad(): void;
  26473. /**
  26474. * Clones the texture.
  26475. * @returns the cloned texture
  26476. */
  26477. clone(): Nullable<BaseTexture>;
  26478. /**
  26479. * Get the texture underlying type (INT, FLOAT...)
  26480. */
  26481. readonly textureType: number;
  26482. /**
  26483. * Get the texture underlying format (RGB, RGBA...)
  26484. */
  26485. readonly textureFormat: number;
  26486. /**
  26487. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26488. * This will returns an RGBA array buffer containing either in values (0-255) or
  26489. * float values (0-1) depending of the underlying buffer type.
  26490. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26491. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26492. * @param buffer defines a user defined buffer to fill with data (can be null)
  26493. * @returns The Array buffer containing the pixels data.
  26494. */
  26495. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26496. /**
  26497. * Release and destroy the underlying lower level texture aka internalTexture.
  26498. */
  26499. releaseInternalTexture(): void;
  26500. /**
  26501. * Get the polynomial representation of the texture data.
  26502. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26503. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26504. */
  26505. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26506. /** @hidden */
  26507. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26508. /** @hidden */
  26509. readonly _lodTextureMid: Nullable<BaseTexture>;
  26510. /** @hidden */
  26511. readonly _lodTextureLow: Nullable<BaseTexture>;
  26512. /**
  26513. * Dispose the texture and release its associated resources.
  26514. */
  26515. dispose(): void;
  26516. /**
  26517. * Serialize the texture into a JSON representation that can be parsed later on.
  26518. * @returns the JSON representation of the texture
  26519. */
  26520. serialize(): any;
  26521. /**
  26522. * Helper function to be called back once a list of texture contains only ready textures.
  26523. * @param textures Define the list of textures to wait for
  26524. * @param callback Define the callback triggered once the entire list will be ready
  26525. */
  26526. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26527. }
  26528. }
  26529. declare module "babylonjs/Materials/uniformBuffer" {
  26530. import { Nullable, FloatArray } from "babylonjs/types";
  26531. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26532. import { Engine } from "babylonjs/Engines/engine";
  26533. import { Effect } from "babylonjs/Materials/effect";
  26534. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26535. /**
  26536. * Uniform buffer objects.
  26537. *
  26538. * Handles blocks of uniform on the GPU.
  26539. *
  26540. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26541. *
  26542. * For more information, please refer to :
  26543. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26544. */
  26545. export class UniformBuffer {
  26546. private _engine;
  26547. private _buffer;
  26548. private _data;
  26549. private _bufferData;
  26550. private _dynamic?;
  26551. private _uniformLocations;
  26552. private _uniformSizes;
  26553. private _uniformLocationPointer;
  26554. private _needSync;
  26555. private _noUBO;
  26556. private _currentEffect;
  26557. private static _MAX_UNIFORM_SIZE;
  26558. private static _tempBuffer;
  26559. /**
  26560. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26561. * This is dynamic to allow compat with webgl 1 and 2.
  26562. * You will need to pass the name of the uniform as well as the value.
  26563. */
  26564. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26565. /**
  26566. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26567. * This is dynamic to allow compat with webgl 1 and 2.
  26568. * You will need to pass the name of the uniform as well as the value.
  26569. */
  26570. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26571. /**
  26572. * Lambda to Update a single float in a uniform buffer.
  26573. * This is dynamic to allow compat with webgl 1 and 2.
  26574. * You will need to pass the name of the uniform as well as the value.
  26575. */
  26576. updateFloat: (name: string, x: number) => void;
  26577. /**
  26578. * Lambda to Update a vec2 of float in a uniform buffer.
  26579. * This is dynamic to allow compat with webgl 1 and 2.
  26580. * You will need to pass the name of the uniform as well as the value.
  26581. */
  26582. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26583. /**
  26584. * Lambda to Update a vec3 of float in a uniform buffer.
  26585. * This is dynamic to allow compat with webgl 1 and 2.
  26586. * You will need to pass the name of the uniform as well as the value.
  26587. */
  26588. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26589. /**
  26590. * Lambda to Update a vec4 of float in a uniform buffer.
  26591. * This is dynamic to allow compat with webgl 1 and 2.
  26592. * You will need to pass the name of the uniform as well as the value.
  26593. */
  26594. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26595. /**
  26596. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26597. * This is dynamic to allow compat with webgl 1 and 2.
  26598. * You will need to pass the name of the uniform as well as the value.
  26599. */
  26600. updateMatrix: (name: string, mat: Matrix) => void;
  26601. /**
  26602. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26603. * This is dynamic to allow compat with webgl 1 and 2.
  26604. * You will need to pass the name of the uniform as well as the value.
  26605. */
  26606. updateVector3: (name: string, vector: Vector3) => void;
  26607. /**
  26608. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26609. * This is dynamic to allow compat with webgl 1 and 2.
  26610. * You will need to pass the name of the uniform as well as the value.
  26611. */
  26612. updateVector4: (name: string, vector: Vector4) => void;
  26613. /**
  26614. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26615. * This is dynamic to allow compat with webgl 1 and 2.
  26616. * You will need to pass the name of the uniform as well as the value.
  26617. */
  26618. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26619. /**
  26620. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26621. * This is dynamic to allow compat with webgl 1 and 2.
  26622. * You will need to pass the name of the uniform as well as the value.
  26623. */
  26624. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26625. /**
  26626. * Instantiates a new Uniform buffer objects.
  26627. *
  26628. * Handles blocks of uniform on the GPU.
  26629. *
  26630. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26631. *
  26632. * For more information, please refer to :
  26633. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26634. * @param engine Define the engine the buffer is associated with
  26635. * @param data Define the data contained in the buffer
  26636. * @param dynamic Define if the buffer is updatable
  26637. */
  26638. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26639. /**
  26640. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26641. * or just falling back on setUniformXXX calls.
  26642. */
  26643. readonly useUbo: boolean;
  26644. /**
  26645. * Indicates if the WebGL underlying uniform buffer is in sync
  26646. * with the javascript cache data.
  26647. */
  26648. readonly isSync: boolean;
  26649. /**
  26650. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26651. * Also, a dynamic UniformBuffer will disable cache verification and always
  26652. * update the underlying WebGL uniform buffer to the GPU.
  26653. * @returns if Dynamic, otherwise false
  26654. */
  26655. isDynamic(): boolean;
  26656. /**
  26657. * The data cache on JS side.
  26658. * @returns the underlying data as a float array
  26659. */
  26660. getData(): Float32Array;
  26661. /**
  26662. * The underlying WebGL Uniform buffer.
  26663. * @returns the webgl buffer
  26664. */
  26665. getBuffer(): Nullable<WebGLBuffer>;
  26666. /**
  26667. * std140 layout specifies how to align data within an UBO structure.
  26668. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26669. * for specs.
  26670. */
  26671. private _fillAlignment;
  26672. /**
  26673. * Adds an uniform in the buffer.
  26674. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26675. * for the layout to be correct !
  26676. * @param name Name of the uniform, as used in the uniform block in the shader.
  26677. * @param size Data size, or data directly.
  26678. */
  26679. addUniform(name: string, size: number | number[]): void;
  26680. /**
  26681. * Adds a Matrix 4x4 to the uniform buffer.
  26682. * @param name Name of the uniform, as used in the uniform block in the shader.
  26683. * @param mat A 4x4 matrix.
  26684. */
  26685. addMatrix(name: string, mat: Matrix): void;
  26686. /**
  26687. * Adds a vec2 to the uniform buffer.
  26688. * @param name Name of the uniform, as used in the uniform block in the shader.
  26689. * @param x Define the x component value of the vec2
  26690. * @param y Define the y component value of the vec2
  26691. */
  26692. addFloat2(name: string, x: number, y: number): void;
  26693. /**
  26694. * Adds a vec3 to the uniform buffer.
  26695. * @param name Name of the uniform, as used in the uniform block in the shader.
  26696. * @param x Define the x component value of the vec3
  26697. * @param y Define the y component value of the vec3
  26698. * @param z Define the z component value of the vec3
  26699. */
  26700. addFloat3(name: string, x: number, y: number, z: number): void;
  26701. /**
  26702. * Adds a vec3 to the uniform buffer.
  26703. * @param name Name of the uniform, as used in the uniform block in the shader.
  26704. * @param color Define the vec3 from a Color
  26705. */
  26706. addColor3(name: string, color: Color3): void;
  26707. /**
  26708. * Adds a vec4 to the uniform buffer.
  26709. * @param name Name of the uniform, as used in the uniform block in the shader.
  26710. * @param color Define the rgb components from a Color
  26711. * @param alpha Define the a component of the vec4
  26712. */
  26713. addColor4(name: string, color: Color3, alpha: number): void;
  26714. /**
  26715. * Adds a vec3 to the uniform buffer.
  26716. * @param name Name of the uniform, as used in the uniform block in the shader.
  26717. * @param vector Define the vec3 components from a Vector
  26718. */
  26719. addVector3(name: string, vector: Vector3): void;
  26720. /**
  26721. * Adds a Matrix 3x3 to the uniform buffer.
  26722. * @param name Name of the uniform, as used in the uniform block in the shader.
  26723. */
  26724. addMatrix3x3(name: string): void;
  26725. /**
  26726. * Adds a Matrix 2x2 to the uniform buffer.
  26727. * @param name Name of the uniform, as used in the uniform block in the shader.
  26728. */
  26729. addMatrix2x2(name: string): void;
  26730. /**
  26731. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26732. */
  26733. create(): void;
  26734. /** @hidden */
  26735. _rebuild(): void;
  26736. /**
  26737. * Updates the WebGL Uniform Buffer on the GPU.
  26738. * If the `dynamic` flag is set to true, no cache comparison is done.
  26739. * Otherwise, the buffer will be updated only if the cache differs.
  26740. */
  26741. update(): void;
  26742. /**
  26743. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26744. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26745. * @param data Define the flattened data
  26746. * @param size Define the size of the data.
  26747. */
  26748. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26749. private _updateMatrix3x3ForUniform;
  26750. private _updateMatrix3x3ForEffect;
  26751. private _updateMatrix2x2ForEffect;
  26752. private _updateMatrix2x2ForUniform;
  26753. private _updateFloatForEffect;
  26754. private _updateFloatForUniform;
  26755. private _updateFloat2ForEffect;
  26756. private _updateFloat2ForUniform;
  26757. private _updateFloat3ForEffect;
  26758. private _updateFloat3ForUniform;
  26759. private _updateFloat4ForEffect;
  26760. private _updateFloat4ForUniform;
  26761. private _updateMatrixForEffect;
  26762. private _updateMatrixForUniform;
  26763. private _updateVector3ForEffect;
  26764. private _updateVector3ForUniform;
  26765. private _updateVector4ForEffect;
  26766. private _updateVector4ForUniform;
  26767. private _updateColor3ForEffect;
  26768. private _updateColor3ForUniform;
  26769. private _updateColor4ForEffect;
  26770. private _updateColor4ForUniform;
  26771. /**
  26772. * Sets a sampler uniform on the effect.
  26773. * @param name Define the name of the sampler.
  26774. * @param texture Define the texture to set in the sampler
  26775. */
  26776. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26777. /**
  26778. * Directly updates the value of the uniform in the cache AND on the GPU.
  26779. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26780. * @param data Define the flattened data
  26781. */
  26782. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26783. /**
  26784. * Binds this uniform buffer to an effect.
  26785. * @param effect Define the effect to bind the buffer to
  26786. * @param name Name of the uniform block in the shader.
  26787. */
  26788. bindToEffect(effect: Effect, name: string): void;
  26789. /**
  26790. * Disposes the uniform buffer.
  26791. */
  26792. dispose(): void;
  26793. }
  26794. }
  26795. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26796. import { Nullable } from "babylonjs/types";
  26797. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26798. /**
  26799. * This represents the required contract to create a new type of texture loader.
  26800. */
  26801. export interface IInternalTextureLoader {
  26802. /**
  26803. * Defines wether the loader supports cascade loading the different faces.
  26804. */
  26805. supportCascades: boolean;
  26806. /**
  26807. * This returns if the loader support the current file information.
  26808. * @param extension defines the file extension of the file being loaded
  26809. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26810. * @param fallback defines the fallback internal texture if any
  26811. * @param isBase64 defines whether the texture is encoded as a base64
  26812. * @param isBuffer defines whether the texture data are stored as a buffer
  26813. * @returns true if the loader can load the specified file
  26814. */
  26815. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26816. /**
  26817. * Transform the url before loading if required.
  26818. * @param rootUrl the url of the texture
  26819. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26820. * @returns the transformed texture
  26821. */
  26822. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26823. /**
  26824. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26825. * @param rootUrl the url of the texture
  26826. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26827. * @returns the fallback texture
  26828. */
  26829. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26830. /**
  26831. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26832. * @param data contains the texture data
  26833. * @param texture defines the BabylonJS internal texture
  26834. * @param createPolynomials will be true if polynomials have been requested
  26835. * @param onLoad defines the callback to trigger once the texture is ready
  26836. * @param onError defines the callback to trigger in case of error
  26837. */
  26838. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26839. /**
  26840. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26841. * @param data contains the texture data
  26842. * @param texture defines the BabylonJS internal texture
  26843. * @param callback defines the method to call once ready to upload
  26844. */
  26845. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26846. }
  26847. }
  26848. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26849. import { Scene } from "babylonjs/scene";
  26850. import { Engine } from "babylonjs/Engines/engine";
  26851. import { Texture } from "babylonjs/Materials/Textures/texture";
  26852. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26853. /**
  26854. * Creation options of the multi render target texture.
  26855. */
  26856. export interface IMultiRenderTargetOptions {
  26857. /**
  26858. * Define if the texture needs to create mip maps after render.
  26859. */
  26860. generateMipMaps?: boolean;
  26861. /**
  26862. * Define the types of all the draw buffers we want to create
  26863. */
  26864. types?: number[];
  26865. /**
  26866. * Define the sampling modes of all the draw buffers we want to create
  26867. */
  26868. samplingModes?: number[];
  26869. /**
  26870. * Define if a depth buffer is required
  26871. */
  26872. generateDepthBuffer?: boolean;
  26873. /**
  26874. * Define if a stencil buffer is required
  26875. */
  26876. generateStencilBuffer?: boolean;
  26877. /**
  26878. * Define if a depth texture is required instead of a depth buffer
  26879. */
  26880. generateDepthTexture?: boolean;
  26881. /**
  26882. * Define the number of desired draw buffers
  26883. */
  26884. textureCount?: number;
  26885. /**
  26886. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26887. */
  26888. doNotChangeAspectRatio?: boolean;
  26889. /**
  26890. * Define the default type of the buffers we are creating
  26891. */
  26892. defaultType?: number;
  26893. }
  26894. /**
  26895. * A multi render target, like a render target provides the ability to render to a texture.
  26896. * Unlike the render target, it can render to several draw buffers in one draw.
  26897. * This is specially interesting in deferred rendering or for any effects requiring more than
  26898. * just one color from a single pass.
  26899. */
  26900. export class MultiRenderTarget extends RenderTargetTexture {
  26901. private _internalTextures;
  26902. private _textures;
  26903. private _multiRenderTargetOptions;
  26904. /**
  26905. * Get if draw buffers are currently supported by the used hardware and browser.
  26906. */
  26907. readonly isSupported: boolean;
  26908. /**
  26909. * Get the list of textures generated by the multi render target.
  26910. */
  26911. readonly textures: Texture[];
  26912. /**
  26913. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26914. */
  26915. readonly depthTexture: Texture;
  26916. /**
  26917. * Set the wrapping mode on U of all the textures we are rendering to.
  26918. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26919. */
  26920. wrapU: number;
  26921. /**
  26922. * Set the wrapping mode on V of all the textures we are rendering to.
  26923. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26924. */
  26925. wrapV: number;
  26926. /**
  26927. * Instantiate a new multi render target texture.
  26928. * A multi render target, like a render target provides the ability to render to a texture.
  26929. * Unlike the render target, it can render to several draw buffers in one draw.
  26930. * This is specially interesting in deferred rendering or for any effects requiring more than
  26931. * just one color from a single pass.
  26932. * @param name Define the name of the texture
  26933. * @param size Define the size of the buffers to render to
  26934. * @param count Define the number of target we are rendering into
  26935. * @param scene Define the scene the texture belongs to
  26936. * @param options Define the options used to create the multi render target
  26937. */
  26938. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26939. /** @hidden */
  26940. _rebuild(): void;
  26941. private _createInternalTextures;
  26942. private _createTextures;
  26943. /**
  26944. * Define the number of samples used if MSAA is enabled.
  26945. */
  26946. samples: number;
  26947. /**
  26948. * Resize all the textures in the multi render target.
  26949. * Be carrefull as it will recreate all the data in the new texture.
  26950. * @param size Define the new size
  26951. */
  26952. resize(size: any): void;
  26953. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26954. /**
  26955. * Dispose the render targets and their associated resources
  26956. */
  26957. dispose(): void;
  26958. /**
  26959. * Release all the underlying texture used as draw buffers.
  26960. */
  26961. releaseInternalTextures(): void;
  26962. }
  26963. }
  26964. declare module "babylonjs/Audio/analyser" {
  26965. import { Scene } from "babylonjs/scene";
  26966. /**
  26967. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26969. */
  26970. export class Analyser {
  26971. /**
  26972. * Gets or sets the smoothing
  26973. * @ignorenaming
  26974. */
  26975. SMOOTHING: number;
  26976. /**
  26977. * Gets or sets the FFT table size
  26978. * @ignorenaming
  26979. */
  26980. FFT_SIZE: number;
  26981. /**
  26982. * Gets or sets the bar graph amplitude
  26983. * @ignorenaming
  26984. */
  26985. BARGRAPHAMPLITUDE: number;
  26986. /**
  26987. * Gets or sets the position of the debug canvas
  26988. * @ignorenaming
  26989. */
  26990. DEBUGCANVASPOS: {
  26991. x: number;
  26992. y: number;
  26993. };
  26994. /**
  26995. * Gets or sets the debug canvas size
  26996. * @ignorenaming
  26997. */
  26998. DEBUGCANVASSIZE: {
  26999. width: number;
  27000. height: number;
  27001. };
  27002. private _byteFreqs;
  27003. private _byteTime;
  27004. private _floatFreqs;
  27005. private _webAudioAnalyser;
  27006. private _debugCanvas;
  27007. private _debugCanvasContext;
  27008. private _scene;
  27009. private _registerFunc;
  27010. private _audioEngine;
  27011. /**
  27012. * Creates a new analyser
  27013. * @param scene defines hosting scene
  27014. */
  27015. constructor(scene: Scene);
  27016. /**
  27017. * Get the number of data values you will have to play with for the visualization
  27018. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27019. * @returns a number
  27020. */
  27021. getFrequencyBinCount(): number;
  27022. /**
  27023. * Gets the current frequency data as a byte array
  27024. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27025. * @returns a Uint8Array
  27026. */
  27027. getByteFrequencyData(): Uint8Array;
  27028. /**
  27029. * Gets the current waveform as a byte array
  27030. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27031. * @returns a Uint8Array
  27032. */
  27033. getByteTimeDomainData(): Uint8Array;
  27034. /**
  27035. * Gets the current frequency data as a float array
  27036. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27037. * @returns a Float32Array
  27038. */
  27039. getFloatFrequencyData(): Float32Array;
  27040. /**
  27041. * Renders the debug canvas
  27042. */
  27043. drawDebugCanvas(): void;
  27044. /**
  27045. * Stops rendering the debug canvas and removes it
  27046. */
  27047. stopDebugCanvas(): void;
  27048. /**
  27049. * Connects two audio nodes
  27050. * @param inputAudioNode defines first node to connect
  27051. * @param outputAudioNode defines second node to connect
  27052. */
  27053. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27054. /**
  27055. * Releases all associated resources
  27056. */
  27057. dispose(): void;
  27058. }
  27059. }
  27060. declare module "babylonjs/Audio/audioEngine" {
  27061. import { IDisposable } from "babylonjs/scene";
  27062. import { Analyser } from "babylonjs/Audio/analyser";
  27063. import { Nullable } from "babylonjs/types";
  27064. import { Observable } from "babylonjs/Misc/observable";
  27065. /**
  27066. * This represents an audio engine and it is responsible
  27067. * to play, synchronize and analyse sounds throughout the application.
  27068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27069. */
  27070. export interface IAudioEngine extends IDisposable {
  27071. /**
  27072. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27073. */
  27074. readonly canUseWebAudio: boolean;
  27075. /**
  27076. * Gets the current AudioContext if available.
  27077. */
  27078. readonly audioContext: Nullable<AudioContext>;
  27079. /**
  27080. * The master gain node defines the global audio volume of your audio engine.
  27081. */
  27082. readonly masterGain: GainNode;
  27083. /**
  27084. * Gets whether or not mp3 are supported by your browser.
  27085. */
  27086. readonly isMP3supported: boolean;
  27087. /**
  27088. * Gets whether or not ogg are supported by your browser.
  27089. */
  27090. readonly isOGGsupported: boolean;
  27091. /**
  27092. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27093. * @ignoreNaming
  27094. */
  27095. WarnedWebAudioUnsupported: boolean;
  27096. /**
  27097. * Defines if the audio engine relies on a custom unlocked button.
  27098. * In this case, the embedded button will not be displayed.
  27099. */
  27100. useCustomUnlockedButton: boolean;
  27101. /**
  27102. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27103. */
  27104. readonly unlocked: boolean;
  27105. /**
  27106. * Event raised when audio has been unlocked on the browser.
  27107. */
  27108. onAudioUnlockedObservable: Observable<AudioEngine>;
  27109. /**
  27110. * Event raised when audio has been locked on the browser.
  27111. */
  27112. onAudioLockedObservable: Observable<AudioEngine>;
  27113. /**
  27114. * Flags the audio engine in Locked state.
  27115. * This happens due to new browser policies preventing audio to autoplay.
  27116. */
  27117. lock(): void;
  27118. /**
  27119. * Unlocks the audio engine once a user action has been done on the dom.
  27120. * This is helpful to resume play once browser policies have been satisfied.
  27121. */
  27122. unlock(): void;
  27123. }
  27124. /**
  27125. * This represents the default audio engine used in babylon.
  27126. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27128. */
  27129. export class AudioEngine implements IAudioEngine {
  27130. private _audioContext;
  27131. private _audioContextInitialized;
  27132. private _muteButton;
  27133. private _hostElement;
  27134. /**
  27135. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27136. */
  27137. canUseWebAudio: boolean;
  27138. /**
  27139. * The master gain node defines the global audio volume of your audio engine.
  27140. */
  27141. masterGain: GainNode;
  27142. /**
  27143. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27144. * @ignoreNaming
  27145. */
  27146. WarnedWebAudioUnsupported: boolean;
  27147. /**
  27148. * Gets whether or not mp3 are supported by your browser.
  27149. */
  27150. isMP3supported: boolean;
  27151. /**
  27152. * Gets whether or not ogg are supported by your browser.
  27153. */
  27154. isOGGsupported: boolean;
  27155. /**
  27156. * Gets whether audio has been unlocked on the device.
  27157. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27158. * a user interaction has happened.
  27159. */
  27160. unlocked: boolean;
  27161. /**
  27162. * Defines if the audio engine relies on a custom unlocked button.
  27163. * In this case, the embedded button will not be displayed.
  27164. */
  27165. useCustomUnlockedButton: boolean;
  27166. /**
  27167. * Event raised when audio has been unlocked on the browser.
  27168. */
  27169. onAudioUnlockedObservable: Observable<AudioEngine>;
  27170. /**
  27171. * Event raised when audio has been locked on the browser.
  27172. */
  27173. onAudioLockedObservable: Observable<AudioEngine>;
  27174. /**
  27175. * Gets the current AudioContext if available.
  27176. */
  27177. readonly audioContext: Nullable<AudioContext>;
  27178. private _connectedAnalyser;
  27179. /**
  27180. * Instantiates a new audio engine.
  27181. *
  27182. * There should be only one per page as some browsers restrict the number
  27183. * of audio contexts you can create.
  27184. * @param hostElement defines the host element where to display the mute icon if necessary
  27185. */
  27186. constructor(hostElement?: Nullable<HTMLElement>);
  27187. /**
  27188. * Flags the audio engine in Locked state.
  27189. * This happens due to new browser policies preventing audio to autoplay.
  27190. */
  27191. lock(): void;
  27192. /**
  27193. * Unlocks the audio engine once a user action has been done on the dom.
  27194. * This is helpful to resume play once browser policies have been satisfied.
  27195. */
  27196. unlock(): void;
  27197. private _resumeAudioContext;
  27198. private _initializeAudioContext;
  27199. private _tryToRun;
  27200. private _triggerRunningState;
  27201. private _triggerSuspendedState;
  27202. private _displayMuteButton;
  27203. private _moveButtonToTopLeft;
  27204. private _onResize;
  27205. private _hideMuteButton;
  27206. /**
  27207. * Destroy and release the resources associated with the audio ccontext.
  27208. */
  27209. dispose(): void;
  27210. /**
  27211. * Gets the global volume sets on the master gain.
  27212. * @returns the global volume if set or -1 otherwise
  27213. */
  27214. getGlobalVolume(): number;
  27215. /**
  27216. * Sets the global volume of your experience (sets on the master gain).
  27217. * @param newVolume Defines the new global volume of the application
  27218. */
  27219. setGlobalVolume(newVolume: number): void;
  27220. /**
  27221. * Connect the audio engine to an audio analyser allowing some amazing
  27222. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27224. * @param analyser The analyser to connect to the engine
  27225. */
  27226. connectToAnalyser(analyser: Analyser): void;
  27227. }
  27228. }
  27229. declare module "babylonjs/Loading/loadingScreen" {
  27230. /**
  27231. * Interface used to present a loading screen while loading a scene
  27232. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27233. */
  27234. export interface ILoadingScreen {
  27235. /**
  27236. * Function called to display the loading screen
  27237. */
  27238. displayLoadingUI: () => void;
  27239. /**
  27240. * Function called to hide the loading screen
  27241. */
  27242. hideLoadingUI: () => void;
  27243. /**
  27244. * Gets or sets the color to use for the background
  27245. */
  27246. loadingUIBackgroundColor: string;
  27247. /**
  27248. * Gets or sets the text to display while loading
  27249. */
  27250. loadingUIText: string;
  27251. }
  27252. /**
  27253. * Class used for the default loading screen
  27254. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27255. */
  27256. export class DefaultLoadingScreen implements ILoadingScreen {
  27257. private _renderingCanvas;
  27258. private _loadingText;
  27259. private _loadingDivBackgroundColor;
  27260. private _loadingDiv;
  27261. private _loadingTextDiv;
  27262. /**
  27263. * Creates a new default loading screen
  27264. * @param _renderingCanvas defines the canvas used to render the scene
  27265. * @param _loadingText defines the default text to display
  27266. * @param _loadingDivBackgroundColor defines the default background color
  27267. */
  27268. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27269. /**
  27270. * Function called to display the loading screen
  27271. */
  27272. displayLoadingUI(): void;
  27273. /**
  27274. * Function called to hide the loading screen
  27275. */
  27276. hideLoadingUI(): void;
  27277. /**
  27278. * Gets or sets the text to display while loading
  27279. */
  27280. loadingUIText: string;
  27281. /**
  27282. * Gets or sets the color to use for the background
  27283. */
  27284. loadingUIBackgroundColor: string;
  27285. private _resizeLoadingUI;
  27286. }
  27287. }
  27288. declare module "babylonjs/Materials/Textures/videoTexture" {
  27289. import { Observable } from "babylonjs/Misc/observable";
  27290. import { Nullable } from "babylonjs/types";
  27291. import { Scene } from "babylonjs/scene";
  27292. import { Texture } from "babylonjs/Materials/Textures/texture";
  27293. /**
  27294. * Settings for finer control over video usage
  27295. */
  27296. export interface VideoTextureSettings {
  27297. /**
  27298. * Applies `autoplay` to video, if specified
  27299. */
  27300. autoPlay?: boolean;
  27301. /**
  27302. * Applies `loop` to video, if specified
  27303. */
  27304. loop?: boolean;
  27305. /**
  27306. * Automatically updates internal texture from video at every frame in the render loop
  27307. */
  27308. autoUpdateTexture: boolean;
  27309. /**
  27310. * Image src displayed during the video loading or until the user interacts with the video.
  27311. */
  27312. poster?: string;
  27313. }
  27314. /**
  27315. * If you want to display a video in your scene, this is the special texture for that.
  27316. * This special texture works similar to other textures, with the exception of a few parameters.
  27317. * @see https://doc.babylonjs.com/how_to/video_texture
  27318. */
  27319. export class VideoTexture extends Texture {
  27320. /**
  27321. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27322. */
  27323. readonly autoUpdateTexture: boolean;
  27324. /**
  27325. * The video instance used by the texture internally
  27326. */
  27327. readonly video: HTMLVideoElement;
  27328. private _onUserActionRequestedObservable;
  27329. /**
  27330. * Event triggerd when a dom action is required by the user to play the video.
  27331. * This happens due to recent changes in browser policies preventing video to auto start.
  27332. */
  27333. readonly onUserActionRequestedObservable: Observable<Texture>;
  27334. private _generateMipMaps;
  27335. private _engine;
  27336. private _stillImageCaptured;
  27337. private _displayingPosterTexture;
  27338. private _settings;
  27339. private _createInternalTextureOnEvent;
  27340. /**
  27341. * Creates a video texture.
  27342. * If you want to display a video in your scene, this is the special texture for that.
  27343. * This special texture works similar to other textures, with the exception of a few parameters.
  27344. * @see https://doc.babylonjs.com/how_to/video_texture
  27345. * @param name optional name, will detect from video source, if not defined
  27346. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27347. * @param scene is obviously the current scene.
  27348. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27349. * @param invertY is false by default but can be used to invert video on Y axis
  27350. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27351. * @param settings allows finer control over video usage
  27352. */
  27353. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27354. private _getName;
  27355. private _getVideo;
  27356. private _createInternalTexture;
  27357. private reset;
  27358. /**
  27359. * @hidden Internal method to initiate `update`.
  27360. */
  27361. _rebuild(): void;
  27362. /**
  27363. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27364. */
  27365. update(): void;
  27366. /**
  27367. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27368. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27369. */
  27370. updateTexture(isVisible: boolean): void;
  27371. protected _updateInternalTexture: () => void;
  27372. /**
  27373. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27374. * @param url New url.
  27375. */
  27376. updateURL(url: string): void;
  27377. /**
  27378. * Dispose the texture and release its associated resources.
  27379. */
  27380. dispose(): void;
  27381. /**
  27382. * Creates a video texture straight from a stream.
  27383. * @param scene Define the scene the texture should be created in
  27384. * @param stream Define the stream the texture should be created from
  27385. * @returns The created video texture as a promise
  27386. */
  27387. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27388. /**
  27389. * Creates a video texture straight from your WebCam video feed.
  27390. * @param scene Define the scene the texture should be created in
  27391. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27392. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27393. * @returns The created video texture as a promise
  27394. */
  27395. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27396. minWidth: number;
  27397. maxWidth: number;
  27398. minHeight: number;
  27399. maxHeight: number;
  27400. deviceId: string;
  27401. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27402. /**
  27403. * Creates a video texture straight from your WebCam video feed.
  27404. * @param scene Define the scene the texture should be created in
  27405. * @param onReady Define a callback to triggered once the texture will be ready
  27406. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27407. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27408. */
  27409. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27410. minWidth: number;
  27411. maxWidth: number;
  27412. minHeight: number;
  27413. maxHeight: number;
  27414. deviceId: string;
  27415. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27416. }
  27417. }
  27418. declare module "babylonjs/Engines/engine" {
  27419. import { Observable } from "babylonjs/Misc/observable";
  27420. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27421. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27422. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27423. import { Camera } from "babylonjs/Cameras/camera";
  27424. import { Scene } from "babylonjs/scene";
  27425. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27426. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27427. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27428. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27429. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27430. import { Material } from "babylonjs/Materials/material";
  27431. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27432. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27433. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27434. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27435. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27436. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27437. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27438. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27439. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27440. import { WebRequest } from "babylonjs/Misc/webRequest";
  27441. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27442. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27443. /**
  27444. * Interface for attribute information associated with buffer instanciation
  27445. */
  27446. export class InstancingAttributeInfo {
  27447. /**
  27448. * Index/offset of the attribute in the vertex shader
  27449. */
  27450. index: number;
  27451. /**
  27452. * size of the attribute, 1, 2, 3 or 4
  27453. */
  27454. attributeSize: number;
  27455. /**
  27456. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27457. * default is FLOAT
  27458. */
  27459. attribyteType: number;
  27460. /**
  27461. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27462. */
  27463. normalized: boolean;
  27464. /**
  27465. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27466. */
  27467. offset: number;
  27468. /**
  27469. * Name of the GLSL attribute, for debugging purpose only
  27470. */
  27471. attributeName: string;
  27472. }
  27473. /**
  27474. * Define options used to create a depth texture
  27475. */
  27476. export class DepthTextureCreationOptions {
  27477. /** Specifies whether or not a stencil should be allocated in the texture */
  27478. generateStencil?: boolean;
  27479. /** Specifies whether or not bilinear filtering is enable on the texture */
  27480. bilinearFiltering?: boolean;
  27481. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27482. comparisonFunction?: number;
  27483. /** Specifies if the created texture is a cube texture */
  27484. isCube?: boolean;
  27485. }
  27486. /**
  27487. * Class used to describe the capabilities of the engine relatively to the current browser
  27488. */
  27489. export class EngineCapabilities {
  27490. /** Maximum textures units per fragment shader */
  27491. maxTexturesImageUnits: number;
  27492. /** Maximum texture units per vertex shader */
  27493. maxVertexTextureImageUnits: number;
  27494. /** Maximum textures units in the entire pipeline */
  27495. maxCombinedTexturesImageUnits: number;
  27496. /** Maximum texture size */
  27497. maxTextureSize: number;
  27498. /** Maximum cube texture size */
  27499. maxCubemapTextureSize: number;
  27500. /** Maximum render texture size */
  27501. maxRenderTextureSize: number;
  27502. /** Maximum number of vertex attributes */
  27503. maxVertexAttribs: number;
  27504. /** Maximum number of varyings */
  27505. maxVaryingVectors: number;
  27506. /** Maximum number of uniforms per vertex shader */
  27507. maxVertexUniformVectors: number;
  27508. /** Maximum number of uniforms per fragment shader */
  27509. maxFragmentUniformVectors: number;
  27510. /** Defines if standard derivates (dx/dy) are supported */
  27511. standardDerivatives: boolean;
  27512. /** Defines if s3tc texture compression is supported */
  27513. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27514. /** Defines if pvrtc texture compression is supported */
  27515. pvrtc: any;
  27516. /** Defines if etc1 texture compression is supported */
  27517. etc1: any;
  27518. /** Defines if etc2 texture compression is supported */
  27519. etc2: any;
  27520. /** Defines if astc texture compression is supported */
  27521. astc: any;
  27522. /** Defines if float textures are supported */
  27523. textureFloat: boolean;
  27524. /** Defines if vertex array objects are supported */
  27525. vertexArrayObject: boolean;
  27526. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27527. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27528. /** Gets the maximum level of anisotropy supported */
  27529. maxAnisotropy: number;
  27530. /** Defines if instancing is supported */
  27531. instancedArrays: boolean;
  27532. /** Defines if 32 bits indices are supported */
  27533. uintIndices: boolean;
  27534. /** Defines if high precision shaders are supported */
  27535. highPrecisionShaderSupported: boolean;
  27536. /** Defines if depth reading in the fragment shader is supported */
  27537. fragmentDepthSupported: boolean;
  27538. /** Defines if float texture linear filtering is supported*/
  27539. textureFloatLinearFiltering: boolean;
  27540. /** Defines if rendering to float textures is supported */
  27541. textureFloatRender: boolean;
  27542. /** Defines if half float textures are supported*/
  27543. textureHalfFloat: boolean;
  27544. /** Defines if half float texture linear filtering is supported*/
  27545. textureHalfFloatLinearFiltering: boolean;
  27546. /** Defines if rendering to half float textures is supported */
  27547. textureHalfFloatRender: boolean;
  27548. /** Defines if textureLOD shader command is supported */
  27549. textureLOD: boolean;
  27550. /** Defines if draw buffers extension is supported */
  27551. drawBuffersExtension: boolean;
  27552. /** Defines if depth textures are supported */
  27553. depthTextureExtension: boolean;
  27554. /** Defines if float color buffer are supported */
  27555. colorBufferFloat: boolean;
  27556. /** Gets disjoint timer query extension (null if not supported) */
  27557. timerQuery: EXT_disjoint_timer_query;
  27558. /** Defines if timestamp can be used with timer query */
  27559. canUseTimestampForTimerQuery: boolean;
  27560. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27561. multiview: any;
  27562. /** Function used to let the system compiles shaders in background */
  27563. parallelShaderCompile: {
  27564. COMPLETION_STATUS_KHR: number;
  27565. };
  27566. }
  27567. /** Interface defining initialization parameters for Engine class */
  27568. export interface EngineOptions extends WebGLContextAttributes {
  27569. /**
  27570. * Defines if the engine should no exceed a specified device ratio
  27571. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27572. */
  27573. limitDeviceRatio?: number;
  27574. /**
  27575. * Defines if webvr should be enabled automatically
  27576. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27577. */
  27578. autoEnableWebVR?: boolean;
  27579. /**
  27580. * Defines if webgl2 should be turned off even if supported
  27581. * @see http://doc.babylonjs.com/features/webgl2
  27582. */
  27583. disableWebGL2Support?: boolean;
  27584. /**
  27585. * Defines if webaudio should be initialized as well
  27586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27587. */
  27588. audioEngine?: boolean;
  27589. /**
  27590. * Defines if animations should run using a deterministic lock step
  27591. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27592. */
  27593. deterministicLockstep?: boolean;
  27594. /** Defines the maximum steps to use with deterministic lock step mode */
  27595. lockstepMaxSteps?: number;
  27596. /**
  27597. * Defines that engine should ignore context lost events
  27598. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27599. */
  27600. doNotHandleContextLost?: boolean;
  27601. /**
  27602. * Defines that engine should ignore modifying touch action attribute and style
  27603. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27604. */
  27605. doNotHandleTouchAction?: boolean;
  27606. /**
  27607. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27608. */
  27609. useHighPrecisionFloats?: boolean;
  27610. }
  27611. /**
  27612. * Defines the interface used by display changed events
  27613. */
  27614. export interface IDisplayChangedEventArgs {
  27615. /** Gets the vrDisplay object (if any) */
  27616. vrDisplay: Nullable<any>;
  27617. /** Gets a boolean indicating if webVR is supported */
  27618. vrSupported: boolean;
  27619. }
  27620. /**
  27621. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27622. */
  27623. export class Engine {
  27624. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27625. static ExceptionList: ({
  27626. key: string;
  27627. capture: string;
  27628. captureConstraint: number;
  27629. targets: string[];
  27630. } | {
  27631. key: string;
  27632. capture: null;
  27633. captureConstraint: null;
  27634. targets: string[];
  27635. })[];
  27636. /** Gets the list of created engines */
  27637. static readonly Instances: Engine[];
  27638. /**
  27639. * Gets the latest created engine
  27640. */
  27641. static readonly LastCreatedEngine: Nullable<Engine>;
  27642. /**
  27643. * Gets the latest created scene
  27644. */
  27645. static readonly LastCreatedScene: Nullable<Scene>;
  27646. /**
  27647. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27648. * @param flag defines which part of the materials must be marked as dirty
  27649. * @param predicate defines a predicate used to filter which materials should be affected
  27650. */
  27651. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27652. /**
  27653. * Hidden
  27654. */
  27655. static _TextureLoaders: IInternalTextureLoader[];
  27656. /** Defines that alpha blending is disabled */
  27657. static readonly ALPHA_DISABLE: number;
  27658. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27659. static readonly ALPHA_ADD: number;
  27660. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27661. static readonly ALPHA_COMBINE: number;
  27662. /** Defines that alpha blending to DEST - SRC * DEST */
  27663. static readonly ALPHA_SUBTRACT: number;
  27664. /** Defines that alpha blending to SRC * DEST */
  27665. static readonly ALPHA_MULTIPLY: number;
  27666. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27667. static readonly ALPHA_MAXIMIZED: number;
  27668. /** Defines that alpha blending to SRC + DEST */
  27669. static readonly ALPHA_ONEONE: number;
  27670. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27671. static readonly ALPHA_PREMULTIPLIED: number;
  27672. /**
  27673. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27674. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27675. */
  27676. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27677. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27678. static readonly ALPHA_INTERPOLATE: number;
  27679. /**
  27680. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27681. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27682. */
  27683. static readonly ALPHA_SCREENMODE: number;
  27684. /** Defines that the ressource is not delayed*/
  27685. static readonly DELAYLOADSTATE_NONE: number;
  27686. /** Defines that the ressource was successfully delay loaded */
  27687. static readonly DELAYLOADSTATE_LOADED: number;
  27688. /** Defines that the ressource is currently delay loading */
  27689. static readonly DELAYLOADSTATE_LOADING: number;
  27690. /** Defines that the ressource is delayed and has not started loading */
  27691. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27693. static readonly NEVER: number;
  27694. /** 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 */
  27695. static readonly ALWAYS: number;
  27696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27697. static readonly LESS: number;
  27698. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27699. static readonly EQUAL: number;
  27700. /** 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 */
  27701. static readonly LEQUAL: number;
  27702. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27703. static readonly GREATER: number;
  27704. /** 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 */
  27705. static readonly GEQUAL: number;
  27706. /** 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 */
  27707. static readonly NOTEQUAL: number;
  27708. /** Passed to stencilOperation to specify that stencil value must be kept */
  27709. static readonly KEEP: number;
  27710. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27711. static readonly REPLACE: number;
  27712. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27713. static readonly INCR: number;
  27714. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27715. static readonly DECR: number;
  27716. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27717. static readonly INVERT: number;
  27718. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27719. static readonly INCR_WRAP: number;
  27720. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27721. static readonly DECR_WRAP: number;
  27722. /** Texture is not repeating outside of 0..1 UVs */
  27723. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27724. /** Texture is repeating outside of 0..1 UVs */
  27725. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27726. /** Texture is repeating and mirrored */
  27727. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27728. /** ALPHA */
  27729. static readonly TEXTUREFORMAT_ALPHA: number;
  27730. /** LUMINANCE */
  27731. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27732. /** LUMINANCE_ALPHA */
  27733. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27734. /** RGB */
  27735. static readonly TEXTUREFORMAT_RGB: number;
  27736. /** RGBA */
  27737. static readonly TEXTUREFORMAT_RGBA: number;
  27738. /** RED */
  27739. static readonly TEXTUREFORMAT_RED: number;
  27740. /** RED (2nd reference) */
  27741. static readonly TEXTUREFORMAT_R: number;
  27742. /** RG */
  27743. static readonly TEXTUREFORMAT_RG: number;
  27744. /** RED_INTEGER */
  27745. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27746. /** RED_INTEGER (2nd reference) */
  27747. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27748. /** RG_INTEGER */
  27749. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27750. /** RGB_INTEGER */
  27751. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27752. /** RGBA_INTEGER */
  27753. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27754. /** UNSIGNED_BYTE */
  27755. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27756. /** UNSIGNED_BYTE (2nd reference) */
  27757. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27758. /** FLOAT */
  27759. static readonly TEXTURETYPE_FLOAT: number;
  27760. /** HALF_FLOAT */
  27761. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27762. /** BYTE */
  27763. static readonly TEXTURETYPE_BYTE: number;
  27764. /** SHORT */
  27765. static readonly TEXTURETYPE_SHORT: number;
  27766. /** UNSIGNED_SHORT */
  27767. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27768. /** INT */
  27769. static readonly TEXTURETYPE_INT: number;
  27770. /** UNSIGNED_INT */
  27771. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27772. /** UNSIGNED_SHORT_4_4_4_4 */
  27773. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27774. /** UNSIGNED_SHORT_5_5_5_1 */
  27775. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27776. /** UNSIGNED_SHORT_5_6_5 */
  27777. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27778. /** UNSIGNED_INT_2_10_10_10_REV */
  27779. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27780. /** UNSIGNED_INT_24_8 */
  27781. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27782. /** UNSIGNED_INT_10F_11F_11F_REV */
  27783. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27784. /** UNSIGNED_INT_5_9_9_9_REV */
  27785. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27786. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27787. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27788. /** nearest is mag = nearest and min = nearest and mip = linear */
  27789. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27790. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27791. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27792. /** Trilinear is mag = linear and min = linear and mip = linear */
  27793. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27794. /** nearest is mag = nearest and min = nearest and mip = linear */
  27795. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27796. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27797. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27798. /** Trilinear is mag = linear and min = linear and mip = linear */
  27799. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27800. /** mag = nearest and min = nearest and mip = nearest */
  27801. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27802. /** mag = nearest and min = linear and mip = nearest */
  27803. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27804. /** mag = nearest and min = linear and mip = linear */
  27805. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27806. /** mag = nearest and min = linear and mip = none */
  27807. static readonly TEXTURE_NEAREST_LINEAR: number;
  27808. /** mag = nearest and min = nearest and mip = none */
  27809. static readonly TEXTURE_NEAREST_NEAREST: number;
  27810. /** mag = linear and min = nearest and mip = nearest */
  27811. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27812. /** mag = linear and min = nearest and mip = linear */
  27813. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27814. /** mag = linear and min = linear and mip = none */
  27815. static readonly TEXTURE_LINEAR_LINEAR: number;
  27816. /** mag = linear and min = nearest and mip = none */
  27817. static readonly TEXTURE_LINEAR_NEAREST: number;
  27818. /** Explicit coordinates mode */
  27819. static readonly TEXTURE_EXPLICIT_MODE: number;
  27820. /** Spherical coordinates mode */
  27821. static readonly TEXTURE_SPHERICAL_MODE: number;
  27822. /** Planar coordinates mode */
  27823. static readonly TEXTURE_PLANAR_MODE: number;
  27824. /** Cubic coordinates mode */
  27825. static readonly TEXTURE_CUBIC_MODE: number;
  27826. /** Projection coordinates mode */
  27827. static readonly TEXTURE_PROJECTION_MODE: number;
  27828. /** Skybox coordinates mode */
  27829. static readonly TEXTURE_SKYBOX_MODE: number;
  27830. /** Inverse Cubic coordinates mode */
  27831. static readonly TEXTURE_INVCUBIC_MODE: number;
  27832. /** Equirectangular coordinates mode */
  27833. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27834. /** Equirectangular Fixed coordinates mode */
  27835. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27836. /** Equirectangular Fixed Mirrored coordinates mode */
  27837. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27838. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27839. static readonly SCALEMODE_FLOOR: number;
  27840. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27841. static readonly SCALEMODE_NEAREST: number;
  27842. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27843. static readonly SCALEMODE_CEILING: number;
  27844. /**
  27845. * Returns the current npm package of the sdk
  27846. */
  27847. static readonly NpmPackage: string;
  27848. /**
  27849. * Returns the current version of the framework
  27850. */
  27851. static readonly Version: string;
  27852. /**
  27853. * Returns a string describing the current engine
  27854. */
  27855. readonly description: string;
  27856. /**
  27857. * Gets or sets the epsilon value used by collision engine
  27858. */
  27859. static CollisionsEpsilon: number;
  27860. /**
  27861. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27862. */
  27863. static ShadersRepository: string;
  27864. /**
  27865. * Method called to create the default loading screen.
  27866. * This can be overriden in your own app.
  27867. * @param canvas The rendering canvas element
  27868. * @returns The loading screen
  27869. */
  27870. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27871. /**
  27872. * Method called to create the default rescale post process on each engine.
  27873. */
  27874. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27875. /**
  27876. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27877. */
  27878. forcePOTTextures: boolean;
  27879. /**
  27880. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27881. */
  27882. isFullscreen: boolean;
  27883. /**
  27884. * Gets a boolean indicating if the pointer is currently locked
  27885. */
  27886. isPointerLock: boolean;
  27887. /**
  27888. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27889. */
  27890. cullBackFaces: boolean;
  27891. /**
  27892. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27893. */
  27894. renderEvenInBackground: boolean;
  27895. /**
  27896. * Gets or sets a boolean indicating that cache can be kept between frames
  27897. */
  27898. preventCacheWipeBetweenFrames: boolean;
  27899. /**
  27900. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27901. **/
  27902. enableOfflineSupport: boolean;
  27903. /**
  27904. * 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)
  27905. **/
  27906. disableManifestCheck: boolean;
  27907. /**
  27908. * Gets the list of created scenes
  27909. */
  27910. scenes: Scene[];
  27911. /**
  27912. * Event raised when a new scene is created
  27913. */
  27914. onNewSceneAddedObservable: Observable<Scene>;
  27915. /**
  27916. * Gets the list of created postprocesses
  27917. */
  27918. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27919. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27920. validateShaderPrograms: boolean;
  27921. /**
  27922. * Observable event triggered each time the rendering canvas is resized
  27923. */
  27924. onResizeObservable: Observable<Engine>;
  27925. /**
  27926. * Observable event triggered each time the canvas loses focus
  27927. */
  27928. onCanvasBlurObservable: Observable<Engine>;
  27929. /**
  27930. * Observable event triggered each time the canvas gains focus
  27931. */
  27932. onCanvasFocusObservable: Observable<Engine>;
  27933. /**
  27934. * Observable event triggered each time the canvas receives pointerout event
  27935. */
  27936. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27937. /**
  27938. * Observable event triggered before each texture is initialized
  27939. */
  27940. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27941. private _vrDisplay;
  27942. private _vrSupported;
  27943. private _oldSize;
  27944. private _oldHardwareScaleFactor;
  27945. private _vrExclusivePointerMode;
  27946. private _webVRInitPromise;
  27947. /**
  27948. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27949. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27950. */
  27951. readonly isInVRExclusivePointerMode: boolean;
  27952. /**
  27953. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27954. */
  27955. disableUniformBuffers: boolean;
  27956. /** @hidden */
  27957. _uniformBuffers: UniformBuffer[];
  27958. /**
  27959. * Gets a boolean indicating that the engine supports uniform buffers
  27960. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27961. */
  27962. readonly supportsUniformBuffers: boolean;
  27963. /**
  27964. * Observable raised when the engine begins a new frame
  27965. */
  27966. onBeginFrameObservable: Observable<Engine>;
  27967. /**
  27968. * If set, will be used to request the next animation frame for the render loop
  27969. */
  27970. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27971. /**
  27972. * Observable raised when the engine ends the current frame
  27973. */
  27974. onEndFrameObservable: Observable<Engine>;
  27975. /**
  27976. * Observable raised when the engine is about to compile a shader
  27977. */
  27978. onBeforeShaderCompilationObservable: Observable<Engine>;
  27979. /**
  27980. * Observable raised when the engine has jsut compiled a shader
  27981. */
  27982. onAfterShaderCompilationObservable: Observable<Engine>;
  27983. /** @hidden */
  27984. _gl: WebGLRenderingContext;
  27985. private _renderingCanvas;
  27986. private _windowIsBackground;
  27987. private _webGLVersion;
  27988. protected _highPrecisionShadersAllowed: boolean;
  27989. /** @hidden */
  27990. readonly _shouldUseHighPrecisionShader: boolean;
  27991. /**
  27992. * Gets a boolean indicating that only power of 2 textures are supported
  27993. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27994. */
  27995. readonly needPOTTextures: boolean;
  27996. /** @hidden */
  27997. _badOS: boolean;
  27998. /** @hidden */
  27999. _badDesktopOS: boolean;
  28000. /**
  28001. * Gets the audio engine
  28002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28003. * @ignorenaming
  28004. */
  28005. static audioEngine: IAudioEngine;
  28006. /**
  28007. * Default AudioEngine factory responsible of creating the Audio Engine.
  28008. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28009. */
  28010. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28011. /**
  28012. * Default offline support factory responsible of creating a tool used to store data locally.
  28013. * By default, this will create a Database object if the workload has been embedded.
  28014. */
  28015. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28016. private _onFocus;
  28017. private _onBlur;
  28018. private _onCanvasPointerOut;
  28019. private _onCanvasBlur;
  28020. private _onCanvasFocus;
  28021. private _onFullscreenChange;
  28022. private _onPointerLockChange;
  28023. private _onVRDisplayPointerRestricted;
  28024. private _onVRDisplayPointerUnrestricted;
  28025. private _onVrDisplayConnect;
  28026. private _onVrDisplayDisconnect;
  28027. private _onVrDisplayPresentChange;
  28028. /**
  28029. * Observable signaled when VR display mode changes
  28030. */
  28031. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28032. /**
  28033. * Observable signaled when VR request present is complete
  28034. */
  28035. onVRRequestPresentComplete: Observable<boolean>;
  28036. /**
  28037. * Observable signaled when VR request present starts
  28038. */
  28039. onVRRequestPresentStart: Observable<Engine>;
  28040. private _hardwareScalingLevel;
  28041. /** @hidden */
  28042. protected _caps: EngineCapabilities;
  28043. private _pointerLockRequested;
  28044. private _isStencilEnable;
  28045. private _colorWrite;
  28046. private _loadingScreen;
  28047. /** @hidden */
  28048. _drawCalls: PerfCounter;
  28049. private _glVersion;
  28050. private _glRenderer;
  28051. private _glVendor;
  28052. private _videoTextureSupported;
  28053. private _renderingQueueLaunched;
  28054. private _activeRenderLoops;
  28055. private _deterministicLockstep;
  28056. private _lockstepMaxSteps;
  28057. /**
  28058. * Observable signaled when a context lost event is raised
  28059. */
  28060. onContextLostObservable: Observable<Engine>;
  28061. /**
  28062. * Observable signaled when a context restored event is raised
  28063. */
  28064. onContextRestoredObservable: Observable<Engine>;
  28065. private _onContextLost;
  28066. private _onContextRestored;
  28067. private _contextWasLost;
  28068. private _doNotHandleContextLost;
  28069. /**
  28070. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28071. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28072. */
  28073. doNotHandleContextLost: boolean;
  28074. private _performanceMonitor;
  28075. private _fps;
  28076. private _deltaTime;
  28077. /**
  28078. * Turn this value on if you want to pause FPS computation when in background
  28079. */
  28080. disablePerformanceMonitorInBackground: boolean;
  28081. /**
  28082. * Gets the performance monitor attached to this engine
  28083. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28084. */
  28085. readonly performanceMonitor: PerformanceMonitor;
  28086. /**
  28087. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28088. */
  28089. disableVertexArrayObjects: boolean;
  28090. /** @hidden */
  28091. protected _depthCullingState: _DepthCullingState;
  28092. /** @hidden */
  28093. protected _stencilState: _StencilState;
  28094. /** @hidden */
  28095. protected _alphaState: _AlphaState;
  28096. /** @hidden */
  28097. protected _alphaMode: number;
  28098. protected _internalTexturesCache: InternalTexture[];
  28099. /** @hidden */
  28100. protected _activeChannel: number;
  28101. private _currentTextureChannel;
  28102. /** @hidden */
  28103. protected _boundTexturesCache: {
  28104. [key: string]: Nullable<InternalTexture>;
  28105. };
  28106. /** @hidden */
  28107. protected _currentEffect: Nullable<Effect>;
  28108. /** @hidden */
  28109. protected _currentProgram: Nullable<WebGLProgram>;
  28110. private _compiledEffects;
  28111. private _vertexAttribArraysEnabled;
  28112. /** @hidden */
  28113. protected _cachedViewport: Nullable<Viewport>;
  28114. private _cachedVertexArrayObject;
  28115. /** @hidden */
  28116. protected _cachedVertexBuffers: any;
  28117. /** @hidden */
  28118. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28119. /** @hidden */
  28120. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28121. /** @hidden */
  28122. protected _currentRenderTarget: Nullable<InternalTexture>;
  28123. private _uintIndicesCurrentlySet;
  28124. private _currentBoundBuffer;
  28125. /** @hidden */
  28126. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28127. private _currentBufferPointers;
  28128. private _currentInstanceLocations;
  28129. private _currentInstanceBuffers;
  28130. private _textureUnits;
  28131. private _workingCanvas;
  28132. private _workingContext;
  28133. private _rescalePostProcess;
  28134. private _dummyFramebuffer;
  28135. private _externalData;
  28136. private _bindedRenderFunction;
  28137. private _vaoRecordInProgress;
  28138. private _mustWipeVertexAttributes;
  28139. private _emptyTexture;
  28140. private _emptyCubeTexture;
  28141. private _emptyTexture3D;
  28142. /** @hidden */
  28143. _frameHandler: number;
  28144. private _nextFreeTextureSlots;
  28145. private _maxSimultaneousTextures;
  28146. private _activeRequests;
  28147. private _texturesSupported;
  28148. private _textureFormatInUse;
  28149. /**
  28150. * Gets the list of texture formats supported
  28151. */
  28152. readonly texturesSupported: Array<string>;
  28153. /**
  28154. * Gets the list of texture formats in use
  28155. */
  28156. readonly textureFormatInUse: Nullable<string>;
  28157. /**
  28158. * Gets the current viewport
  28159. */
  28160. readonly currentViewport: Nullable<Viewport>;
  28161. /**
  28162. * Gets the default empty texture
  28163. */
  28164. readonly emptyTexture: InternalTexture;
  28165. /**
  28166. * Gets the default empty 3D texture
  28167. */
  28168. readonly emptyTexture3D: InternalTexture;
  28169. /**
  28170. * Gets the default empty cube texture
  28171. */
  28172. readonly emptyCubeTexture: InternalTexture;
  28173. /**
  28174. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28175. */
  28176. readonly premultipliedAlpha: boolean;
  28177. /**
  28178. * Creates a new engine
  28179. * @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
  28180. * @param antialias defines enable antialiasing (default: false)
  28181. * @param options defines further options to be sent to the getContext() function
  28182. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28183. */
  28184. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28185. private _disableTouchAction;
  28186. private _rebuildInternalTextures;
  28187. private _rebuildEffects;
  28188. /**
  28189. * Gets a boolean indicating if all created effects are ready
  28190. * @returns true if all effects are ready
  28191. */
  28192. areAllEffectsReady(): boolean;
  28193. private _rebuildBuffers;
  28194. private _initGLContext;
  28195. /**
  28196. * Gets version of the current webGL context
  28197. */
  28198. readonly webGLVersion: number;
  28199. /**
  28200. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28201. */
  28202. readonly isStencilEnable: boolean;
  28203. private _prepareWorkingCanvas;
  28204. /**
  28205. * Reset the texture cache to empty state
  28206. */
  28207. resetTextureCache(): void;
  28208. /**
  28209. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28210. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28211. * @returns true if engine is in deterministic lock step mode
  28212. */
  28213. isDeterministicLockStep(): boolean;
  28214. /**
  28215. * Gets the max steps when engine is running in deterministic lock step
  28216. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28217. * @returns the max steps
  28218. */
  28219. getLockstepMaxSteps(): number;
  28220. /**
  28221. * Gets an object containing information about the current webGL context
  28222. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28223. */
  28224. getGlInfo(): {
  28225. vendor: string;
  28226. renderer: string;
  28227. version: string;
  28228. };
  28229. /**
  28230. * Gets current aspect ratio
  28231. * @param camera defines the camera to use to get the aspect ratio
  28232. * @param useScreen defines if screen size must be used (or the current render target if any)
  28233. * @returns a number defining the aspect ratio
  28234. */
  28235. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28236. /**
  28237. * Gets current screen aspect ratio
  28238. * @returns a number defining the aspect ratio
  28239. */
  28240. getScreenAspectRatio(): number;
  28241. /**
  28242. * Gets the current render width
  28243. * @param useScreen defines if screen size must be used (or the current render target if any)
  28244. * @returns a number defining the current render width
  28245. */
  28246. getRenderWidth(useScreen?: boolean): number;
  28247. /**
  28248. * Gets the current render height
  28249. * @param useScreen defines if screen size must be used (or the current render target if any)
  28250. * @returns a number defining the current render height
  28251. */
  28252. getRenderHeight(useScreen?: boolean): number;
  28253. /**
  28254. * Gets the HTML canvas attached with the current webGL context
  28255. * @returns a HTML canvas
  28256. */
  28257. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28258. /**
  28259. * Gets the client rect of the HTML canvas attached with the current webGL context
  28260. * @returns a client rectanglee
  28261. */
  28262. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28263. /**
  28264. * Defines the hardware scaling level.
  28265. * By default the hardware scaling level is computed from the window device ratio.
  28266. * 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.
  28267. * @param level defines the level to use
  28268. */
  28269. setHardwareScalingLevel(level: number): void;
  28270. /**
  28271. * Gets the current hardware scaling level.
  28272. * By default the hardware scaling level is computed from the window device ratio.
  28273. * 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.
  28274. * @returns a number indicating the current hardware scaling level
  28275. */
  28276. getHardwareScalingLevel(): number;
  28277. /**
  28278. * Gets the list of loaded textures
  28279. * @returns an array containing all loaded textures
  28280. */
  28281. getLoadedTexturesCache(): InternalTexture[];
  28282. /**
  28283. * Gets the object containing all engine capabilities
  28284. * @returns the EngineCapabilities object
  28285. */
  28286. getCaps(): EngineCapabilities;
  28287. /**
  28288. * Gets the current depth function
  28289. * @returns a number defining the depth function
  28290. */
  28291. getDepthFunction(): Nullable<number>;
  28292. /**
  28293. * Sets the current depth function
  28294. * @param depthFunc defines the function to use
  28295. */
  28296. setDepthFunction(depthFunc: number): void;
  28297. /**
  28298. * Sets the current depth function to GREATER
  28299. */
  28300. setDepthFunctionToGreater(): void;
  28301. /**
  28302. * Sets the current depth function to GEQUAL
  28303. */
  28304. setDepthFunctionToGreaterOrEqual(): void;
  28305. /**
  28306. * Sets the current depth function to LESS
  28307. */
  28308. setDepthFunctionToLess(): void;
  28309. private _cachedStencilBuffer;
  28310. private _cachedStencilFunction;
  28311. private _cachedStencilMask;
  28312. private _cachedStencilOperationPass;
  28313. private _cachedStencilOperationFail;
  28314. private _cachedStencilOperationDepthFail;
  28315. private _cachedStencilReference;
  28316. /**
  28317. * Caches the the state of the stencil buffer
  28318. */
  28319. cacheStencilState(): void;
  28320. /**
  28321. * Restores the state of the stencil buffer
  28322. */
  28323. restoreStencilState(): void;
  28324. /**
  28325. * Sets the current depth function to LEQUAL
  28326. */
  28327. setDepthFunctionToLessOrEqual(): void;
  28328. /**
  28329. * Gets a boolean indicating if stencil buffer is enabled
  28330. * @returns the current stencil buffer state
  28331. */
  28332. getStencilBuffer(): boolean;
  28333. /**
  28334. * Enable or disable the stencil buffer
  28335. * @param enable defines if the stencil buffer must be enabled or disabled
  28336. */
  28337. setStencilBuffer(enable: boolean): void;
  28338. /**
  28339. * Gets the current stencil mask
  28340. * @returns a number defining the new stencil mask to use
  28341. */
  28342. getStencilMask(): number;
  28343. /**
  28344. * Sets the current stencil mask
  28345. * @param mask defines the new stencil mask to use
  28346. */
  28347. setStencilMask(mask: number): void;
  28348. /**
  28349. * Gets the current stencil function
  28350. * @returns a number defining the stencil function to use
  28351. */
  28352. getStencilFunction(): number;
  28353. /**
  28354. * Gets the current stencil reference value
  28355. * @returns a number defining the stencil reference value to use
  28356. */
  28357. getStencilFunctionReference(): number;
  28358. /**
  28359. * Gets the current stencil mask
  28360. * @returns a number defining the stencil mask to use
  28361. */
  28362. getStencilFunctionMask(): number;
  28363. /**
  28364. * Sets the current stencil function
  28365. * @param stencilFunc defines the new stencil function to use
  28366. */
  28367. setStencilFunction(stencilFunc: number): void;
  28368. /**
  28369. * Sets the current stencil reference
  28370. * @param reference defines the new stencil reference to use
  28371. */
  28372. setStencilFunctionReference(reference: number): void;
  28373. /**
  28374. * Sets the current stencil mask
  28375. * @param mask defines the new stencil mask to use
  28376. */
  28377. setStencilFunctionMask(mask: number): void;
  28378. /**
  28379. * Gets the current stencil operation when stencil fails
  28380. * @returns a number defining stencil operation to use when stencil fails
  28381. */
  28382. getStencilOperationFail(): number;
  28383. /**
  28384. * Gets the current stencil operation when depth fails
  28385. * @returns a number defining stencil operation to use when depth fails
  28386. */
  28387. getStencilOperationDepthFail(): number;
  28388. /**
  28389. * Gets the current stencil operation when stencil passes
  28390. * @returns a number defining stencil operation to use when stencil passes
  28391. */
  28392. getStencilOperationPass(): number;
  28393. /**
  28394. * Sets the stencil operation to use when stencil fails
  28395. * @param operation defines the stencil operation to use when stencil fails
  28396. */
  28397. setStencilOperationFail(operation: number): void;
  28398. /**
  28399. * Sets the stencil operation to use when depth fails
  28400. * @param operation defines the stencil operation to use when depth fails
  28401. */
  28402. setStencilOperationDepthFail(operation: number): void;
  28403. /**
  28404. * Sets the stencil operation to use when stencil passes
  28405. * @param operation defines the stencil operation to use when stencil passes
  28406. */
  28407. setStencilOperationPass(operation: number): void;
  28408. /**
  28409. * Sets a boolean indicating if the dithering state is enabled or disabled
  28410. * @param value defines the dithering state
  28411. */
  28412. setDitheringState(value: boolean): void;
  28413. /**
  28414. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28415. * @param value defines the rasterizer state
  28416. */
  28417. setRasterizerState(value: boolean): void;
  28418. /**
  28419. * stop executing a render loop function and remove it from the execution array
  28420. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28421. */
  28422. stopRenderLoop(renderFunction?: () => void): void;
  28423. /** @hidden */
  28424. _renderLoop(): void;
  28425. /**
  28426. * Register and execute a render loop. The engine can have more than one render function
  28427. * @param renderFunction defines the function to continuously execute
  28428. */
  28429. runRenderLoop(renderFunction: () => void): void;
  28430. /**
  28431. * Toggle full screen mode
  28432. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28433. */
  28434. switchFullscreen(requestPointerLock: boolean): void;
  28435. /**
  28436. * Enters full screen mode
  28437. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28438. */
  28439. enterFullscreen(requestPointerLock: boolean): void;
  28440. /**
  28441. * Exits full screen mode
  28442. */
  28443. exitFullscreen(): void;
  28444. /**
  28445. * Clear the current render buffer or the current render target (if any is set up)
  28446. * @param color defines the color to use
  28447. * @param backBuffer defines if the back buffer must be cleared
  28448. * @param depth defines if the depth buffer must be cleared
  28449. * @param stencil defines if the stencil buffer must be cleared
  28450. */
  28451. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28452. /**
  28453. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28454. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28455. * @param y defines the y-coordinate of the corner of the clear rectangle
  28456. * @param width defines the width of the clear rectangle
  28457. * @param height defines the height of the clear rectangle
  28458. * @param clearColor defines the clear color
  28459. */
  28460. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28461. /**
  28462. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28463. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28464. * @param y defines the y-coordinate of the corner of the clear rectangle
  28465. * @param width defines the width of the clear rectangle
  28466. * @param height defines the height of the clear rectangle
  28467. */
  28468. enableScissor(x: number, y: number, width: number, height: number): void;
  28469. /**
  28470. * Disable previously set scissor test rectangle
  28471. */
  28472. disableScissor(): void;
  28473. private _viewportCached;
  28474. /** @hidden */
  28475. _viewport(x: number, y: number, width: number, height: number): void;
  28476. /**
  28477. * Set the WebGL's viewport
  28478. * @param viewport defines the viewport element to be used
  28479. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28480. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28481. */
  28482. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28483. /**
  28484. * Directly set the WebGL Viewport
  28485. * @param x defines the x coordinate of the viewport (in screen space)
  28486. * @param y defines the y coordinate of the viewport (in screen space)
  28487. * @param width defines the width of the viewport (in screen space)
  28488. * @param height defines the height of the viewport (in screen space)
  28489. * @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
  28490. */
  28491. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28492. /**
  28493. * Begin a new frame
  28494. */
  28495. beginFrame(): void;
  28496. /**
  28497. * Enf the current frame
  28498. */
  28499. endFrame(): void;
  28500. /**
  28501. * Resize the view according to the canvas' size
  28502. */
  28503. resize(): void;
  28504. /**
  28505. * Force a specific size of the canvas
  28506. * @param width defines the new canvas' width
  28507. * @param height defines the new canvas' height
  28508. */
  28509. setSize(width: number, height: number): void;
  28510. /**
  28511. * Gets a boolean indicating if a webVR device was detected
  28512. * @returns true if a webVR device was detected
  28513. */
  28514. isVRDevicePresent(): boolean;
  28515. /**
  28516. * Gets the current webVR device
  28517. * @returns the current webVR device (or null)
  28518. */
  28519. getVRDevice(): any;
  28520. /**
  28521. * Initializes a webVR display and starts listening to display change events
  28522. * The onVRDisplayChangedObservable will be notified upon these changes
  28523. * @returns The onVRDisplayChangedObservable
  28524. */
  28525. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28526. /**
  28527. * Initializes a webVR display and starts listening to display change events
  28528. * The onVRDisplayChangedObservable will be notified upon these changes
  28529. * @returns A promise containing a VRDisplay and if vr is supported
  28530. */
  28531. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28532. /**
  28533. * Call this function to switch to webVR mode
  28534. * Will do nothing if webVR is not supported or if there is no webVR device
  28535. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28536. */
  28537. enableVR(): void;
  28538. /**
  28539. * Call this function to leave webVR mode
  28540. * Will do nothing if webVR is not supported or if there is no webVR device
  28541. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28542. */
  28543. disableVR(): void;
  28544. private _onVRFullScreenTriggered;
  28545. private _getVRDisplaysAsync;
  28546. /**
  28547. * Binds the frame buffer to the specified texture.
  28548. * @param texture The texture to render to or null for the default canvas
  28549. * @param faceIndex The face of the texture to render to in case of cube texture
  28550. * @param requiredWidth The width of the target to render to
  28551. * @param requiredHeight The height of the target to render to
  28552. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28553. * @param depthStencilTexture The depth stencil texture to use to render
  28554. * @param lodLevel defines le lod level to bind to the frame buffer
  28555. */
  28556. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28557. private bindUnboundFramebuffer;
  28558. /**
  28559. * Unbind the current render target texture from the webGL context
  28560. * @param texture defines the render target texture to unbind
  28561. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28562. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28563. */
  28564. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28565. /**
  28566. * Unbind a list of render target textures from the webGL context
  28567. * This is used only when drawBuffer extension or webGL2 are active
  28568. * @param textures defines the render target textures to unbind
  28569. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28570. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28571. */
  28572. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28573. /**
  28574. * Force the mipmap generation for the given render target texture
  28575. * @param texture defines the render target texture to use
  28576. */
  28577. generateMipMapsForCubemap(texture: InternalTexture): void;
  28578. /**
  28579. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28580. */
  28581. flushFramebuffer(): void;
  28582. /**
  28583. * Unbind the current render target and bind the default framebuffer
  28584. */
  28585. restoreDefaultFramebuffer(): void;
  28586. /**
  28587. * Create an uniform buffer
  28588. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28589. * @param elements defines the content of the uniform buffer
  28590. * @returns the webGL uniform buffer
  28591. */
  28592. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28593. /**
  28594. * Create a dynamic uniform buffer
  28595. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28596. * @param elements defines the content of the uniform buffer
  28597. * @returns the webGL uniform buffer
  28598. */
  28599. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28600. /**
  28601. * Update an existing uniform buffer
  28602. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28603. * @param uniformBuffer defines the target uniform buffer
  28604. * @param elements defines the content to update
  28605. * @param offset defines the offset in the uniform buffer where update should start
  28606. * @param count defines the size of the data to update
  28607. */
  28608. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28609. private _resetVertexBufferBinding;
  28610. /**
  28611. * Creates a vertex buffer
  28612. * @param data the data for the vertex buffer
  28613. * @returns the new WebGL static buffer
  28614. */
  28615. createVertexBuffer(data: DataArray): WebGLBuffer;
  28616. /**
  28617. * Creates a dynamic vertex buffer
  28618. * @param data the data for the dynamic vertex buffer
  28619. * @returns the new WebGL dynamic buffer
  28620. */
  28621. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28622. /**
  28623. * Update a dynamic index buffer
  28624. * @param indexBuffer defines the target index buffer
  28625. * @param indices defines the data to update
  28626. * @param offset defines the offset in the target index buffer where update should start
  28627. */
  28628. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28629. /**
  28630. * Updates a dynamic vertex buffer.
  28631. * @param vertexBuffer the vertex buffer to update
  28632. * @param data the data used to update the vertex buffer
  28633. * @param byteOffset the byte offset of the data
  28634. * @param byteLength the byte length of the data
  28635. */
  28636. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28637. private _resetIndexBufferBinding;
  28638. /**
  28639. * Creates a new index buffer
  28640. * @param indices defines the content of the index buffer
  28641. * @param updatable defines if the index buffer must be updatable
  28642. * @returns a new webGL buffer
  28643. */
  28644. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28645. /**
  28646. * Bind a webGL buffer to the webGL context
  28647. * @param buffer defines the buffer to bind
  28648. */
  28649. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28650. /**
  28651. * Bind an uniform buffer to the current webGL context
  28652. * @param buffer defines the buffer to bind
  28653. */
  28654. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28655. /**
  28656. * Bind a buffer to the current webGL context at a given location
  28657. * @param buffer defines the buffer to bind
  28658. * @param location defines the index where to bind the buffer
  28659. */
  28660. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28661. /**
  28662. * Bind a specific block at a given index in a specific shader program
  28663. * @param shaderProgram defines the shader program
  28664. * @param blockName defines the block name
  28665. * @param index defines the index where to bind the block
  28666. */
  28667. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28668. private bindIndexBuffer;
  28669. private bindBuffer;
  28670. /**
  28671. * update the bound buffer with the given data
  28672. * @param data defines the data to update
  28673. */
  28674. updateArrayBuffer(data: Float32Array): void;
  28675. private _vertexAttribPointer;
  28676. private _bindIndexBufferWithCache;
  28677. private _bindVertexBuffersAttributes;
  28678. /**
  28679. * Records a vertex array object
  28680. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28681. * @param vertexBuffers defines the list of vertex buffers to store
  28682. * @param indexBuffer defines the index buffer to store
  28683. * @param effect defines the effect to store
  28684. * @returns the new vertex array object
  28685. */
  28686. recordVertexArrayObject(vertexBuffers: {
  28687. [key: string]: VertexBuffer;
  28688. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28689. /**
  28690. * Bind a specific vertex array object
  28691. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28692. * @param vertexArrayObject defines the vertex array object to bind
  28693. * @param indexBuffer defines the index buffer to bind
  28694. */
  28695. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28696. /**
  28697. * Bind webGl buffers directly to the webGL context
  28698. * @param vertexBuffer defines the vertex buffer to bind
  28699. * @param indexBuffer defines the index buffer to bind
  28700. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28701. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28702. * @param effect defines the effect associated with the vertex buffer
  28703. */
  28704. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28705. private _unbindVertexArrayObject;
  28706. /**
  28707. * Bind a list of vertex buffers to the webGL context
  28708. * @param vertexBuffers defines the list of vertex buffers to bind
  28709. * @param indexBuffer defines the index buffer to bind
  28710. * @param effect defines the effect associated with the vertex buffers
  28711. */
  28712. bindBuffers(vertexBuffers: {
  28713. [key: string]: Nullable<VertexBuffer>;
  28714. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28715. /**
  28716. * Unbind all instance attributes
  28717. */
  28718. unbindInstanceAttributes(): void;
  28719. /**
  28720. * Release and free the memory of a vertex array object
  28721. * @param vao defines the vertex array object to delete
  28722. */
  28723. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28724. /** @hidden */
  28725. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28726. /**
  28727. * Creates a webGL buffer to use with instanciation
  28728. * @param capacity defines the size of the buffer
  28729. * @returns the webGL buffer
  28730. */
  28731. createInstancesBuffer(capacity: number): WebGLBuffer;
  28732. /**
  28733. * Delete a webGL buffer used with instanciation
  28734. * @param buffer defines the webGL buffer to delete
  28735. */
  28736. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28737. /**
  28738. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28739. * @param instancesBuffer defines the webGL buffer to update and bind
  28740. * @param data defines the data to store in the buffer
  28741. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28742. */
  28743. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28744. /**
  28745. * Apply all cached states (depth, culling, stencil and alpha)
  28746. */
  28747. applyStates(): void;
  28748. /**
  28749. * Send a draw order
  28750. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28751. * @param indexStart defines the starting index
  28752. * @param indexCount defines the number of index to draw
  28753. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28754. */
  28755. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28756. /**
  28757. * Draw a list of points
  28758. * @param verticesStart defines the index of first vertex to draw
  28759. * @param verticesCount defines the count of vertices to draw
  28760. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28761. */
  28762. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28763. /**
  28764. * Draw a list of unindexed primitives
  28765. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28766. * @param verticesStart defines the index of first vertex to draw
  28767. * @param verticesCount defines the count of vertices to draw
  28768. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28769. */
  28770. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28771. /**
  28772. * Draw a list of indexed primitives
  28773. * @param fillMode defines the primitive to use
  28774. * @param indexStart defines the starting index
  28775. * @param indexCount defines the number of index to draw
  28776. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28777. */
  28778. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28779. /**
  28780. * Draw a list of unindexed primitives
  28781. * @param fillMode defines the primitive to use
  28782. * @param verticesStart defines the index of first vertex to draw
  28783. * @param verticesCount defines the count of vertices to draw
  28784. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28785. */
  28786. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28787. private _drawMode;
  28788. /** @hidden */
  28789. _releaseEffect(effect: Effect): void;
  28790. /** @hidden */
  28791. _deleteProgram(program: WebGLProgram): void;
  28792. /**
  28793. * Create a new effect (used to store vertex/fragment shaders)
  28794. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28795. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28796. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28797. * @param samplers defines an array of string used to represent textures
  28798. * @param defines defines the string containing the defines to use to compile the shaders
  28799. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28800. * @param onCompiled defines a function to call when the effect creation is successful
  28801. * @param onError defines a function to call when the effect creation has failed
  28802. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28803. * @returns the new Effect
  28804. */
  28805. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28806. private _compileShader;
  28807. private _compileRawShader;
  28808. /**
  28809. * Directly creates a webGL program
  28810. * @param vertexCode defines the vertex shader code to use
  28811. * @param fragmentCode defines the fragment shader code to use
  28812. * @param context defines the webGL context to use (if not set, the current one will be used)
  28813. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28814. * @returns the new webGL program
  28815. */
  28816. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28817. /**
  28818. * Creates a webGL program
  28819. * @param vertexCode defines the vertex shader code to use
  28820. * @param fragmentCode defines the fragment shader code to use
  28821. * @param defines defines the string containing the defines to use to compile the shaders
  28822. * @param context defines the webGL context to use (if not set, the current one will be used)
  28823. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28824. * @returns the new webGL program
  28825. */
  28826. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28827. private _createShaderProgram;
  28828. private _finalizeProgram;
  28829. /** @hidden */
  28830. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28831. /** @hidden */
  28832. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28833. /**
  28834. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28835. * @param shaderProgram defines the webGL program to use
  28836. * @param uniformsNames defines the list of uniform names
  28837. * @returns an array of webGL uniform locations
  28838. */
  28839. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28840. /**
  28841. * Gets the lsit of active attributes for a given webGL program
  28842. * @param shaderProgram defines the webGL program to use
  28843. * @param attributesNames defines the list of attribute names to get
  28844. * @returns an array of indices indicating the offset of each attribute
  28845. */
  28846. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28847. /**
  28848. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28849. * @param effect defines the effect to activate
  28850. */
  28851. enableEffect(effect: Nullable<Effect>): void;
  28852. /**
  28853. * Set the value of an uniform to an array of int32
  28854. * @param uniform defines the webGL uniform location where to store the value
  28855. * @param array defines the array of int32 to store
  28856. */
  28857. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28858. /**
  28859. * Set the value of an uniform to an array of int32 (stored as vec2)
  28860. * @param uniform defines the webGL uniform location where to store the value
  28861. * @param array defines the array of int32 to store
  28862. */
  28863. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28864. /**
  28865. * Set the value of an uniform to an array of int32 (stored as vec3)
  28866. * @param uniform defines the webGL uniform location where to store the value
  28867. * @param array defines the array of int32 to store
  28868. */
  28869. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28870. /**
  28871. * Set the value of an uniform to an array of int32 (stored as vec4)
  28872. * @param uniform defines the webGL uniform location where to store the value
  28873. * @param array defines the array of int32 to store
  28874. */
  28875. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28876. /**
  28877. * Set the value of an uniform to an array of float32
  28878. * @param uniform defines the webGL uniform location where to store the value
  28879. * @param array defines the array of float32 to store
  28880. */
  28881. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28882. /**
  28883. * Set the value of an uniform to an array of float32 (stored as vec2)
  28884. * @param uniform defines the webGL uniform location where to store the value
  28885. * @param array defines the array of float32 to store
  28886. */
  28887. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28888. /**
  28889. * Set the value of an uniform to an array of float32 (stored as vec3)
  28890. * @param uniform defines the webGL uniform location where to store the value
  28891. * @param array defines the array of float32 to store
  28892. */
  28893. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28894. /**
  28895. * Set the value of an uniform to an array of float32 (stored as vec4)
  28896. * @param uniform defines the webGL uniform location where to store the value
  28897. * @param array defines the array of float32 to store
  28898. */
  28899. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28900. /**
  28901. * Set the value of an uniform to an array of number
  28902. * @param uniform defines the webGL uniform location where to store the value
  28903. * @param array defines the array of number to store
  28904. */
  28905. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28906. /**
  28907. * Set the value of an uniform to an array of number (stored as vec2)
  28908. * @param uniform defines the webGL uniform location where to store the value
  28909. * @param array defines the array of number to store
  28910. */
  28911. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28912. /**
  28913. * Set the value of an uniform to an array of number (stored as vec3)
  28914. * @param uniform defines the webGL uniform location where to store the value
  28915. * @param array defines the array of number to store
  28916. */
  28917. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28918. /**
  28919. * Set the value of an uniform to an array of number (stored as vec4)
  28920. * @param uniform defines the webGL uniform location where to store the value
  28921. * @param array defines the array of number to store
  28922. */
  28923. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28924. /**
  28925. * Set the value of an uniform to an array of float32 (stored as matrices)
  28926. * @param uniform defines the webGL uniform location where to store the value
  28927. * @param matrices defines the array of float32 to store
  28928. */
  28929. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28930. /**
  28931. * Set the value of an uniform to a matrix
  28932. * @param uniform defines the webGL uniform location where to store the value
  28933. * @param matrix defines the matrix to store
  28934. */
  28935. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28936. /**
  28937. * Set the value of an uniform to a matrix (3x3)
  28938. * @param uniform defines the webGL uniform location where to store the value
  28939. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28940. */
  28941. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28942. /**
  28943. * Set the value of an uniform to a matrix (2x2)
  28944. * @param uniform defines the webGL uniform location where to store the value
  28945. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28946. */
  28947. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28948. /**
  28949. * Set the value of an uniform to a number (int)
  28950. * @param uniform defines the webGL uniform location where to store the value
  28951. * @param value defines the int number to store
  28952. */
  28953. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28954. /**
  28955. * Set the value of an uniform to a number (float)
  28956. * @param uniform defines the webGL uniform location where to store the value
  28957. * @param value defines the float number to store
  28958. */
  28959. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28960. /**
  28961. * Set the value of an uniform to a vec2
  28962. * @param uniform defines the webGL uniform location where to store the value
  28963. * @param x defines the 1st component of the value
  28964. * @param y defines the 2nd component of the value
  28965. */
  28966. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28967. /**
  28968. * Set the value of an uniform to a vec3
  28969. * @param uniform defines the webGL uniform location where to store the value
  28970. * @param x defines the 1st component of the value
  28971. * @param y defines the 2nd component of the value
  28972. * @param z defines the 3rd component of the value
  28973. */
  28974. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28975. /**
  28976. * Set the value of an uniform to a boolean
  28977. * @param uniform defines the webGL uniform location where to store the value
  28978. * @param bool defines the boolean to store
  28979. */
  28980. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28981. /**
  28982. * Set the value of an uniform to a vec4
  28983. * @param uniform defines the webGL uniform location where to store the value
  28984. * @param x defines the 1st component of the value
  28985. * @param y defines the 2nd component of the value
  28986. * @param z defines the 3rd component of the value
  28987. * @param w defines the 4th component of the value
  28988. */
  28989. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28990. /**
  28991. * Set the value of an uniform to a Color3
  28992. * @param uniform defines the webGL uniform location where to store the value
  28993. * @param color3 defines the color to store
  28994. */
  28995. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28996. /**
  28997. * Set the value of an uniform to a Color3 and an alpha value
  28998. * @param uniform defines the webGL uniform location where to store the value
  28999. * @param color3 defines the color to store
  29000. * @param alpha defines the alpha component to store
  29001. */
  29002. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29003. /**
  29004. * Sets a Color4 on a uniform variable
  29005. * @param uniform defines the uniform location
  29006. * @param color4 defines the value to be set
  29007. */
  29008. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29009. /**
  29010. * Set various states to the webGL context
  29011. * @param culling defines backface culling state
  29012. * @param zOffset defines the value to apply to zOffset (0 by default)
  29013. * @param force defines if states must be applied even if cache is up to date
  29014. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29015. */
  29016. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29017. /**
  29018. * Set the z offset to apply to current rendering
  29019. * @param value defines the offset to apply
  29020. */
  29021. setZOffset(value: number): void;
  29022. /**
  29023. * Gets the current value of the zOffset
  29024. * @returns the current zOffset state
  29025. */
  29026. getZOffset(): number;
  29027. /**
  29028. * Enable or disable depth buffering
  29029. * @param enable defines the state to set
  29030. */
  29031. setDepthBuffer(enable: boolean): void;
  29032. /**
  29033. * Gets a boolean indicating if depth writing is enabled
  29034. * @returns the current depth writing state
  29035. */
  29036. getDepthWrite(): boolean;
  29037. /**
  29038. * Enable or disable depth writing
  29039. * @param enable defines the state to set
  29040. */
  29041. setDepthWrite(enable: boolean): void;
  29042. /**
  29043. * Enable or disable color writing
  29044. * @param enable defines the state to set
  29045. */
  29046. setColorWrite(enable: boolean): void;
  29047. /**
  29048. * Gets a boolean indicating if color writing is enabled
  29049. * @returns the current color writing state
  29050. */
  29051. getColorWrite(): boolean;
  29052. /**
  29053. * Sets alpha constants used by some alpha blending modes
  29054. * @param r defines the red component
  29055. * @param g defines the green component
  29056. * @param b defines the blue component
  29057. * @param a defines the alpha component
  29058. */
  29059. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29060. /**
  29061. * Sets the current alpha mode
  29062. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29063. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29064. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29065. */
  29066. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29067. /**
  29068. * Gets the current alpha mode
  29069. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29070. * @returns the current alpha mode
  29071. */
  29072. getAlphaMode(): number;
  29073. /**
  29074. * Clears the list of texture accessible through engine.
  29075. * This can help preventing texture load conflict due to name collision.
  29076. */
  29077. clearInternalTexturesCache(): void;
  29078. /**
  29079. * Force the entire cache to be cleared
  29080. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29081. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29082. */
  29083. wipeCaches(bruteForce?: boolean): void;
  29084. /**
  29085. * Set the compressed texture format to use, based on the formats you have, and the formats
  29086. * supported by the hardware / browser.
  29087. *
  29088. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29089. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29090. * to API arguments needed to compressed textures. This puts the burden on the container
  29091. * generator to house the arcane code for determining these for current & future formats.
  29092. *
  29093. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29094. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29095. *
  29096. * Note: The result of this call is not taken into account when a texture is base64.
  29097. *
  29098. * @param formatsAvailable defines the list of those format families you have created
  29099. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29100. *
  29101. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29102. * @returns The extension selected.
  29103. */
  29104. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29105. private _getSamplingParameters;
  29106. private _partialLoadImg;
  29107. private _cascadeLoadImgs;
  29108. /** @hidden */
  29109. _createTexture(): WebGLTexture;
  29110. /**
  29111. * Usually called from Texture.ts.
  29112. * Passed information to create a WebGLTexture
  29113. * @param urlArg defines a value which contains one of the following:
  29114. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29115. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29116. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29117. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29118. * @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)
  29119. * @param scene needed for loading to the correct scene
  29120. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29121. * @param onLoad optional callback to be called upon successful completion
  29122. * @param onError optional callback to be called upon failure
  29123. * @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
  29124. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29125. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29126. * @param forcedExtension defines the extension to use to pick the right loader
  29127. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29128. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29129. */
  29130. 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;
  29131. private _rescaleTexture;
  29132. /**
  29133. * Update a raw texture
  29134. * @param texture defines the texture to update
  29135. * @param data defines the data to store in the texture
  29136. * @param format defines the format of the data
  29137. * @param invertY defines if data must be stored with Y axis inverted
  29138. * @param compression defines the compression used (null by default)
  29139. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29140. */
  29141. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29142. /**
  29143. * Creates a raw texture
  29144. * @param data defines the data to store in the texture
  29145. * @param width defines the width of the texture
  29146. * @param height defines the height of the texture
  29147. * @param format defines the format of the data
  29148. * @param generateMipMaps defines if the engine should generate the mip levels
  29149. * @param invertY defines if data must be stored with Y axis inverted
  29150. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29151. * @param compression defines the compression used (null by default)
  29152. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29153. * @returns the raw texture inside an InternalTexture
  29154. */
  29155. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29156. private _unpackFlipYCached;
  29157. /**
  29158. * In case you are sharing the context with other applications, it might
  29159. * be interested to not cache the unpack flip y state to ensure a consistent
  29160. * value would be set.
  29161. */
  29162. enableUnpackFlipYCached: boolean;
  29163. /** @hidden */
  29164. _unpackFlipY(value: boolean): void;
  29165. /** @hidden */
  29166. _getUnpackAlignement(): number;
  29167. /**
  29168. * Creates a dynamic texture
  29169. * @param width defines the width of the texture
  29170. * @param height defines the height of the texture
  29171. * @param generateMipMaps defines if the engine should generate the mip levels
  29172. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29173. * @returns the dynamic texture inside an InternalTexture
  29174. */
  29175. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29176. /**
  29177. * Update the sampling mode of a given texture
  29178. * @param samplingMode defines the required sampling mode
  29179. * @param texture defines the texture to update
  29180. */
  29181. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29182. /**
  29183. * Update the content of a dynamic texture
  29184. * @param texture defines the texture to update
  29185. * @param canvas defines the canvas containing the source
  29186. * @param invertY defines if data must be stored with Y axis inverted
  29187. * @param premulAlpha defines if alpha is stored as premultiplied
  29188. * @param format defines the format of the data
  29189. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29190. */
  29191. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29192. /**
  29193. * Update a video texture
  29194. * @param texture defines the texture to update
  29195. * @param video defines the video element to use
  29196. * @param invertY defines if data must be stored with Y axis inverted
  29197. */
  29198. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29199. /**
  29200. * Updates a depth texture Comparison Mode and Function.
  29201. * If the comparison Function is equal to 0, the mode will be set to none.
  29202. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29203. * @param texture The texture to set the comparison function for
  29204. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29205. */
  29206. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29207. private _setupDepthStencilTexture;
  29208. /**
  29209. * Creates a depth stencil texture.
  29210. * This is only available in WebGL 2 or with the depth texture extension available.
  29211. * @param size The size of face edge in the texture.
  29212. * @param options The options defining the texture.
  29213. * @returns The texture
  29214. */
  29215. createDepthStencilTexture(size: number | {
  29216. width: number;
  29217. height: number;
  29218. }, options: DepthTextureCreationOptions): InternalTexture;
  29219. /**
  29220. * Creates a depth stencil texture.
  29221. * This is only available in WebGL 2 or with the depth texture extension available.
  29222. * @param size The size of face edge in the texture.
  29223. * @param options The options defining the texture.
  29224. * @returns The texture
  29225. */
  29226. private _createDepthStencilTexture;
  29227. /**
  29228. * Creates a depth stencil cube texture.
  29229. * This is only available in WebGL 2.
  29230. * @param size The size of face edge in the cube texture.
  29231. * @param options The options defining the cube texture.
  29232. * @returns The cube texture
  29233. */
  29234. private _createDepthStencilCubeTexture;
  29235. /**
  29236. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29237. * @param renderTarget The render target to set the frame buffer for
  29238. */
  29239. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29240. /**
  29241. * Creates a new render target texture
  29242. * @param size defines the size of the texture
  29243. * @param options defines the options used to create the texture
  29244. * @returns a new render target texture stored in an InternalTexture
  29245. */
  29246. createRenderTargetTexture(size: number | {
  29247. width: number;
  29248. height: number;
  29249. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29250. /**
  29251. * Create a multi render target texture
  29252. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29253. * @param size defines the size of the texture
  29254. * @param options defines the creation options
  29255. * @returns the cube texture as an InternalTexture
  29256. */
  29257. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29258. private _setupFramebufferDepthAttachments;
  29259. /**
  29260. * Updates the sample count of a render target texture
  29261. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29262. * @param texture defines the texture to update
  29263. * @param samples defines the sample count to set
  29264. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29265. */
  29266. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29267. /**
  29268. * Update the sample count for a given multiple render target texture
  29269. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29270. * @param textures defines the textures to update
  29271. * @param samples defines the sample count to set
  29272. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29273. */
  29274. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29275. /** @hidden */
  29276. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29277. /** @hidden */
  29278. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29279. /** @hidden */
  29280. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29281. /** @hidden */
  29282. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29283. /**
  29284. * Creates a new render target cube texture
  29285. * @param size defines the size of the texture
  29286. * @param options defines the options used to create the texture
  29287. * @returns a new render target cube texture stored in an InternalTexture
  29288. */
  29289. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29290. /**
  29291. * Creates a cube texture
  29292. * @param rootUrl defines the url where the files to load is located
  29293. * @param scene defines the current scene
  29294. * @param files defines the list of files to load (1 per face)
  29295. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29296. * @param onLoad defines an optional callback raised when the texture is loaded
  29297. * @param onError defines an optional callback raised if there is an issue to load the texture
  29298. * @param format defines the format of the data
  29299. * @param forcedExtension defines the extension to use to pick the right loader
  29300. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29301. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29302. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29303. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29304. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29305. * @returns the cube texture as an InternalTexture
  29306. */
  29307. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29308. /**
  29309. * @hidden
  29310. */
  29311. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29312. /**
  29313. * Update a raw cube texture
  29314. * @param texture defines the texture to udpdate
  29315. * @param data defines the data to store
  29316. * @param format defines the data format
  29317. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29318. * @param invertY defines if data must be stored with Y axis inverted
  29319. * @param compression defines the compression used (null by default)
  29320. * @param level defines which level of the texture to update
  29321. */
  29322. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29323. /**
  29324. * Creates a new raw cube texture
  29325. * @param data defines the array of data to use to create each face
  29326. * @param size defines the size of the textures
  29327. * @param format defines the format of the data
  29328. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29329. * @param generateMipMaps defines if the engine should generate the mip levels
  29330. * @param invertY defines if data must be stored with Y axis inverted
  29331. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29332. * @param compression defines the compression used (null by default)
  29333. * @returns the cube texture as an InternalTexture
  29334. */
  29335. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29336. /**
  29337. * Creates a new raw cube texture from a specified url
  29338. * @param url defines the url where the data is located
  29339. * @param scene defines the current scene
  29340. * @param size defines the size of the textures
  29341. * @param format defines the format of the data
  29342. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29343. * @param noMipmap defines if the engine should avoid generating the mip levels
  29344. * @param callback defines a callback used to extract texture data from loaded data
  29345. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29346. * @param onLoad defines a callback called when texture is loaded
  29347. * @param onError defines a callback called if there is an error
  29348. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29349. * @param invertY defines if data must be stored with Y axis inverted
  29350. * @returns the cube texture as an InternalTexture
  29351. */
  29352. 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;
  29353. /**
  29354. * Update a raw 3D texture
  29355. * @param texture defines the texture to update
  29356. * @param data defines the data to store
  29357. * @param format defines the data format
  29358. * @param invertY defines if data must be stored with Y axis inverted
  29359. * @param compression defines the used compression (can be null)
  29360. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29361. */
  29362. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29363. /**
  29364. * Creates a new raw 3D texture
  29365. * @param data defines the data used to create the texture
  29366. * @param width defines the width of the texture
  29367. * @param height defines the height of the texture
  29368. * @param depth defines the depth of the texture
  29369. * @param format defines the format of the texture
  29370. * @param generateMipMaps defines if the engine must generate mip levels
  29371. * @param invertY defines if data must be stored with Y axis inverted
  29372. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29373. * @param compression defines the compressed used (can be null)
  29374. * @param textureType defines the compressed used (can be null)
  29375. * @returns a new raw 3D texture (stored in an InternalTexture)
  29376. */
  29377. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29378. private _prepareWebGLTextureContinuation;
  29379. private _prepareWebGLTexture;
  29380. private _convertRGBtoRGBATextureData;
  29381. /** @hidden */
  29382. _releaseFramebufferObjects(texture: InternalTexture): void;
  29383. /** @hidden */
  29384. _releaseTexture(texture: InternalTexture): void;
  29385. private setProgram;
  29386. private _boundUniforms;
  29387. /**
  29388. * Binds an effect to the webGL context
  29389. * @param effect defines the effect to bind
  29390. */
  29391. bindSamplers(effect: Effect): void;
  29392. private _activateCurrentTexture;
  29393. /** @hidden */
  29394. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29395. /** @hidden */
  29396. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29397. /**
  29398. * Sets a texture to the webGL context from a postprocess
  29399. * @param channel defines the channel to use
  29400. * @param postProcess defines the source postprocess
  29401. */
  29402. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29403. /**
  29404. * Binds the output of the passed in post process to the texture channel specified
  29405. * @param channel The channel the texture should be bound to
  29406. * @param postProcess The post process which's output should be bound
  29407. */
  29408. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29409. /**
  29410. * Unbind all textures from the webGL context
  29411. */
  29412. unbindAllTextures(): void;
  29413. /**
  29414. * Sets a texture to the according uniform.
  29415. * @param channel The texture channel
  29416. * @param uniform The uniform to set
  29417. * @param texture The texture to apply
  29418. */
  29419. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29420. /**
  29421. * Sets a depth stencil texture from a render target to the according uniform.
  29422. * @param channel The texture channel
  29423. * @param uniform The uniform to set
  29424. * @param texture The render target texture containing the depth stencil texture to apply
  29425. */
  29426. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29427. private _bindSamplerUniformToChannel;
  29428. private _getTextureWrapMode;
  29429. private _setTexture;
  29430. /**
  29431. * Sets an array of texture to the webGL context
  29432. * @param channel defines the channel where the texture array must be set
  29433. * @param uniform defines the associated uniform location
  29434. * @param textures defines the array of textures to bind
  29435. */
  29436. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29437. /** @hidden */
  29438. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29439. private _setTextureParameterFloat;
  29440. private _setTextureParameterInteger;
  29441. /**
  29442. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29443. * @param x defines the x coordinate of the rectangle where pixels must be read
  29444. * @param y defines the y coordinate of the rectangle where pixels must be read
  29445. * @param width defines the width of the rectangle where pixels must be read
  29446. * @param height defines the height of the rectangle where pixels must be read
  29447. * @returns a Uint8Array containing RGBA colors
  29448. */
  29449. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29450. /**
  29451. * Add an externaly attached data from its key.
  29452. * This method call will fail and return false, if such key already exists.
  29453. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29454. * @param key the unique key that identifies the data
  29455. * @param data the data object to associate to the key for this Engine instance
  29456. * @return true if no such key were already present and the data was added successfully, false otherwise
  29457. */
  29458. addExternalData<T>(key: string, data: T): boolean;
  29459. /**
  29460. * Get an externaly attached data from its key
  29461. * @param key the unique key that identifies the data
  29462. * @return the associated data, if present (can be null), or undefined if not present
  29463. */
  29464. getExternalData<T>(key: string): T;
  29465. /**
  29466. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29467. * @param key the unique key that identifies the data
  29468. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29469. * @return the associated data, can be null if the factory returned null.
  29470. */
  29471. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29472. /**
  29473. * Remove an externaly attached data from the Engine instance
  29474. * @param key the unique key that identifies the data
  29475. * @return true if the data was successfully removed, false if it doesn't exist
  29476. */
  29477. removeExternalData(key: string): boolean;
  29478. /**
  29479. * Unbind all vertex attributes from the webGL context
  29480. */
  29481. unbindAllAttributes(): void;
  29482. /**
  29483. * 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
  29484. */
  29485. releaseEffects(): void;
  29486. /**
  29487. * Dispose and release all associated resources
  29488. */
  29489. dispose(): void;
  29490. /**
  29491. * Display the loading screen
  29492. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29493. */
  29494. displayLoadingUI(): void;
  29495. /**
  29496. * Hide the loading screen
  29497. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29498. */
  29499. hideLoadingUI(): void;
  29500. /**
  29501. * Gets the current loading screen object
  29502. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29503. */
  29504. /**
  29505. * Sets the current loading screen object
  29506. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29507. */
  29508. loadingScreen: ILoadingScreen;
  29509. /**
  29510. * Sets the current loading screen text
  29511. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29512. */
  29513. loadingUIText: string;
  29514. /**
  29515. * Sets the current loading screen background color
  29516. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29517. */
  29518. loadingUIBackgroundColor: string;
  29519. /**
  29520. * Attach a new callback raised when context lost event is fired
  29521. * @param callback defines the callback to call
  29522. */
  29523. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29524. /**
  29525. * Attach a new callback raised when context restored event is fired
  29526. * @param callback defines the callback to call
  29527. */
  29528. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29529. /**
  29530. * Gets the source code of the vertex shader associated with a specific webGL program
  29531. * @param program defines the program to use
  29532. * @returns a string containing the source code of the vertex shader associated with the program
  29533. */
  29534. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29535. /**
  29536. * Gets the source code of the fragment shader associated with a specific webGL program
  29537. * @param program defines the program to use
  29538. * @returns a string containing the source code of the fragment shader associated with the program
  29539. */
  29540. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29541. /**
  29542. * Get the current error code of the webGL context
  29543. * @returns the error code
  29544. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29545. */
  29546. getError(): number;
  29547. /**
  29548. * Gets the current framerate
  29549. * @returns a number representing the framerate
  29550. */
  29551. getFps(): number;
  29552. /**
  29553. * Gets the time spent between current and previous frame
  29554. * @returns a number representing the delta time in ms
  29555. */
  29556. getDeltaTime(): number;
  29557. private _measureFps;
  29558. /** @hidden */
  29559. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29560. private _canRenderToFloatFramebuffer;
  29561. private _canRenderToHalfFloatFramebuffer;
  29562. private _canRenderToFramebuffer;
  29563. /** @hidden */
  29564. _getWebGLTextureType(type: number): number;
  29565. private _getInternalFormat;
  29566. /** @hidden */
  29567. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29568. /** @hidden */
  29569. _getRGBAMultiSampleBufferFormat(type: number): number;
  29570. /** @hidden */
  29571. _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;
  29572. /** @hidden */
  29573. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29574. private _partialLoadFile;
  29575. private _cascadeLoadFiles;
  29576. /**
  29577. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29578. * @returns true if the engine can be created
  29579. * @ignorenaming
  29580. */
  29581. static isSupported(): boolean;
  29582. }
  29583. }
  29584. declare module "babylonjs/Materials/effect" {
  29585. import { Observable } from "babylonjs/Misc/observable";
  29586. import { Nullable } from "babylonjs/types";
  29587. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29588. import { IDisposable } from "babylonjs/scene";
  29589. import { Engine } from "babylonjs/Engines/engine";
  29590. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29591. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29592. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29593. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29595. /**
  29596. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29597. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29598. */
  29599. export class EffectFallbacks {
  29600. private _defines;
  29601. private _currentRank;
  29602. private _maxRank;
  29603. private _mesh;
  29604. /**
  29605. * Removes the fallback from the bound mesh.
  29606. */
  29607. unBindMesh(): void;
  29608. /**
  29609. * Adds a fallback on the specified property.
  29610. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29611. * @param define The name of the define in the shader
  29612. */
  29613. addFallback(rank: number, define: string): void;
  29614. /**
  29615. * Sets the mesh to use CPU skinning when needing to fallback.
  29616. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29617. * @param mesh The mesh to use the fallbacks.
  29618. */
  29619. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29620. /**
  29621. * Checks to see if more fallbacks are still availible.
  29622. */
  29623. readonly isMoreFallbacks: boolean;
  29624. /**
  29625. * Removes the defines that shoould be removed when falling back.
  29626. * @param currentDefines defines the current define statements for the shader.
  29627. * @param effect defines the current effect we try to compile
  29628. * @returns The resulting defines with defines of the current rank removed.
  29629. */
  29630. reduce(currentDefines: string, effect: Effect): string;
  29631. }
  29632. /**
  29633. * Options to be used when creating an effect.
  29634. */
  29635. export class EffectCreationOptions {
  29636. /**
  29637. * Atrributes that will be used in the shader.
  29638. */
  29639. attributes: string[];
  29640. /**
  29641. * Uniform varible names that will be set in the shader.
  29642. */
  29643. uniformsNames: string[];
  29644. /**
  29645. * Uniform buffer varible names that will be set in the shader.
  29646. */
  29647. uniformBuffersNames: string[];
  29648. /**
  29649. * Sampler texture variable names that will be set in the shader.
  29650. */
  29651. samplers: string[];
  29652. /**
  29653. * Define statements that will be set in the shader.
  29654. */
  29655. defines: any;
  29656. /**
  29657. * Possible fallbacks for this effect to improve performance when needed.
  29658. */
  29659. fallbacks: Nullable<EffectFallbacks>;
  29660. /**
  29661. * Callback that will be called when the shader is compiled.
  29662. */
  29663. onCompiled: Nullable<(effect: Effect) => void>;
  29664. /**
  29665. * Callback that will be called if an error occurs during shader compilation.
  29666. */
  29667. onError: Nullable<(effect: Effect, errors: string) => void>;
  29668. /**
  29669. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29670. */
  29671. indexParameters: any;
  29672. /**
  29673. * Max number of lights that can be used in the shader.
  29674. */
  29675. maxSimultaneousLights: number;
  29676. /**
  29677. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29678. */
  29679. transformFeedbackVaryings: Nullable<string[]>;
  29680. }
  29681. /**
  29682. * Effect containing vertex and fragment shader that can be executed on an object.
  29683. */
  29684. export class Effect implements IDisposable {
  29685. /**
  29686. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29687. */
  29688. static ShadersRepository: string;
  29689. /**
  29690. * Name of the effect.
  29691. */
  29692. name: any;
  29693. /**
  29694. * String container all the define statements that should be set on the shader.
  29695. */
  29696. defines: string;
  29697. /**
  29698. * Callback that will be called when the shader is compiled.
  29699. */
  29700. onCompiled: Nullable<(effect: Effect) => void>;
  29701. /**
  29702. * Callback that will be called if an error occurs during shader compilation.
  29703. */
  29704. onError: Nullable<(effect: Effect, errors: string) => void>;
  29705. /**
  29706. * Callback that will be called when effect is bound.
  29707. */
  29708. onBind: Nullable<(effect: Effect) => void>;
  29709. /**
  29710. * Unique ID of the effect.
  29711. */
  29712. uniqueId: number;
  29713. /**
  29714. * Observable that will be called when the shader is compiled.
  29715. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29716. */
  29717. onCompileObservable: Observable<Effect>;
  29718. /**
  29719. * Observable that will be called if an error occurs during shader compilation.
  29720. */
  29721. onErrorObservable: Observable<Effect>;
  29722. /** @hidden */
  29723. _onBindObservable: Nullable<Observable<Effect>>;
  29724. /**
  29725. * Observable that will be called when effect is bound.
  29726. */
  29727. readonly onBindObservable: Observable<Effect>;
  29728. /** @hidden */
  29729. _bonesComputationForcedToCPU: boolean;
  29730. private static _uniqueIdSeed;
  29731. private _engine;
  29732. private _uniformBuffersNames;
  29733. private _uniformsNames;
  29734. private _samplerList;
  29735. private _samplers;
  29736. private _isReady;
  29737. private _compilationError;
  29738. private _attributesNames;
  29739. private _attributes;
  29740. private _uniforms;
  29741. /**
  29742. * Key for the effect.
  29743. * @hidden
  29744. */
  29745. _key: string;
  29746. private _indexParameters;
  29747. private _fallbacks;
  29748. private _vertexSourceCode;
  29749. private _fragmentSourceCode;
  29750. private _vertexSourceCodeOverride;
  29751. private _fragmentSourceCodeOverride;
  29752. private _transformFeedbackVaryings;
  29753. /**
  29754. * Compiled shader to webGL program.
  29755. * @hidden
  29756. */
  29757. _program: WebGLProgram;
  29758. private _valueCache;
  29759. private static _baseCache;
  29760. /**
  29761. * Instantiates an effect.
  29762. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29763. * @param baseName Name of the effect.
  29764. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29765. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29766. * @param samplers List of sampler variables that will be passed to the shader.
  29767. * @param engine Engine to be used to render the effect
  29768. * @param defines Define statements to be added to the shader.
  29769. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29770. * @param onCompiled Callback that will be called when the shader is compiled.
  29771. * @param onError Callback that will be called if an error occurs during shader compilation.
  29772. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29773. */
  29774. 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);
  29775. /**
  29776. * Unique key for this effect
  29777. */
  29778. readonly key: string;
  29779. /**
  29780. * If the effect has been compiled and prepared.
  29781. * @returns if the effect is compiled and prepared.
  29782. */
  29783. isReady(): boolean;
  29784. /**
  29785. * The engine the effect was initialized with.
  29786. * @returns the engine.
  29787. */
  29788. getEngine(): Engine;
  29789. /**
  29790. * The compiled webGL program for the effect
  29791. * @returns the webGL program.
  29792. */
  29793. getProgram(): WebGLProgram;
  29794. /**
  29795. * The set of names of attribute variables for the shader.
  29796. * @returns An array of attribute names.
  29797. */
  29798. getAttributesNames(): string[];
  29799. /**
  29800. * Returns the attribute at the given index.
  29801. * @param index The index of the attribute.
  29802. * @returns The location of the attribute.
  29803. */
  29804. getAttributeLocation(index: number): number;
  29805. /**
  29806. * Returns the attribute based on the name of the variable.
  29807. * @param name of the attribute to look up.
  29808. * @returns the attribute location.
  29809. */
  29810. getAttributeLocationByName(name: string): number;
  29811. /**
  29812. * The number of attributes.
  29813. * @returns the numnber of attributes.
  29814. */
  29815. getAttributesCount(): number;
  29816. /**
  29817. * Gets the index of a uniform variable.
  29818. * @param uniformName of the uniform to look up.
  29819. * @returns the index.
  29820. */
  29821. getUniformIndex(uniformName: string): number;
  29822. /**
  29823. * Returns the attribute based on the name of the variable.
  29824. * @param uniformName of the uniform to look up.
  29825. * @returns the location of the uniform.
  29826. */
  29827. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29828. /**
  29829. * Returns an array of sampler variable names
  29830. * @returns The array of sampler variable neames.
  29831. */
  29832. getSamplers(): string[];
  29833. /**
  29834. * The error from the last compilation.
  29835. * @returns the error string.
  29836. */
  29837. getCompilationError(): string;
  29838. /**
  29839. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29840. * @param func The callback to be used.
  29841. */
  29842. executeWhenCompiled(func: (effect: Effect) => void): void;
  29843. private _checkIsReady;
  29844. /** @hidden */
  29845. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29846. /** @hidden */
  29847. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29848. /** @hidden */
  29849. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29850. private _processShaderConversion;
  29851. private _processIncludes;
  29852. private _processPrecision;
  29853. /**
  29854. * Recompiles the webGL program
  29855. * @param vertexSourceCode The source code for the vertex shader.
  29856. * @param fragmentSourceCode The source code for the fragment shader.
  29857. * @param onCompiled Callback called when completed.
  29858. * @param onError Callback called on error.
  29859. * @hidden
  29860. */
  29861. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29862. /**
  29863. * Gets the uniform locations of the the specified variable names
  29864. * @param names THe names of the variables to lookup.
  29865. * @returns Array of locations in the same order as variable names.
  29866. */
  29867. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29868. /**
  29869. * Prepares the effect
  29870. * @hidden
  29871. */
  29872. _prepareEffect(): void;
  29873. /**
  29874. * Checks if the effect is supported. (Must be called after compilation)
  29875. */
  29876. readonly isSupported: boolean;
  29877. /**
  29878. * Binds a texture to the engine to be used as output of the shader.
  29879. * @param channel Name of the output variable.
  29880. * @param texture Texture to bind.
  29881. * @hidden
  29882. */
  29883. _bindTexture(channel: string, texture: InternalTexture): void;
  29884. /**
  29885. * Sets a texture on the engine to be used in the shader.
  29886. * @param channel Name of the sampler variable.
  29887. * @param texture Texture to set.
  29888. */
  29889. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29890. /**
  29891. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29892. * @param channel Name of the sampler variable.
  29893. * @param texture Texture to set.
  29894. */
  29895. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29896. /**
  29897. * Sets an array of textures on the engine to be used in the shader.
  29898. * @param channel Name of the variable.
  29899. * @param textures Textures to set.
  29900. */
  29901. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29902. /**
  29903. * 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)
  29904. * @param channel Name of the sampler variable.
  29905. * @param postProcess Post process to get the input texture from.
  29906. */
  29907. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29908. /**
  29909. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29910. * 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)
  29911. * @param channel Name of the sampler variable.
  29912. * @param postProcess Post process to get the output texture from.
  29913. */
  29914. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29915. /** @hidden */
  29916. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29917. /** @hidden */
  29918. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29919. /** @hidden */
  29920. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29921. /** @hidden */
  29922. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29923. /**
  29924. * Binds a buffer to a uniform.
  29925. * @param buffer Buffer to bind.
  29926. * @param name Name of the uniform variable to bind to.
  29927. */
  29928. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29929. /**
  29930. * Binds block to a uniform.
  29931. * @param blockName Name of the block to bind.
  29932. * @param index Index to bind.
  29933. */
  29934. bindUniformBlock(blockName: string, index: number): void;
  29935. /**
  29936. * Sets an interger value on a uniform variable.
  29937. * @param uniformName Name of the variable.
  29938. * @param value Value to be set.
  29939. * @returns this effect.
  29940. */
  29941. setInt(uniformName: string, value: number): Effect;
  29942. /**
  29943. * Sets an int array on a uniform variable.
  29944. * @param uniformName Name of the variable.
  29945. * @param array array to be set.
  29946. * @returns this effect.
  29947. */
  29948. setIntArray(uniformName: string, array: Int32Array): Effect;
  29949. /**
  29950. * 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)
  29951. * @param uniformName Name of the variable.
  29952. * @param array array to be set.
  29953. * @returns this effect.
  29954. */
  29955. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29956. /**
  29957. * 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)
  29958. * @param uniformName Name of the variable.
  29959. * @param array array to be set.
  29960. * @returns this effect.
  29961. */
  29962. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29963. /**
  29964. * 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)
  29965. * @param uniformName Name of the variable.
  29966. * @param array array to be set.
  29967. * @returns this effect.
  29968. */
  29969. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29970. /**
  29971. * Sets an float array on a uniform variable.
  29972. * @param uniformName Name of the variable.
  29973. * @param array array to be set.
  29974. * @returns this effect.
  29975. */
  29976. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29977. /**
  29978. * 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)
  29979. * @param uniformName Name of the variable.
  29980. * @param array array to be set.
  29981. * @returns this effect.
  29982. */
  29983. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29984. /**
  29985. * 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)
  29986. * @param uniformName Name of the variable.
  29987. * @param array array to be set.
  29988. * @returns this effect.
  29989. */
  29990. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29991. /**
  29992. * 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)
  29993. * @param uniformName Name of the variable.
  29994. * @param array array to be set.
  29995. * @returns this effect.
  29996. */
  29997. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29998. /**
  29999. * Sets an array on a uniform variable.
  30000. * @param uniformName Name of the variable.
  30001. * @param array array to be set.
  30002. * @returns this effect.
  30003. */
  30004. setArray(uniformName: string, array: number[]): Effect;
  30005. /**
  30006. * 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)
  30007. * @param uniformName Name of the variable.
  30008. * @param array array to be set.
  30009. * @returns this effect.
  30010. */
  30011. setArray2(uniformName: string, array: number[]): Effect;
  30012. /**
  30013. * 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)
  30014. * @param uniformName Name of the variable.
  30015. * @param array array to be set.
  30016. * @returns this effect.
  30017. */
  30018. setArray3(uniformName: string, array: number[]): Effect;
  30019. /**
  30020. * 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)
  30021. * @param uniformName Name of the variable.
  30022. * @param array array to be set.
  30023. * @returns this effect.
  30024. */
  30025. setArray4(uniformName: string, array: number[]): Effect;
  30026. /**
  30027. * Sets matrices on a uniform variable.
  30028. * @param uniformName Name of the variable.
  30029. * @param matrices matrices to be set.
  30030. * @returns this effect.
  30031. */
  30032. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30033. /**
  30034. * Sets matrix on a uniform variable.
  30035. * @param uniformName Name of the variable.
  30036. * @param matrix matrix to be set.
  30037. * @returns this effect.
  30038. */
  30039. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30040. /**
  30041. * 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)
  30042. * @param uniformName Name of the variable.
  30043. * @param matrix matrix to be set.
  30044. * @returns this effect.
  30045. */
  30046. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30047. /**
  30048. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30049. * @param uniformName Name of the variable.
  30050. * @param matrix matrix to be set.
  30051. * @returns this effect.
  30052. */
  30053. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30054. /**
  30055. * Sets a float on a uniform variable.
  30056. * @param uniformName Name of the variable.
  30057. * @param value value to be set.
  30058. * @returns this effect.
  30059. */
  30060. setFloat(uniformName: string, value: number): Effect;
  30061. /**
  30062. * Sets a boolean on a uniform variable.
  30063. * @param uniformName Name of the variable.
  30064. * @param bool value to be set.
  30065. * @returns this effect.
  30066. */
  30067. setBool(uniformName: string, bool: boolean): Effect;
  30068. /**
  30069. * Sets a Vector2 on a uniform variable.
  30070. * @param uniformName Name of the variable.
  30071. * @param vector2 vector2 to be set.
  30072. * @returns this effect.
  30073. */
  30074. setVector2(uniformName: string, vector2: Vector2): Effect;
  30075. /**
  30076. * Sets a float2 on a uniform variable.
  30077. * @param uniformName Name of the variable.
  30078. * @param x First float in float2.
  30079. * @param y Second float in float2.
  30080. * @returns this effect.
  30081. */
  30082. setFloat2(uniformName: string, x: number, y: number): Effect;
  30083. /**
  30084. * Sets a Vector3 on a uniform variable.
  30085. * @param uniformName Name of the variable.
  30086. * @param vector3 Value to be set.
  30087. * @returns this effect.
  30088. */
  30089. setVector3(uniformName: string, vector3: Vector3): Effect;
  30090. /**
  30091. * Sets a float3 on a uniform variable.
  30092. * @param uniformName Name of the variable.
  30093. * @param x First float in float3.
  30094. * @param y Second float in float3.
  30095. * @param z Third float in float3.
  30096. * @returns this effect.
  30097. */
  30098. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30099. /**
  30100. * Sets a Vector4 on a uniform variable.
  30101. * @param uniformName Name of the variable.
  30102. * @param vector4 Value to be set.
  30103. * @returns this effect.
  30104. */
  30105. setVector4(uniformName: string, vector4: Vector4): Effect;
  30106. /**
  30107. * Sets a float4 on a uniform variable.
  30108. * @param uniformName Name of the variable.
  30109. * @param x First float in float4.
  30110. * @param y Second float in float4.
  30111. * @param z Third float in float4.
  30112. * @param w Fourth float in float4.
  30113. * @returns this effect.
  30114. */
  30115. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30116. /**
  30117. * Sets a Color3 on a uniform variable.
  30118. * @param uniformName Name of the variable.
  30119. * @param color3 Value to be set.
  30120. * @returns this effect.
  30121. */
  30122. setColor3(uniformName: string, color3: Color3): Effect;
  30123. /**
  30124. * Sets a Color4 on a uniform variable.
  30125. * @param uniformName Name of the variable.
  30126. * @param color3 Value to be set.
  30127. * @param alpha Alpha value to be set.
  30128. * @returns this effect.
  30129. */
  30130. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30131. /**
  30132. * Sets a Color4 on a uniform variable
  30133. * @param uniformName defines the name of the variable
  30134. * @param color4 defines the value to be set
  30135. * @returns this effect.
  30136. */
  30137. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30138. /** Release all associated resources */
  30139. dispose(): void;
  30140. /**
  30141. * This function will add a new shader to the shader store
  30142. * @param name the name of the shader
  30143. * @param pixelShader optional pixel shader content
  30144. * @param vertexShader optional vertex shader content
  30145. */
  30146. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30147. /**
  30148. * Store of each shader (The can be looked up using effect.key)
  30149. */
  30150. static ShadersStore: {
  30151. [key: string]: string;
  30152. };
  30153. /**
  30154. * Store of each included file for a shader (The can be looked up using effect.key)
  30155. */
  30156. static IncludesShadersStore: {
  30157. [key: string]: string;
  30158. };
  30159. /**
  30160. * Resets the cache of effects.
  30161. */
  30162. static ResetCache(): void;
  30163. }
  30164. }
  30165. declare module "babylonjs/Materials/colorCurves" {
  30166. import { Effect } from "babylonjs/Materials/effect";
  30167. /**
  30168. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30169. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30170. * 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;
  30171. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30172. */
  30173. export class ColorCurves {
  30174. private _dirty;
  30175. private _tempColor;
  30176. private _globalCurve;
  30177. private _highlightsCurve;
  30178. private _midtonesCurve;
  30179. private _shadowsCurve;
  30180. private _positiveCurve;
  30181. private _negativeCurve;
  30182. private _globalHue;
  30183. private _globalDensity;
  30184. private _globalSaturation;
  30185. private _globalExposure;
  30186. /**
  30187. * Gets the global Hue value.
  30188. * 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).
  30189. */
  30190. /**
  30191. * Sets the global Hue value.
  30192. * 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).
  30193. */
  30194. globalHue: number;
  30195. /**
  30196. * Gets the global Density value.
  30197. * 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.
  30198. * Values less than zero provide a filter of opposite hue.
  30199. */
  30200. /**
  30201. * Sets the global Density value.
  30202. * 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.
  30203. * Values less than zero provide a filter of opposite hue.
  30204. */
  30205. globalDensity: number;
  30206. /**
  30207. * Gets the global Saturation value.
  30208. * 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.
  30209. */
  30210. /**
  30211. * Sets the global Saturation value.
  30212. * 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.
  30213. */
  30214. globalSaturation: number;
  30215. /**
  30216. * Gets the global Exposure value.
  30217. * 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.
  30218. */
  30219. /**
  30220. * Sets the global Exposure value.
  30221. * 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.
  30222. */
  30223. globalExposure: number;
  30224. private _highlightsHue;
  30225. private _highlightsDensity;
  30226. private _highlightsSaturation;
  30227. private _highlightsExposure;
  30228. /**
  30229. * Gets the highlights Hue value.
  30230. * 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).
  30231. */
  30232. /**
  30233. * Sets the highlights Hue value.
  30234. * 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).
  30235. */
  30236. highlightsHue: number;
  30237. /**
  30238. * Gets the highlights Density value.
  30239. * 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.
  30240. * Values less than zero provide a filter of opposite hue.
  30241. */
  30242. /**
  30243. * Sets the highlights Density value.
  30244. * 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.
  30245. * Values less than zero provide a filter of opposite hue.
  30246. */
  30247. highlightsDensity: number;
  30248. /**
  30249. * Gets the highlights Saturation value.
  30250. * 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.
  30251. */
  30252. /**
  30253. * Sets the highlights Saturation value.
  30254. * 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.
  30255. */
  30256. highlightsSaturation: number;
  30257. /**
  30258. * Gets the highlights Exposure value.
  30259. * 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.
  30260. */
  30261. /**
  30262. * Sets the highlights Exposure value.
  30263. * 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.
  30264. */
  30265. highlightsExposure: number;
  30266. private _midtonesHue;
  30267. private _midtonesDensity;
  30268. private _midtonesSaturation;
  30269. private _midtonesExposure;
  30270. /**
  30271. * Gets the midtones Hue value.
  30272. * 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).
  30273. */
  30274. /**
  30275. * Sets the midtones Hue value.
  30276. * 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).
  30277. */
  30278. midtonesHue: number;
  30279. /**
  30280. * Gets the midtones Density value.
  30281. * 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.
  30282. * Values less than zero provide a filter of opposite hue.
  30283. */
  30284. /**
  30285. * Sets the midtones Density value.
  30286. * 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.
  30287. * Values less than zero provide a filter of opposite hue.
  30288. */
  30289. midtonesDensity: number;
  30290. /**
  30291. * Gets the midtones Saturation value.
  30292. * 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.
  30293. */
  30294. /**
  30295. * Sets the midtones Saturation value.
  30296. * 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.
  30297. */
  30298. midtonesSaturation: number;
  30299. /**
  30300. * Gets the midtones Exposure value.
  30301. * 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.
  30302. */
  30303. /**
  30304. * Sets the midtones Exposure value.
  30305. * 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.
  30306. */
  30307. midtonesExposure: number;
  30308. private _shadowsHue;
  30309. private _shadowsDensity;
  30310. private _shadowsSaturation;
  30311. private _shadowsExposure;
  30312. /**
  30313. * Gets the shadows Hue value.
  30314. * 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).
  30315. */
  30316. /**
  30317. * Sets the shadows Hue value.
  30318. * 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).
  30319. */
  30320. shadowsHue: number;
  30321. /**
  30322. * Gets the shadows Density value.
  30323. * 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.
  30324. * Values less than zero provide a filter of opposite hue.
  30325. */
  30326. /**
  30327. * Sets the shadows Density value.
  30328. * 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.
  30329. * Values less than zero provide a filter of opposite hue.
  30330. */
  30331. shadowsDensity: number;
  30332. /**
  30333. * Gets the shadows Saturation value.
  30334. * 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.
  30335. */
  30336. /**
  30337. * Sets the shadows Saturation value.
  30338. * 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.
  30339. */
  30340. shadowsSaturation: number;
  30341. /**
  30342. * Gets the shadows Exposure value.
  30343. * 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.
  30344. */
  30345. /**
  30346. * Sets the shadows Exposure value.
  30347. * 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.
  30348. */
  30349. shadowsExposure: number;
  30350. /**
  30351. * Returns the class name
  30352. * @returns The class name
  30353. */
  30354. getClassName(): string;
  30355. /**
  30356. * Binds the color curves to the shader.
  30357. * @param colorCurves The color curve to bind
  30358. * @param effect The effect to bind to
  30359. * @param positiveUniform The positive uniform shader parameter
  30360. * @param neutralUniform The neutral uniform shader parameter
  30361. * @param negativeUniform The negative uniform shader parameter
  30362. */
  30363. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30364. /**
  30365. * Prepare the list of uniforms associated with the ColorCurves effects.
  30366. * @param uniformsList The list of uniforms used in the effect
  30367. */
  30368. static PrepareUniforms(uniformsList: string[]): void;
  30369. /**
  30370. * Returns color grading data based on a hue, density, saturation and exposure value.
  30371. * @param filterHue The hue of the color filter.
  30372. * @param filterDensity The density of the color filter.
  30373. * @param saturation The saturation.
  30374. * @param exposure The exposure.
  30375. * @param result The result data container.
  30376. */
  30377. private getColorGradingDataToRef;
  30378. /**
  30379. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30380. * @param value The input slider value in range [-100,100].
  30381. * @returns Adjusted value.
  30382. */
  30383. private static applyColorGradingSliderNonlinear;
  30384. /**
  30385. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30386. * @param hue The hue (H) input.
  30387. * @param saturation The saturation (S) input.
  30388. * @param brightness The brightness (B) input.
  30389. * @result An RGBA color represented as Vector4.
  30390. */
  30391. private static fromHSBToRef;
  30392. /**
  30393. * Returns a value clamped between min and max
  30394. * @param value The value to clamp
  30395. * @param min The minimum of value
  30396. * @param max The maximum of value
  30397. * @returns The clamped value.
  30398. */
  30399. private static clamp;
  30400. /**
  30401. * Clones the current color curve instance.
  30402. * @return The cloned curves
  30403. */
  30404. clone(): ColorCurves;
  30405. /**
  30406. * Serializes the current color curve instance to a json representation.
  30407. * @return a JSON representation
  30408. */
  30409. serialize(): any;
  30410. /**
  30411. * Parses the color curve from a json representation.
  30412. * @param source the JSON source to parse
  30413. * @return The parsed curves
  30414. */
  30415. static Parse(source: any): ColorCurves;
  30416. }
  30417. }
  30418. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30419. import { Observable } from "babylonjs/Misc/observable";
  30420. import { Nullable } from "babylonjs/types";
  30421. import { Color4 } from "babylonjs/Maths/math";
  30422. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30423. import { Effect } from "babylonjs/Materials/effect";
  30424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30425. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30426. /**
  30427. * Interface to follow in your material defines to integrate easily the
  30428. * Image proccessing functions.
  30429. * @hidden
  30430. */
  30431. export interface IImageProcessingConfigurationDefines {
  30432. IMAGEPROCESSING: boolean;
  30433. VIGNETTE: boolean;
  30434. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30435. VIGNETTEBLENDMODEOPAQUE: boolean;
  30436. TONEMAPPING: boolean;
  30437. TONEMAPPING_ACES: boolean;
  30438. CONTRAST: boolean;
  30439. EXPOSURE: boolean;
  30440. COLORCURVES: boolean;
  30441. COLORGRADING: boolean;
  30442. COLORGRADING3D: boolean;
  30443. SAMPLER3DGREENDEPTH: boolean;
  30444. SAMPLER3DBGRMAP: boolean;
  30445. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30446. }
  30447. /**
  30448. * @hidden
  30449. */
  30450. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30451. IMAGEPROCESSING: boolean;
  30452. VIGNETTE: boolean;
  30453. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30454. VIGNETTEBLENDMODEOPAQUE: boolean;
  30455. TONEMAPPING: boolean;
  30456. TONEMAPPING_ACES: boolean;
  30457. CONTRAST: boolean;
  30458. COLORCURVES: boolean;
  30459. COLORGRADING: boolean;
  30460. COLORGRADING3D: boolean;
  30461. SAMPLER3DGREENDEPTH: boolean;
  30462. SAMPLER3DBGRMAP: boolean;
  30463. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30464. EXPOSURE: boolean;
  30465. constructor();
  30466. }
  30467. /**
  30468. * This groups together the common properties used for image processing either in direct forward pass
  30469. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30470. * or not.
  30471. */
  30472. export class ImageProcessingConfiguration {
  30473. /**
  30474. * Default tone mapping applied in BabylonJS.
  30475. */
  30476. static readonly TONEMAPPING_STANDARD: number;
  30477. /**
  30478. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30479. * to other engines rendering to increase portability.
  30480. */
  30481. static readonly TONEMAPPING_ACES: number;
  30482. /**
  30483. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30484. */
  30485. colorCurves: Nullable<ColorCurves>;
  30486. private _colorCurvesEnabled;
  30487. /**
  30488. * Gets wether the color curves effect is enabled.
  30489. */
  30490. /**
  30491. * Sets wether the color curves effect is enabled.
  30492. */
  30493. colorCurvesEnabled: boolean;
  30494. private _colorGradingTexture;
  30495. /**
  30496. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30497. */
  30498. /**
  30499. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30500. */
  30501. colorGradingTexture: Nullable<BaseTexture>;
  30502. private _colorGradingEnabled;
  30503. /**
  30504. * Gets wether the color grading effect is enabled.
  30505. */
  30506. /**
  30507. * Sets wether the color grading effect is enabled.
  30508. */
  30509. colorGradingEnabled: boolean;
  30510. private _colorGradingWithGreenDepth;
  30511. /**
  30512. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30513. */
  30514. /**
  30515. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30516. */
  30517. colorGradingWithGreenDepth: boolean;
  30518. private _colorGradingBGR;
  30519. /**
  30520. * Gets wether the color grading texture contains BGR values.
  30521. */
  30522. /**
  30523. * Sets wether the color grading texture contains BGR values.
  30524. */
  30525. colorGradingBGR: boolean;
  30526. /** @hidden */
  30527. _exposure: number;
  30528. /**
  30529. * Gets the Exposure used in the effect.
  30530. */
  30531. /**
  30532. * Sets the Exposure used in the effect.
  30533. */
  30534. exposure: number;
  30535. private _toneMappingEnabled;
  30536. /**
  30537. * Gets wether the tone mapping effect is enabled.
  30538. */
  30539. /**
  30540. * Sets wether the tone mapping effect is enabled.
  30541. */
  30542. toneMappingEnabled: boolean;
  30543. private _toneMappingType;
  30544. /**
  30545. * Gets the type of tone mapping effect.
  30546. */
  30547. /**
  30548. * Sets the type of tone mapping effect used in BabylonJS.
  30549. */
  30550. toneMappingType: number;
  30551. protected _contrast: number;
  30552. /**
  30553. * Gets the contrast used in the effect.
  30554. */
  30555. /**
  30556. * Sets the contrast used in the effect.
  30557. */
  30558. contrast: number;
  30559. /**
  30560. * Vignette stretch size.
  30561. */
  30562. vignetteStretch: number;
  30563. /**
  30564. * Vignette centre X Offset.
  30565. */
  30566. vignetteCentreX: number;
  30567. /**
  30568. * Vignette centre Y Offset.
  30569. */
  30570. vignetteCentreY: number;
  30571. /**
  30572. * Vignette weight or intensity of the vignette effect.
  30573. */
  30574. vignetteWeight: number;
  30575. /**
  30576. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30577. * if vignetteEnabled is set to true.
  30578. */
  30579. vignetteColor: Color4;
  30580. /**
  30581. * Camera field of view used by the Vignette effect.
  30582. */
  30583. vignetteCameraFov: number;
  30584. private _vignetteBlendMode;
  30585. /**
  30586. * Gets the vignette blend mode allowing different kind of effect.
  30587. */
  30588. /**
  30589. * Sets the vignette blend mode allowing different kind of effect.
  30590. */
  30591. vignetteBlendMode: number;
  30592. private _vignetteEnabled;
  30593. /**
  30594. * Gets wether the vignette effect is enabled.
  30595. */
  30596. /**
  30597. * Sets wether the vignette effect is enabled.
  30598. */
  30599. vignetteEnabled: boolean;
  30600. private _applyByPostProcess;
  30601. /**
  30602. * Gets wether the image processing is applied through a post process or not.
  30603. */
  30604. /**
  30605. * Sets wether the image processing is applied through a post process or not.
  30606. */
  30607. applyByPostProcess: boolean;
  30608. private _isEnabled;
  30609. /**
  30610. * Gets wether the image processing is enabled or not.
  30611. */
  30612. /**
  30613. * Sets wether the image processing is enabled or not.
  30614. */
  30615. isEnabled: boolean;
  30616. /**
  30617. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30618. */
  30619. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30620. /**
  30621. * Method called each time the image processing information changes requires to recompile the effect.
  30622. */
  30623. protected _updateParameters(): void;
  30624. /**
  30625. * Gets the current class name.
  30626. * @return "ImageProcessingConfiguration"
  30627. */
  30628. getClassName(): string;
  30629. /**
  30630. * Prepare the list of uniforms associated with the Image Processing effects.
  30631. * @param uniforms The list of uniforms used in the effect
  30632. * @param defines the list of defines currently in use
  30633. */
  30634. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30635. /**
  30636. * Prepare the list of samplers associated with the Image Processing effects.
  30637. * @param samplersList The list of uniforms used in the effect
  30638. * @param defines the list of defines currently in use
  30639. */
  30640. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30641. /**
  30642. * Prepare the list of defines associated to the shader.
  30643. * @param defines the list of defines to complete
  30644. * @param forPostProcess Define if we are currently in post process mode or not
  30645. */
  30646. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30647. /**
  30648. * Returns true if all the image processing information are ready.
  30649. * @returns True if ready, otherwise, false
  30650. */
  30651. isReady(): boolean;
  30652. /**
  30653. * Binds the image processing to the shader.
  30654. * @param effect The effect to bind to
  30655. * @param aspectRatio Define the current aspect ratio of the effect
  30656. */
  30657. bind(effect: Effect, aspectRatio?: number): void;
  30658. /**
  30659. * Clones the current image processing instance.
  30660. * @return The cloned image processing
  30661. */
  30662. clone(): ImageProcessingConfiguration;
  30663. /**
  30664. * Serializes the current image processing instance to a json representation.
  30665. * @return a JSON representation
  30666. */
  30667. serialize(): any;
  30668. /**
  30669. * Parses the image processing from a json representation.
  30670. * @param source the JSON source to parse
  30671. * @return The parsed image processing
  30672. */
  30673. static Parse(source: any): ImageProcessingConfiguration;
  30674. private static _VIGNETTEMODE_MULTIPLY;
  30675. private static _VIGNETTEMODE_OPAQUE;
  30676. /**
  30677. * Used to apply the vignette as a mix with the pixel color.
  30678. */
  30679. static readonly VIGNETTEMODE_MULTIPLY: number;
  30680. /**
  30681. * Used to apply the vignette as a replacement of the pixel color.
  30682. */
  30683. static readonly VIGNETTEMODE_OPAQUE: number;
  30684. }
  30685. }
  30686. declare module "babylonjs/Materials/fresnelParameters" {
  30687. import { Color3 } from "babylonjs/Maths/math";
  30688. /**
  30689. * This represents all the required information to add a fresnel effect on a material:
  30690. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30691. */
  30692. export class FresnelParameters {
  30693. private _isEnabled;
  30694. /**
  30695. * Define if the fresnel effect is enable or not.
  30696. */
  30697. isEnabled: boolean;
  30698. /**
  30699. * Define the color used on edges (grazing angle)
  30700. */
  30701. leftColor: Color3;
  30702. /**
  30703. * Define the color used on center
  30704. */
  30705. rightColor: Color3;
  30706. /**
  30707. * Define bias applied to computed fresnel term
  30708. */
  30709. bias: number;
  30710. /**
  30711. * Defined the power exponent applied to fresnel term
  30712. */
  30713. power: number;
  30714. /**
  30715. * Clones the current fresnel and its valuues
  30716. * @returns a clone fresnel configuration
  30717. */
  30718. clone(): FresnelParameters;
  30719. /**
  30720. * Serializes the current fresnel parameters to a JSON representation.
  30721. * @return the JSON serialization
  30722. */
  30723. serialize(): any;
  30724. /**
  30725. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30726. * @param parsedFresnelParameters Define the JSON representation
  30727. * @returns the parsed parameters
  30728. */
  30729. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30730. }
  30731. }
  30732. declare module "babylonjs/Misc/decorators" {
  30733. import { Nullable } from "babylonjs/types";
  30734. import { Scene } from "babylonjs/scene";
  30735. import { IAnimatable } from "babylonjs/Misc/tools";
  30736. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30737. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30738. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30739. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30740. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30741. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30742. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30743. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30744. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30745. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30746. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30747. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30748. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30749. /**
  30750. * Decorator used to define property that can be serialized as reference to a camera
  30751. * @param sourceName defines the name of the property to decorate
  30752. */
  30753. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30754. /**
  30755. * Class used to help serialization objects
  30756. */
  30757. export class SerializationHelper {
  30758. /** hidden */
  30759. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30760. /** hidden */
  30761. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30762. /** hidden */
  30763. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30764. /** hidden */
  30765. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30766. /**
  30767. * Appends the serialized animations from the source animations
  30768. * @param source Source containing the animations
  30769. * @param destination Target to store the animations
  30770. */
  30771. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30772. /**
  30773. * Static function used to serialized a specific entity
  30774. * @param entity defines the entity to serialize
  30775. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30776. * @returns a JSON compatible object representing the serialization of the entity
  30777. */
  30778. static Serialize<T>(entity: T, serializationObject?: any): any;
  30779. /**
  30780. * Creates a new entity from a serialization data object
  30781. * @param creationFunction defines a function used to instanciated the new entity
  30782. * @param source defines the source serialization data
  30783. * @param scene defines the hosting scene
  30784. * @param rootUrl defines the root url for resources
  30785. * @returns a new entity
  30786. */
  30787. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30788. /**
  30789. * Clones an object
  30790. * @param creationFunction defines the function used to instanciate the new object
  30791. * @param source defines the source object
  30792. * @returns the cloned object
  30793. */
  30794. static Clone<T>(creationFunction: () => T, source: T): T;
  30795. /**
  30796. * Instanciates a new object based on a source one (some data will be shared between both object)
  30797. * @param creationFunction defines the function used to instanciate the new object
  30798. * @param source defines the source object
  30799. * @returns the new object
  30800. */
  30801. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30802. }
  30803. }
  30804. declare module "babylonjs/Cameras/camera" {
  30805. import { SmartArray } from "babylonjs/Misc/smartArray";
  30806. import { Observable } from "babylonjs/Misc/observable";
  30807. import { Nullable } from "babylonjs/types";
  30808. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30809. import { Scene } from "babylonjs/scene";
  30810. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30811. import { Node } from "babylonjs/node";
  30812. import { Mesh } from "babylonjs/Meshes/mesh";
  30813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30814. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30815. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30816. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30817. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30818. import { Ray } from "babylonjs/Culling/ray";
  30819. /**
  30820. * This is the base class of all the camera used in the application.
  30821. * @see http://doc.babylonjs.com/features/cameras
  30822. */
  30823. export class Camera extends Node {
  30824. /** @hidden */
  30825. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30826. /**
  30827. * This is the default projection mode used by the cameras.
  30828. * It helps recreating a feeling of perspective and better appreciate depth.
  30829. * This is the best way to simulate real life cameras.
  30830. */
  30831. static readonly PERSPECTIVE_CAMERA: number;
  30832. /**
  30833. * This helps creating camera with an orthographic mode.
  30834. * 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.
  30835. */
  30836. static readonly ORTHOGRAPHIC_CAMERA: number;
  30837. /**
  30838. * This is the default FOV mode for perspective cameras.
  30839. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30840. */
  30841. static readonly FOVMODE_VERTICAL_FIXED: number;
  30842. /**
  30843. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30844. */
  30845. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30846. /**
  30847. * This specifies ther is no need for a camera rig.
  30848. * Basically only one eye is rendered corresponding to the camera.
  30849. */
  30850. static readonly RIG_MODE_NONE: number;
  30851. /**
  30852. * Simulates a camera Rig with one blue eye and one red eye.
  30853. * This can be use with 3d blue and red glasses.
  30854. */
  30855. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30856. /**
  30857. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30858. */
  30859. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30860. /**
  30861. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30862. */
  30863. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30864. /**
  30865. * Defines that both eyes of the camera will be rendered over under each other.
  30866. */
  30867. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30868. /**
  30869. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30870. */
  30871. static readonly RIG_MODE_VR: number;
  30872. /**
  30873. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30874. */
  30875. static readonly RIG_MODE_WEBVR: number;
  30876. /**
  30877. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30878. */
  30879. static readonly RIG_MODE_CUSTOM: number;
  30880. /**
  30881. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30882. */
  30883. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30884. /**
  30885. * Define the input manager associated with the camera.
  30886. */
  30887. inputs: CameraInputsManager<Camera>;
  30888. /** @hidden */
  30889. _position: Vector3;
  30890. /**
  30891. * Define the current local position of the camera in the scene
  30892. */
  30893. position: Vector3;
  30894. /**
  30895. * The vector the camera should consider as up.
  30896. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30897. */
  30898. upVector: Vector3;
  30899. /**
  30900. * Define the current limit on the left side for an orthographic camera
  30901. * In scene unit
  30902. */
  30903. orthoLeft: Nullable<number>;
  30904. /**
  30905. * Define the current limit on the right side for an orthographic camera
  30906. * In scene unit
  30907. */
  30908. orthoRight: Nullable<number>;
  30909. /**
  30910. * Define the current limit on the bottom side for an orthographic camera
  30911. * In scene unit
  30912. */
  30913. orthoBottom: Nullable<number>;
  30914. /**
  30915. * Define the current limit on the top side for an orthographic camera
  30916. * In scene unit
  30917. */
  30918. orthoTop: Nullable<number>;
  30919. /**
  30920. * Field Of View is set in Radians. (default is 0.8)
  30921. */
  30922. fov: number;
  30923. /**
  30924. * Define the minimum distance the camera can see from.
  30925. * This is important to note that the depth buffer are not infinite and the closer it starts
  30926. * the more your scene might encounter depth fighting issue.
  30927. */
  30928. minZ: number;
  30929. /**
  30930. * Define the maximum distance the camera can see to.
  30931. * This is important to note that the depth buffer are not infinite and the further it end
  30932. * the more your scene might encounter depth fighting issue.
  30933. */
  30934. maxZ: number;
  30935. /**
  30936. * Define the default inertia of the camera.
  30937. * This helps giving a smooth feeling to the camera movement.
  30938. */
  30939. inertia: number;
  30940. /**
  30941. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30942. */
  30943. mode: number;
  30944. /**
  30945. * Define wether the camera is intermediate.
  30946. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30947. */
  30948. isIntermediate: boolean;
  30949. /**
  30950. * Define the viewport of the camera.
  30951. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30952. */
  30953. viewport: Viewport;
  30954. /**
  30955. * Restricts the camera to viewing objects with the same layerMask.
  30956. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30957. */
  30958. layerMask: number;
  30959. /**
  30960. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30961. */
  30962. fovMode: number;
  30963. /**
  30964. * Rig mode of the camera.
  30965. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30966. * This is normally controlled byt the camera themselves as internal use.
  30967. */
  30968. cameraRigMode: number;
  30969. /**
  30970. * Defines the distance between both "eyes" in case of a RIG
  30971. */
  30972. interaxialDistance: number;
  30973. /**
  30974. * Defines if stereoscopic rendering is done side by side or over under.
  30975. */
  30976. isStereoscopicSideBySide: boolean;
  30977. /**
  30978. * 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
  30979. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30980. * else in the scene.
  30981. */
  30982. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30983. /**
  30984. * When set, the camera will render to this render target instead of the default canvas
  30985. */
  30986. outputRenderTarget: Nullable<RenderTargetTexture>;
  30987. /**
  30988. * Observable triggered when the camera view matrix has changed.
  30989. */
  30990. onViewMatrixChangedObservable: Observable<Camera>;
  30991. /**
  30992. * Observable triggered when the camera Projection matrix has changed.
  30993. */
  30994. onProjectionMatrixChangedObservable: Observable<Camera>;
  30995. /**
  30996. * Observable triggered when the inputs have been processed.
  30997. */
  30998. onAfterCheckInputsObservable: Observable<Camera>;
  30999. /**
  31000. * Observable triggered when reset has been called and applied to the camera.
  31001. */
  31002. onRestoreStateObservable: Observable<Camera>;
  31003. /** @hidden */
  31004. _cameraRigParams: any;
  31005. /** @hidden */
  31006. _rigCameras: Camera[];
  31007. /** @hidden */
  31008. _rigPostProcess: Nullable<PostProcess>;
  31009. protected _webvrViewMatrix: Matrix;
  31010. /** @hidden */
  31011. _skipRendering: boolean;
  31012. /** @hidden */
  31013. _projectionMatrix: Matrix;
  31014. /** @hidden */
  31015. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31016. /** @hidden */
  31017. _activeMeshes: SmartArray<AbstractMesh>;
  31018. protected _globalPosition: Vector3;
  31019. /** hidden */
  31020. _computedViewMatrix: Matrix;
  31021. private _doNotComputeProjectionMatrix;
  31022. private _transformMatrix;
  31023. private _frustumPlanes;
  31024. private _refreshFrustumPlanes;
  31025. private _storedFov;
  31026. private _stateStored;
  31027. /**
  31028. * Instantiates a new camera object.
  31029. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31030. * @see http://doc.babylonjs.com/features/cameras
  31031. * @param name Defines the name of the camera in the scene
  31032. * @param position Defines the position of the camera
  31033. * @param scene Defines the scene the camera belongs too
  31034. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31035. */
  31036. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31037. /**
  31038. * Store current camera state (fov, position, etc..)
  31039. * @returns the camera
  31040. */
  31041. storeState(): Camera;
  31042. /**
  31043. * Restores the camera state values if it has been stored. You must call storeState() first
  31044. */
  31045. protected _restoreStateValues(): boolean;
  31046. /**
  31047. * Restored camera state. You must call storeState() first.
  31048. * @returns true if restored and false otherwise
  31049. */
  31050. restoreState(): boolean;
  31051. /**
  31052. * Gets the class name of the camera.
  31053. * @returns the class name
  31054. */
  31055. getClassName(): string;
  31056. /** @hidden */
  31057. readonly _isCamera: boolean;
  31058. /**
  31059. * Gets a string representation of the camera useful for debug purpose.
  31060. * @param fullDetails Defines that a more verboe level of logging is required
  31061. * @returns the string representation
  31062. */
  31063. toString(fullDetails?: boolean): string;
  31064. /**
  31065. * Gets the current world space position of the camera.
  31066. */
  31067. readonly globalPosition: Vector3;
  31068. /**
  31069. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31070. * @returns the active meshe list
  31071. */
  31072. getActiveMeshes(): SmartArray<AbstractMesh>;
  31073. /**
  31074. * Check wether a mesh is part of the current active mesh list of the camera
  31075. * @param mesh Defines the mesh to check
  31076. * @returns true if active, false otherwise
  31077. */
  31078. isActiveMesh(mesh: Mesh): boolean;
  31079. /**
  31080. * Is this camera ready to be used/rendered
  31081. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31082. * @return true if the camera is ready
  31083. */
  31084. isReady(completeCheck?: boolean): boolean;
  31085. /** @hidden */
  31086. _initCache(): void;
  31087. /** @hidden */
  31088. _updateCache(ignoreParentClass?: boolean): void;
  31089. /** @hidden */
  31090. _isSynchronized(): boolean;
  31091. /** @hidden */
  31092. _isSynchronizedViewMatrix(): boolean;
  31093. /** @hidden */
  31094. _isSynchronizedProjectionMatrix(): boolean;
  31095. /**
  31096. * Attach the input controls to a specific dom element to get the input from.
  31097. * @param element Defines the element the controls should be listened from
  31098. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31099. */
  31100. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31101. /**
  31102. * Detach the current controls from the specified dom element.
  31103. * @param element Defines the element to stop listening the inputs from
  31104. */
  31105. detachControl(element: HTMLElement): void;
  31106. /**
  31107. * Update the camera state according to the different inputs gathered during the frame.
  31108. */
  31109. update(): void;
  31110. /** @hidden */
  31111. _checkInputs(): void;
  31112. /** @hidden */
  31113. readonly rigCameras: Camera[];
  31114. /**
  31115. * Gets the post process used by the rig cameras
  31116. */
  31117. readonly rigPostProcess: Nullable<PostProcess>;
  31118. /**
  31119. * Internal, gets the first post proces.
  31120. * @returns the first post process to be run on this camera.
  31121. */
  31122. _getFirstPostProcess(): Nullable<PostProcess>;
  31123. private _cascadePostProcessesToRigCams;
  31124. /**
  31125. * Attach a post process to the camera.
  31126. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31127. * @param postProcess The post process to attach to the camera
  31128. * @param insertAt The position of the post process in case several of them are in use in the scene
  31129. * @returns the position the post process has been inserted at
  31130. */
  31131. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31132. /**
  31133. * Detach a post process to the camera.
  31134. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31135. * @param postProcess The post process to detach from the camera
  31136. */
  31137. detachPostProcess(postProcess: PostProcess): void;
  31138. /**
  31139. * Gets the current world matrix of the camera
  31140. */
  31141. getWorldMatrix(): Matrix;
  31142. /** @hidden */
  31143. _getViewMatrix(): Matrix;
  31144. /**
  31145. * Gets the current view matrix of the camera.
  31146. * @param force forces the camera to recompute the matrix without looking at the cached state
  31147. * @returns the view matrix
  31148. */
  31149. getViewMatrix(force?: boolean): Matrix;
  31150. /**
  31151. * Freeze the projection matrix.
  31152. * It will prevent the cache check of the camera projection compute and can speed up perf
  31153. * if no parameter of the camera are meant to change
  31154. * @param projection Defines manually a projection if necessary
  31155. */
  31156. freezeProjectionMatrix(projection?: Matrix): void;
  31157. /**
  31158. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31159. */
  31160. unfreezeProjectionMatrix(): void;
  31161. /**
  31162. * Gets the current projection matrix of the camera.
  31163. * @param force forces the camera to recompute the matrix without looking at the cached state
  31164. * @returns the projection matrix
  31165. */
  31166. getProjectionMatrix(force?: boolean): Matrix;
  31167. /**
  31168. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31169. * @returns a Matrix
  31170. */
  31171. getTransformationMatrix(): Matrix;
  31172. private _updateFrustumPlanes;
  31173. /**
  31174. * Checks if a cullable object (mesh...) is in the camera frustum
  31175. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31176. * @param target The object to check
  31177. * @returns true if the object is in frustum otherwise false
  31178. */
  31179. isInFrustum(target: ICullable): boolean;
  31180. /**
  31181. * Checks if a cullable object (mesh...) is in the camera frustum
  31182. * Unlike isInFrustum this cheks the full bounding box
  31183. * @param target The object to check
  31184. * @returns true if the object is in frustum otherwise false
  31185. */
  31186. isCompletelyInFrustum(target: ICullable): boolean;
  31187. /**
  31188. * Gets a ray in the forward direction from the camera.
  31189. * @param length Defines the length of the ray to create
  31190. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31191. * @param origin Defines the start point of the ray which defaults to the camera position
  31192. * @returns the forward ray
  31193. */
  31194. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31195. /**
  31196. * Releases resources associated with this node.
  31197. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31198. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31199. */
  31200. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31201. /** @hidden */
  31202. _isLeftCamera: boolean;
  31203. /**
  31204. * Gets the left camera of a rig setup in case of Rigged Camera
  31205. */
  31206. readonly isLeftCamera: boolean;
  31207. /** @hidden */
  31208. _isRightCamera: boolean;
  31209. /**
  31210. * Gets the right camera of a rig setup in case of Rigged Camera
  31211. */
  31212. readonly isRightCamera: boolean;
  31213. /**
  31214. * Gets the left camera of a rig setup in case of Rigged Camera
  31215. */
  31216. readonly leftCamera: Nullable<FreeCamera>;
  31217. /**
  31218. * Gets the right camera of a rig setup in case of Rigged Camera
  31219. */
  31220. readonly rightCamera: Nullable<FreeCamera>;
  31221. /**
  31222. * Gets the left camera target of a rig setup in case of Rigged Camera
  31223. * @returns the target position
  31224. */
  31225. getLeftTarget(): Nullable<Vector3>;
  31226. /**
  31227. * Gets the right camera target of a rig setup in case of Rigged Camera
  31228. * @returns the target position
  31229. */
  31230. getRightTarget(): Nullable<Vector3>;
  31231. /**
  31232. * @hidden
  31233. */
  31234. setCameraRigMode(mode: number, rigParams: any): void;
  31235. /** @hidden */
  31236. static _setStereoscopicRigMode(camera: Camera): void;
  31237. /** @hidden */
  31238. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31239. /** @hidden */
  31240. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31241. /** @hidden */
  31242. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31243. /** @hidden */
  31244. _getVRProjectionMatrix(): Matrix;
  31245. protected _updateCameraRotationMatrix(): void;
  31246. protected _updateWebVRCameraRotationMatrix(): void;
  31247. /**
  31248. * This function MUST be overwritten by the different WebVR cameras available.
  31249. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31250. * @hidden
  31251. */
  31252. _getWebVRProjectionMatrix(): Matrix;
  31253. /**
  31254. * This function MUST be overwritten by the different WebVR cameras available.
  31255. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31256. * @hidden
  31257. */
  31258. _getWebVRViewMatrix(): Matrix;
  31259. /** @hidden */
  31260. setCameraRigParameter(name: string, value: any): void;
  31261. /**
  31262. * needs to be overridden by children so sub has required properties to be copied
  31263. * @hidden
  31264. */
  31265. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31266. /**
  31267. * May need to be overridden by children
  31268. * @hidden
  31269. */
  31270. _updateRigCameras(): void;
  31271. /** @hidden */
  31272. _setupInputs(): void;
  31273. /**
  31274. * Serialiaze the camera setup to a json represention
  31275. * @returns the JSON representation
  31276. */
  31277. serialize(): any;
  31278. /**
  31279. * Clones the current camera.
  31280. * @param name The cloned camera name
  31281. * @returns the cloned camera
  31282. */
  31283. clone(name: string): Camera;
  31284. /**
  31285. * Gets the direction of the camera relative to a given local axis.
  31286. * @param localAxis Defines the reference axis to provide a relative direction.
  31287. * @return the direction
  31288. */
  31289. getDirection(localAxis: Vector3): Vector3;
  31290. /**
  31291. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31292. * @param localAxis Defines the reference axis to provide a relative direction.
  31293. * @param result Defines the vector to store the result in
  31294. */
  31295. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31296. /**
  31297. * Gets a camera constructor for a given camera type
  31298. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31299. * @param name The name of the camera the result will be able to instantiate
  31300. * @param scene The scene the result will construct the camera in
  31301. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31302. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31303. * @returns a factory method to construc the camera
  31304. */
  31305. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31306. /**
  31307. * Compute the world matrix of the camera.
  31308. * @returns the camera workd matrix
  31309. */
  31310. computeWorldMatrix(): Matrix;
  31311. /**
  31312. * Parse a JSON and creates the camera from the parsed information
  31313. * @param parsedCamera The JSON to parse
  31314. * @param scene The scene to instantiate the camera in
  31315. * @returns the newly constructed camera
  31316. */
  31317. static Parse(parsedCamera: any, scene: Scene): Camera;
  31318. }
  31319. }
  31320. declare module "babylonjs/Misc/tools" {
  31321. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31322. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31323. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31324. import { Observable } from "babylonjs/Misc/observable";
  31325. import { DomManagement } from "babylonjs/Misc/domManagement";
  31326. import { WebRequest } from "babylonjs/Misc/webRequest";
  31327. import { Camera } from "babylonjs/Cameras/camera";
  31328. import { Engine } from "babylonjs/Engines/engine";
  31329. import { Animation } from "babylonjs/Animations/animation";
  31330. /**
  31331. * Interface for any object that can request an animation frame
  31332. */
  31333. export interface ICustomAnimationFrameRequester {
  31334. /**
  31335. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31336. */
  31337. renderFunction?: Function;
  31338. /**
  31339. * Called to request the next frame to render to
  31340. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31341. */
  31342. requestAnimationFrame: Function;
  31343. /**
  31344. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31345. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31346. */
  31347. requestID?: number;
  31348. }
  31349. /**
  31350. * Interface containing an array of animations
  31351. */
  31352. export interface IAnimatable {
  31353. /**
  31354. * Array of animations
  31355. */
  31356. animations: Array<Animation>;
  31357. }
  31358. /** Interface used by value gradients (color, factor, ...) */
  31359. export interface IValueGradient {
  31360. /**
  31361. * Gets or sets the gradient value (between 0 and 1)
  31362. */
  31363. gradient: number;
  31364. }
  31365. /** Class used to store color4 gradient */
  31366. export class ColorGradient implements IValueGradient {
  31367. /**
  31368. * Gets or sets the gradient value (between 0 and 1)
  31369. */
  31370. gradient: number;
  31371. /**
  31372. * Gets or sets first associated color
  31373. */
  31374. color1: Color4;
  31375. /**
  31376. * Gets or sets second associated color
  31377. */
  31378. color2?: Color4;
  31379. /**
  31380. * Will get a color picked randomly between color1 and color2.
  31381. * If color2 is undefined then color1 will be used
  31382. * @param result defines the target Color4 to store the result in
  31383. */
  31384. getColorToRef(result: Color4): void;
  31385. }
  31386. /** Class used to store color 3 gradient */
  31387. export class Color3Gradient implements IValueGradient {
  31388. /**
  31389. * Gets or sets the gradient value (between 0 and 1)
  31390. */
  31391. gradient: number;
  31392. /**
  31393. * Gets or sets the associated color
  31394. */
  31395. color: Color3;
  31396. }
  31397. /** Class used to store factor gradient */
  31398. export class FactorGradient implements IValueGradient {
  31399. /**
  31400. * Gets or sets the gradient value (between 0 and 1)
  31401. */
  31402. gradient: number;
  31403. /**
  31404. * Gets or sets first associated factor
  31405. */
  31406. factor1: number;
  31407. /**
  31408. * Gets or sets second associated factor
  31409. */
  31410. factor2?: number;
  31411. /**
  31412. * Will get a number picked randomly between factor1 and factor2.
  31413. * If factor2 is undefined then factor1 will be used
  31414. * @returns the picked number
  31415. */
  31416. getFactor(): number;
  31417. }
  31418. /**
  31419. * @ignore
  31420. * Application error to support additional information when loading a file
  31421. */
  31422. export class LoadFileError extends Error {
  31423. /** defines the optional web request */
  31424. request?: WebRequest | undefined;
  31425. private static _setPrototypeOf;
  31426. /**
  31427. * Creates a new LoadFileError
  31428. * @param message defines the message of the error
  31429. * @param request defines the optional web request
  31430. */
  31431. constructor(message: string,
  31432. /** defines the optional web request */
  31433. request?: WebRequest | undefined);
  31434. }
  31435. /**
  31436. * Class used to define a retry strategy when error happens while loading assets
  31437. */
  31438. export class RetryStrategy {
  31439. /**
  31440. * Function used to defines an exponential back off strategy
  31441. * @param maxRetries defines the maximum number of retries (3 by default)
  31442. * @param baseInterval defines the interval between retries
  31443. * @returns the strategy function to use
  31444. */
  31445. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31446. }
  31447. /**
  31448. * File request interface
  31449. */
  31450. export interface IFileRequest {
  31451. /**
  31452. * Raised when the request is complete (success or error).
  31453. */
  31454. onCompleteObservable: Observable<IFileRequest>;
  31455. /**
  31456. * Aborts the request for a file.
  31457. */
  31458. abort: () => void;
  31459. }
  31460. /**
  31461. * Class containing a set of static utilities functions
  31462. */
  31463. export class Tools {
  31464. /**
  31465. * Gets or sets the base URL to use to load assets
  31466. */
  31467. static BaseUrl: string;
  31468. /**
  31469. * Enable/Disable Custom HTTP Request Headers globally.
  31470. * default = false
  31471. * @see CustomRequestHeaders
  31472. */
  31473. static UseCustomRequestHeaders: boolean;
  31474. /**
  31475. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31476. * i.e. when loading files, where the server/service expects an Authorization header
  31477. */
  31478. static CustomRequestHeaders: {
  31479. [key: string]: string;
  31480. };
  31481. /**
  31482. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31483. */
  31484. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31485. /**
  31486. * Default behaviour for cors in the application.
  31487. * It can be a string if the expected behavior is identical in the entire app.
  31488. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31489. */
  31490. static CorsBehavior: string | ((url: string | string[]) => string);
  31491. /**
  31492. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31493. * @ignorenaming
  31494. */
  31495. static UseFallbackTexture: boolean;
  31496. /**
  31497. * Use this object to register external classes like custom textures or material
  31498. * to allow the laoders to instantiate them
  31499. */
  31500. static RegisteredExternalClasses: {
  31501. [key: string]: Object;
  31502. };
  31503. /**
  31504. * Texture content used if a texture cannot loaded
  31505. * @ignorenaming
  31506. */
  31507. static fallbackTexture: string;
  31508. /**
  31509. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31510. * @param u defines the coordinate on X axis
  31511. * @param v defines the coordinate on Y axis
  31512. * @param width defines the width of the source data
  31513. * @param height defines the height of the source data
  31514. * @param pixels defines the source byte array
  31515. * @param color defines the output color
  31516. */
  31517. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31518. /**
  31519. * Interpolates between a and b via alpha
  31520. * @param a The lower value (returned when alpha = 0)
  31521. * @param b The upper value (returned when alpha = 1)
  31522. * @param alpha The interpolation-factor
  31523. * @return The mixed value
  31524. */
  31525. static Mix(a: number, b: number, alpha: number): number;
  31526. /**
  31527. * Tries to instantiate a new object from a given class name
  31528. * @param className defines the class name to instantiate
  31529. * @returns the new object or null if the system was not able to do the instantiation
  31530. */
  31531. static Instantiate(className: string): any;
  31532. /**
  31533. * Provides a slice function that will work even on IE
  31534. * @param data defines the array to slice
  31535. * @param start defines the start of the data (optional)
  31536. * @param end defines the end of the data (optional)
  31537. * @returns the new sliced array
  31538. */
  31539. static Slice<T>(data: T, start?: number, end?: number): T;
  31540. /**
  31541. * Polyfill for setImmediate
  31542. * @param action defines the action to execute after the current execution block
  31543. */
  31544. static SetImmediate(action: () => void): void;
  31545. /**
  31546. * Function indicating if a number is an exponent of 2
  31547. * @param value defines the value to test
  31548. * @returns true if the value is an exponent of 2
  31549. */
  31550. static IsExponentOfTwo(value: number): boolean;
  31551. private static _tmpFloatArray;
  31552. /**
  31553. * Returns the nearest 32-bit single precision float representation of a Number
  31554. * @param value A Number. If the parameter is of a different type, it will get converted
  31555. * to a number or to NaN if it cannot be converted
  31556. * @returns number
  31557. */
  31558. static FloatRound(value: number): number;
  31559. /**
  31560. * Find the next highest power of two.
  31561. * @param x Number to start search from.
  31562. * @return Next highest power of two.
  31563. */
  31564. static CeilingPOT(x: number): number;
  31565. /**
  31566. * Find the next lowest power of two.
  31567. * @param x Number to start search from.
  31568. * @return Next lowest power of two.
  31569. */
  31570. static FloorPOT(x: number): number;
  31571. /**
  31572. * Find the nearest power of two.
  31573. * @param x Number to start search from.
  31574. * @return Next nearest power of two.
  31575. */
  31576. static NearestPOT(x: number): number;
  31577. /**
  31578. * Get the closest exponent of two
  31579. * @param value defines the value to approximate
  31580. * @param max defines the maximum value to return
  31581. * @param mode defines how to define the closest value
  31582. * @returns closest exponent of two of the given value
  31583. */
  31584. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31585. /**
  31586. * Extracts the filename from a path
  31587. * @param path defines the path to use
  31588. * @returns the filename
  31589. */
  31590. static GetFilename(path: string): string;
  31591. /**
  31592. * Extracts the "folder" part of a path (everything before the filename).
  31593. * @param uri The URI to extract the info from
  31594. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31595. * @returns The "folder" part of the path
  31596. */
  31597. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31598. /**
  31599. * Extracts text content from a DOM element hierarchy
  31600. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31601. */
  31602. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31603. /**
  31604. * Convert an angle in radians to degrees
  31605. * @param angle defines the angle to convert
  31606. * @returns the angle in degrees
  31607. */
  31608. static ToDegrees(angle: number): number;
  31609. /**
  31610. * Convert an angle in degrees to radians
  31611. * @param angle defines the angle to convert
  31612. * @returns the angle in radians
  31613. */
  31614. static ToRadians(angle: number): number;
  31615. /**
  31616. * Encode a buffer to a base64 string
  31617. * @param buffer defines the buffer to encode
  31618. * @returns the encoded string
  31619. */
  31620. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31621. /**
  31622. * Extracts minimum and maximum values from a list of indexed positions
  31623. * @param positions defines the positions to use
  31624. * @param indices defines the indices to the positions
  31625. * @param indexStart defines the start index
  31626. * @param indexCount defines the end index
  31627. * @param bias defines bias value to add to the result
  31628. * @return minimum and maximum values
  31629. */
  31630. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31631. minimum: Vector3;
  31632. maximum: Vector3;
  31633. };
  31634. /**
  31635. * Extracts minimum and maximum values from a list of positions
  31636. * @param positions defines the positions to use
  31637. * @param start defines the start index in the positions array
  31638. * @param count defines the number of positions to handle
  31639. * @param bias defines bias value to add to the result
  31640. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31641. * @return minimum and maximum values
  31642. */
  31643. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31644. minimum: Vector3;
  31645. maximum: Vector3;
  31646. };
  31647. /**
  31648. * Returns an array if obj is not an array
  31649. * @param obj defines the object to evaluate as an array
  31650. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31651. * @returns either obj directly if obj is an array or a new array containing obj
  31652. */
  31653. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31654. /**
  31655. * Gets the pointer prefix to use
  31656. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31657. */
  31658. static GetPointerPrefix(): string;
  31659. /**
  31660. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31661. * @param func - the function to be called
  31662. * @param requester - the object that will request the next frame. Falls back to window.
  31663. * @returns frame number
  31664. */
  31665. static QueueNewFrame(func: () => void, requester?: any): number;
  31666. /**
  31667. * Ask the browser to promote the current element to fullscreen rendering mode
  31668. * @param element defines the DOM element to promote
  31669. */
  31670. static RequestFullscreen(element: HTMLElement): void;
  31671. /**
  31672. * Asks the browser to exit fullscreen mode
  31673. */
  31674. static ExitFullscreen(): void;
  31675. /**
  31676. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31677. * @param url define the url we are trying
  31678. * @param element define the dom element where to configure the cors policy
  31679. */
  31680. static SetCorsBehavior(url: string | string[], element: {
  31681. crossOrigin: string | null;
  31682. }): void;
  31683. /**
  31684. * Removes unwanted characters from an url
  31685. * @param url defines the url to clean
  31686. * @returns the cleaned url
  31687. */
  31688. static CleanUrl(url: string): string;
  31689. /**
  31690. * Gets or sets a function used to pre-process url before using them to load assets
  31691. */
  31692. static PreprocessUrl: (url: string) => string;
  31693. /**
  31694. * Loads an image as an HTMLImageElement.
  31695. * @param input url string, ArrayBuffer, or Blob to load
  31696. * @param onLoad callback called when the image successfully loads
  31697. * @param onError callback called when the image fails to load
  31698. * @param offlineProvider offline provider for caching
  31699. * @returns the HTMLImageElement of the loaded image
  31700. */
  31701. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31702. /**
  31703. * Loads a file
  31704. * @param url url string, ArrayBuffer, or Blob to load
  31705. * @param onSuccess callback called when the file successfully loads
  31706. * @param onProgress callback called while file is loading (if the server supports this mode)
  31707. * @param offlineProvider defines the offline provider for caching
  31708. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31709. * @param onError callback called when the file fails to load
  31710. * @returns a file request object
  31711. */
  31712. 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;
  31713. /**
  31714. * Load a script (identified by an url). When the url returns, the
  31715. * content of this file is added into a new script element, attached to the DOM (body element)
  31716. * @param scriptUrl defines the url of the script to laod
  31717. * @param onSuccess defines the callback called when the script is loaded
  31718. * @param onError defines the callback to call if an error occurs
  31719. * @param scriptId defines the id of the script element
  31720. */
  31721. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31722. /**
  31723. * Load an asynchronous script (identified by an url). When the url returns, the
  31724. * content of this file is added into a new script element, attached to the DOM (body element)
  31725. * @param scriptUrl defines the url of the script to laod
  31726. * @param scriptId defines the id of the script element
  31727. * @returns a promise request object
  31728. */
  31729. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31730. /**
  31731. * Loads a file from a blob
  31732. * @param fileToLoad defines the blob to use
  31733. * @param callback defines the callback to call when data is loaded
  31734. * @param progressCallback defines the callback to call during loading process
  31735. * @returns a file request object
  31736. */
  31737. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31738. /**
  31739. * Loads a file
  31740. * @param fileToLoad defines the file to load
  31741. * @param callback defines the callback to call when data is loaded
  31742. * @param progressCallBack defines the callback to call during loading process
  31743. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31744. * @returns a file request object
  31745. */
  31746. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31747. /**
  31748. * Creates a data url from a given string content
  31749. * @param content defines the content to convert
  31750. * @returns the new data url link
  31751. */
  31752. static FileAsURL(content: string): string;
  31753. /**
  31754. * Format the given number to a specific decimal format
  31755. * @param value defines the number to format
  31756. * @param decimals defines the number of decimals to use
  31757. * @returns the formatted string
  31758. */
  31759. static Format(value: number, decimals?: number): string;
  31760. /**
  31761. * Checks if a given vector is inside a specific range
  31762. * @param v defines the vector to test
  31763. * @param min defines the minimum range
  31764. * @param max defines the maximum range
  31765. */
  31766. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31767. /**
  31768. * Tries to copy an object by duplicating every property
  31769. * @param source defines the source object
  31770. * @param destination defines the target object
  31771. * @param doNotCopyList defines a list of properties to avoid
  31772. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31773. */
  31774. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31775. /**
  31776. * Gets a boolean indicating if the given object has no own property
  31777. * @param obj defines the object to test
  31778. * @returns true if object has no own property
  31779. */
  31780. static IsEmpty(obj: any): boolean;
  31781. /**
  31782. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31783. * @param str Source string
  31784. * @param suffix Suffix to search for in the source string
  31785. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31786. */
  31787. static EndsWith(str: string, suffix: string): boolean;
  31788. /**
  31789. * Function used to register events at window level
  31790. * @param events defines the events to register
  31791. */
  31792. static RegisterTopRootEvents(events: {
  31793. name: string;
  31794. handler: Nullable<(e: FocusEvent) => any>;
  31795. }[]): void;
  31796. /**
  31797. * Function used to unregister events from window level
  31798. * @param events defines the events to unregister
  31799. */
  31800. static UnregisterTopRootEvents(events: {
  31801. name: string;
  31802. handler: Nullable<(e: FocusEvent) => any>;
  31803. }[]): void;
  31804. /**
  31805. * @ignore
  31806. */
  31807. static _ScreenshotCanvas: HTMLCanvasElement;
  31808. /**
  31809. * Dumps the current bound framebuffer
  31810. * @param width defines the rendering width
  31811. * @param height defines the rendering height
  31812. * @param engine defines the hosting engine
  31813. * @param successCallback defines the callback triggered once the data are available
  31814. * @param mimeType defines the mime type of the result
  31815. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31816. */
  31817. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31818. /**
  31819. * Converts the canvas data to blob.
  31820. * This acts as a polyfill for browsers not supporting the to blob function.
  31821. * @param canvas Defines the canvas to extract the data from
  31822. * @param successCallback Defines the callback triggered once the data are available
  31823. * @param mimeType Defines the mime type of the result
  31824. */
  31825. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31826. /**
  31827. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31828. * @param successCallback defines the callback triggered once the data are available
  31829. * @param mimeType defines the mime type of the result
  31830. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31831. */
  31832. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31833. /**
  31834. * Downloads a blob in the browser
  31835. * @param blob defines the blob to download
  31836. * @param fileName defines the name of the downloaded file
  31837. */
  31838. static Download(blob: Blob, fileName: string): void;
  31839. /**
  31840. * Captures a screenshot of the current rendering
  31841. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31842. * @param engine defines the rendering engine
  31843. * @param camera defines the source camera
  31844. * @param size This parameter can be set to a single number or to an object with the
  31845. * following (optional) properties: precision, width, height. If a single number is passed,
  31846. * it will be used for both width and height. If an object is passed, the screenshot size
  31847. * will be derived from the parameters. The precision property is a multiplier allowing
  31848. * rendering at a higher or lower resolution
  31849. * @param successCallback defines the callback receives a single parameter which contains the
  31850. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31851. * src parameter of an <img> to display it
  31852. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31853. * Check your browser for supported MIME types
  31854. */
  31855. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31856. /**
  31857. * Generates an image screenshot from the specified camera.
  31858. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31859. * @param engine The engine to use for rendering
  31860. * @param camera The camera to use for rendering
  31861. * @param size This parameter can be set to a single number or to an object with the
  31862. * following (optional) properties: precision, width, height. If a single number is passed,
  31863. * it will be used for both width and height. If an object is passed, the screenshot size
  31864. * will be derived from the parameters. The precision property is a multiplier allowing
  31865. * rendering at a higher or lower resolution
  31866. * @param successCallback The callback receives a single parameter which contains the
  31867. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31868. * src parameter of an <img> to display it
  31869. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31870. * Check your browser for supported MIME types
  31871. * @param samples Texture samples (default: 1)
  31872. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31873. * @param fileName A name for for the downloaded file.
  31874. */
  31875. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31876. /**
  31877. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31878. * Be aware Math.random() could cause collisions, but:
  31879. * "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"
  31880. * @returns a pseudo random id
  31881. */
  31882. static RandomId(): string;
  31883. /**
  31884. * Test if the given uri is a base64 string
  31885. * @param uri The uri to test
  31886. * @return True if the uri is a base64 string or false otherwise
  31887. */
  31888. static IsBase64(uri: string): boolean;
  31889. /**
  31890. * Decode the given base64 uri.
  31891. * @param uri The uri to decode
  31892. * @return The decoded base64 data.
  31893. */
  31894. static DecodeBase64(uri: string): ArrayBuffer;
  31895. /**
  31896. * Gets the absolute url.
  31897. * @param url the input url
  31898. * @return the absolute url
  31899. */
  31900. static GetAbsoluteUrl(url: string): string;
  31901. /**
  31902. * No log
  31903. */
  31904. static readonly NoneLogLevel: number;
  31905. /**
  31906. * Only message logs
  31907. */
  31908. static readonly MessageLogLevel: number;
  31909. /**
  31910. * Only warning logs
  31911. */
  31912. static readonly WarningLogLevel: number;
  31913. /**
  31914. * Only error logs
  31915. */
  31916. static readonly ErrorLogLevel: number;
  31917. /**
  31918. * All logs
  31919. */
  31920. static readonly AllLogLevel: number;
  31921. /**
  31922. * Gets a value indicating the number of loading errors
  31923. * @ignorenaming
  31924. */
  31925. static readonly errorsCount: number;
  31926. /**
  31927. * Callback called when a new log is added
  31928. */
  31929. static OnNewCacheEntry: (entry: string) => void;
  31930. /**
  31931. * Log a message to the console
  31932. * @param message defines the message to log
  31933. */
  31934. static Log(message: string): void;
  31935. /**
  31936. * Write a warning message to the console
  31937. * @param message defines the message to log
  31938. */
  31939. static Warn(message: string): void;
  31940. /**
  31941. * Write an error message to the console
  31942. * @param message defines the message to log
  31943. */
  31944. static Error(message: string): void;
  31945. /**
  31946. * Gets current log cache (list of logs)
  31947. */
  31948. static readonly LogCache: string;
  31949. /**
  31950. * Clears the log cache
  31951. */
  31952. static ClearLogCache(): void;
  31953. /**
  31954. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31955. */
  31956. static LogLevels: number;
  31957. /**
  31958. * Checks if the loaded document was accessed via `file:`-Protocol.
  31959. * @returns boolean
  31960. */
  31961. static IsFileURL(): boolean;
  31962. /**
  31963. * Checks if the window object exists
  31964. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31965. */
  31966. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31967. /**
  31968. * No performance log
  31969. */
  31970. static readonly PerformanceNoneLogLevel: number;
  31971. /**
  31972. * Use user marks to log performance
  31973. */
  31974. static readonly PerformanceUserMarkLogLevel: number;
  31975. /**
  31976. * Log performance to the console
  31977. */
  31978. static readonly PerformanceConsoleLogLevel: number;
  31979. private static _performance;
  31980. /**
  31981. * Sets the current performance log level
  31982. */
  31983. static PerformanceLogLevel: number;
  31984. private static _StartPerformanceCounterDisabled;
  31985. private static _EndPerformanceCounterDisabled;
  31986. private static _StartUserMark;
  31987. private static _EndUserMark;
  31988. private static _StartPerformanceConsole;
  31989. private static _EndPerformanceConsole;
  31990. /**
  31991. * Starts a performance counter
  31992. */
  31993. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31994. /**
  31995. * Ends a specific performance coutner
  31996. */
  31997. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31998. /**
  31999. * Gets either window.performance.now() if supported or Date.now() else
  32000. */
  32001. static readonly Now: number;
  32002. /**
  32003. * This method will return the name of the class used to create the instance of the given object.
  32004. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32005. * @param object the object to get the class name from
  32006. * @param isType defines if the object is actually a type
  32007. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32008. */
  32009. static GetClassName(object: any, isType?: boolean): string;
  32010. /**
  32011. * Gets the first element of an array satisfying a given predicate
  32012. * @param array defines the array to browse
  32013. * @param predicate defines the predicate to use
  32014. * @returns null if not found or the element
  32015. */
  32016. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32017. /**
  32018. * This method will return the name of the full name of the class, including its owning module (if any).
  32019. * 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).
  32020. * @param object the object to get the class name from
  32021. * @param isType defines if the object is actually a type
  32022. * @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.
  32023. * @ignorenaming
  32024. */
  32025. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32026. /**
  32027. * Returns a promise that resolves after the given amount of time.
  32028. * @param delay Number of milliseconds to delay
  32029. * @returns Promise that resolves after the given amount of time
  32030. */
  32031. static DelayAsync(delay: number): Promise<void>;
  32032. /**
  32033. * Gets the current gradient from an array of IValueGradient
  32034. * @param ratio defines the current ratio to get
  32035. * @param gradients defines the array of IValueGradient
  32036. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32037. */
  32038. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32039. }
  32040. /**
  32041. * This class is used to track a performance counter which is number based.
  32042. * The user has access to many properties which give statistics of different nature.
  32043. *
  32044. * The implementer can track two kinds of Performance Counter: time and count.
  32045. * 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.
  32046. * 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.
  32047. */
  32048. export class PerfCounter {
  32049. /**
  32050. * Gets or sets a global boolean to turn on and off all the counters
  32051. */
  32052. static Enabled: boolean;
  32053. /**
  32054. * Returns the smallest value ever
  32055. */
  32056. readonly min: number;
  32057. /**
  32058. * Returns the biggest value ever
  32059. */
  32060. readonly max: number;
  32061. /**
  32062. * Returns the average value since the performance counter is running
  32063. */
  32064. readonly average: number;
  32065. /**
  32066. * Returns the average value of the last second the counter was monitored
  32067. */
  32068. readonly lastSecAverage: number;
  32069. /**
  32070. * Returns the current value
  32071. */
  32072. readonly current: number;
  32073. /**
  32074. * Gets the accumulated total
  32075. */
  32076. readonly total: number;
  32077. /**
  32078. * Gets the total value count
  32079. */
  32080. readonly count: number;
  32081. /**
  32082. * Creates a new counter
  32083. */
  32084. constructor();
  32085. /**
  32086. * Call this method to start monitoring a new frame.
  32087. * 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.
  32088. */
  32089. fetchNewFrame(): void;
  32090. /**
  32091. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32092. * @param newCount the count value to add to the monitored count
  32093. * @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.
  32094. */
  32095. addCount(newCount: number, fetchResult: boolean): void;
  32096. /**
  32097. * Start monitoring this performance counter
  32098. */
  32099. beginMonitoring(): void;
  32100. /**
  32101. * Compute the time lapsed since the previous beginMonitoring() call.
  32102. * @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
  32103. */
  32104. endMonitoring(newFrame?: boolean): void;
  32105. private _fetchResult;
  32106. private _startMonitoringTime;
  32107. private _min;
  32108. private _max;
  32109. private _average;
  32110. private _current;
  32111. private _totalValueCount;
  32112. private _totalAccumulated;
  32113. private _lastSecAverage;
  32114. private _lastSecAccumulated;
  32115. private _lastSecTime;
  32116. private _lastSecValueCount;
  32117. }
  32118. /**
  32119. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32120. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32121. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32122. * @param name The name of the class, case should be preserved
  32123. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32124. */
  32125. export function className(name: string, module?: string): (target: Object) => void;
  32126. /**
  32127. * An implementation of a loop for asynchronous functions.
  32128. */
  32129. export class AsyncLoop {
  32130. /**
  32131. * Defines the number of iterations for the loop
  32132. */
  32133. iterations: number;
  32134. /**
  32135. * Defines the current index of the loop.
  32136. */
  32137. index: number;
  32138. private _done;
  32139. private _fn;
  32140. private _successCallback;
  32141. /**
  32142. * Constructor.
  32143. * @param iterations the number of iterations.
  32144. * @param func the function to run each iteration
  32145. * @param successCallback the callback that will be called upon succesful execution
  32146. * @param offset starting offset.
  32147. */
  32148. constructor(
  32149. /**
  32150. * Defines the number of iterations for the loop
  32151. */
  32152. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32153. /**
  32154. * Execute the next iteration. Must be called after the last iteration was finished.
  32155. */
  32156. executeNext(): void;
  32157. /**
  32158. * Break the loop and run the success callback.
  32159. */
  32160. breakLoop(): void;
  32161. /**
  32162. * Create and run an async loop.
  32163. * @param iterations the number of iterations.
  32164. * @param fn the function to run each iteration
  32165. * @param successCallback the callback that will be called upon succesful execution
  32166. * @param offset starting offset.
  32167. * @returns the created async loop object
  32168. */
  32169. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32170. /**
  32171. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32172. * @param iterations total number of iterations
  32173. * @param syncedIterations number of synchronous iterations in each async iteration.
  32174. * @param fn the function to call each iteration.
  32175. * @param callback a success call back that will be called when iterating stops.
  32176. * @param breakFunction a break condition (optional)
  32177. * @param timeout timeout settings for the setTimeout function. default - 0.
  32178. * @returns the created async loop object
  32179. */
  32180. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32181. }
  32182. }
  32183. declare module "babylonjs/Collisions/collisionCoordinator" {
  32184. import { Nullable } from "babylonjs/types";
  32185. import { Scene } from "babylonjs/scene";
  32186. import { Vector3 } from "babylonjs/Maths/math";
  32187. import { Collider } from "babylonjs/Collisions/collider";
  32188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32189. /** @hidden */
  32190. export interface ICollisionCoordinator {
  32191. createCollider(): Collider;
  32192. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32193. init(scene: Scene): void;
  32194. }
  32195. /** @hidden */
  32196. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32197. private _scene;
  32198. private _scaledPosition;
  32199. private _scaledVelocity;
  32200. private _finalPosition;
  32201. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32202. createCollider(): Collider;
  32203. init(scene: Scene): void;
  32204. private _collideWithWorld;
  32205. }
  32206. }
  32207. declare module "babylonjs/Animations/animationGroup" {
  32208. import { Animatable } from "babylonjs/Animations/animatable";
  32209. import { Animation } from "babylonjs/Animations/animation";
  32210. import { Scene, IDisposable } from "babylonjs/scene";
  32211. import { Observable } from "babylonjs/Misc/observable";
  32212. import { Nullable } from "babylonjs/types";
  32213. /**
  32214. * This class defines the direct association between an animation and a target
  32215. */
  32216. export class TargetedAnimation {
  32217. /**
  32218. * Animation to perform
  32219. */
  32220. animation: Animation;
  32221. /**
  32222. * Target to animate
  32223. */
  32224. target: any;
  32225. }
  32226. /**
  32227. * Use this class to create coordinated animations on multiple targets
  32228. */
  32229. export class AnimationGroup implements IDisposable {
  32230. /** The name of the animation group */
  32231. name: string;
  32232. private _scene;
  32233. private _targetedAnimations;
  32234. private _animatables;
  32235. private _from;
  32236. private _to;
  32237. private _isStarted;
  32238. private _isPaused;
  32239. private _speedRatio;
  32240. /**
  32241. * Gets or sets the unique id of the node
  32242. */
  32243. uniqueId: number;
  32244. /**
  32245. * This observable will notify when one animation have ended
  32246. */
  32247. onAnimationEndObservable: Observable<TargetedAnimation>;
  32248. /**
  32249. * Observer raised when one animation loops
  32250. */
  32251. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32252. /**
  32253. * This observable will notify when all animations have ended.
  32254. */
  32255. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32256. /**
  32257. * This observable will notify when all animations have paused.
  32258. */
  32259. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32260. /**
  32261. * This observable will notify when all animations are playing.
  32262. */
  32263. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32264. /**
  32265. * Gets the first frame
  32266. */
  32267. readonly from: number;
  32268. /**
  32269. * Gets the last frame
  32270. */
  32271. readonly to: number;
  32272. /**
  32273. * Define if the animations are started
  32274. */
  32275. readonly isStarted: boolean;
  32276. /**
  32277. * Gets a value indicating that the current group is playing
  32278. */
  32279. readonly isPlaying: boolean;
  32280. /**
  32281. * Gets or sets the speed ratio to use for all animations
  32282. */
  32283. /**
  32284. * Gets or sets the speed ratio to use for all animations
  32285. */
  32286. speedRatio: number;
  32287. /**
  32288. * Gets the targeted animations for this animation group
  32289. */
  32290. readonly targetedAnimations: Array<TargetedAnimation>;
  32291. /**
  32292. * returning the list of animatables controlled by this animation group.
  32293. */
  32294. readonly animatables: Array<Animatable>;
  32295. /**
  32296. * Instantiates a new Animation Group.
  32297. * This helps managing several animations at once.
  32298. * @see http://doc.babylonjs.com/how_to/group
  32299. * @param name Defines the name of the group
  32300. * @param scene Defines the scene the group belongs to
  32301. */
  32302. constructor(
  32303. /** The name of the animation group */
  32304. name: string, scene?: Nullable<Scene>);
  32305. /**
  32306. * Add an animation (with its target) in the group
  32307. * @param animation defines the animation we want to add
  32308. * @param target defines the target of the animation
  32309. * @returns the TargetedAnimation object
  32310. */
  32311. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32312. /**
  32313. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32314. * It can add constant keys at begin or end
  32315. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32316. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32317. * @returns the animation group
  32318. */
  32319. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32320. /**
  32321. * Start all animations on given targets
  32322. * @param loop defines if animations must loop
  32323. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32324. * @param from defines the from key (optional)
  32325. * @param to defines the to key (optional)
  32326. * @returns the current animation group
  32327. */
  32328. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32329. /**
  32330. * Pause all animations
  32331. * @returns the animation group
  32332. */
  32333. pause(): AnimationGroup;
  32334. /**
  32335. * Play all animations to initial state
  32336. * This function will start() the animations if they were not started or will restart() them if they were paused
  32337. * @param loop defines if animations must loop
  32338. * @returns the animation group
  32339. */
  32340. play(loop?: boolean): AnimationGroup;
  32341. /**
  32342. * Reset all animations to initial state
  32343. * @returns the animation group
  32344. */
  32345. reset(): AnimationGroup;
  32346. /**
  32347. * Restart animations from key 0
  32348. * @returns the animation group
  32349. */
  32350. restart(): AnimationGroup;
  32351. /**
  32352. * Stop all animations
  32353. * @returns the animation group
  32354. */
  32355. stop(): AnimationGroup;
  32356. /**
  32357. * Set animation weight for all animatables
  32358. * @param weight defines the weight to use
  32359. * @return the animationGroup
  32360. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32361. */
  32362. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32363. /**
  32364. * Synchronize and normalize all animatables with a source animatable
  32365. * @param root defines the root animatable to synchronize with
  32366. * @return the animationGroup
  32367. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32368. */
  32369. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32370. /**
  32371. * Goes to a specific frame in this animation group
  32372. * @param frame the frame number to go to
  32373. * @return the animationGroup
  32374. */
  32375. goToFrame(frame: number): AnimationGroup;
  32376. /**
  32377. * Dispose all associated resources
  32378. */
  32379. dispose(): void;
  32380. private _checkAnimationGroupEnded;
  32381. /**
  32382. * Clone the current animation group and returns a copy
  32383. * @param newName defines the name of the new group
  32384. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32385. * @returns the new aniamtion group
  32386. */
  32387. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32388. /**
  32389. * Returns a new AnimationGroup object parsed from the source provided.
  32390. * @param parsedAnimationGroup defines the source
  32391. * @param scene defines the scene that will receive the animationGroup
  32392. * @returns a new AnimationGroup
  32393. */
  32394. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32395. /**
  32396. * Returns the string "AnimationGroup"
  32397. * @returns "AnimationGroup"
  32398. */
  32399. getClassName(): string;
  32400. /**
  32401. * Creates a detailled string about the object
  32402. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32403. * @returns a string representing the object
  32404. */
  32405. toString(fullDetails?: boolean): string;
  32406. }
  32407. }
  32408. declare module "babylonjs/scene" {
  32409. import { Nullable } from "babylonjs/types";
  32410. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32411. import { Observable } from "babylonjs/Misc/observable";
  32412. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32413. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32414. import { Geometry } from "babylonjs/Meshes/geometry";
  32415. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32416. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32418. import { Mesh } from "babylonjs/Meshes/mesh";
  32419. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32420. import { Bone } from "babylonjs/Bones/bone";
  32421. import { Skeleton } from "babylonjs/Bones/skeleton";
  32422. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32423. import { Camera } from "babylonjs/Cameras/camera";
  32424. import { AbstractScene } from "babylonjs/abstractScene";
  32425. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32426. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32427. import { Material } from "babylonjs/Materials/material";
  32428. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32429. import { Effect } from "babylonjs/Materials/effect";
  32430. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32431. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32432. import { Light } from "babylonjs/Lights/light";
  32433. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32434. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32435. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32436. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32437. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32438. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32439. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32440. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32441. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32442. import { Engine } from "babylonjs/Engines/engine";
  32443. import { Node } from "babylonjs/node";
  32444. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32445. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32446. import { WebRequest } from "babylonjs/Misc/webRequest";
  32447. import { Ray } from "babylonjs/Culling/ray";
  32448. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32449. import { Animation } from "babylonjs/Animations/animation";
  32450. import { Animatable } from "babylonjs/Animations/animatable";
  32451. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32452. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32453. import { Collider } from "babylonjs/Collisions/collider";
  32454. /**
  32455. * Define an interface for all classes that will hold resources
  32456. */
  32457. export interface IDisposable {
  32458. /**
  32459. * Releases all held resources
  32460. */
  32461. dispose(): void;
  32462. }
  32463. /** Interface defining initialization parameters for Scene class */
  32464. export interface SceneOptions {
  32465. /**
  32466. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32467. * It will improve performance when the number of geometries becomes important.
  32468. */
  32469. useGeometryUniqueIdsMap?: boolean;
  32470. /**
  32471. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32472. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32473. */
  32474. useMaterialMeshMap?: boolean;
  32475. /**
  32476. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32477. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32478. */
  32479. useClonedMeshhMap?: boolean;
  32480. }
  32481. /**
  32482. * Represents a scene to be rendered by the engine.
  32483. * @see http://doc.babylonjs.com/features/scene
  32484. */
  32485. export class Scene extends AbstractScene implements IAnimatable {
  32486. private static _uniqueIdCounter;
  32487. /** The fog is deactivated */
  32488. static readonly FOGMODE_NONE: number;
  32489. /** The fog density is following an exponential function */
  32490. static readonly FOGMODE_EXP: number;
  32491. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32492. static readonly FOGMODE_EXP2: number;
  32493. /** The fog density is following a linear function. */
  32494. static readonly FOGMODE_LINEAR: number;
  32495. /**
  32496. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32497. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32498. */
  32499. static MinDeltaTime: number;
  32500. /**
  32501. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32502. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32503. */
  32504. static MaxDeltaTime: number;
  32505. /**
  32506. * Factory used to create the default material.
  32507. * @param name The name of the material to create
  32508. * @param scene The scene to create the material for
  32509. * @returns The default material
  32510. */
  32511. static DefaultMaterialFactory(scene: Scene): Material;
  32512. /**
  32513. * Factory used to create the a collision coordinator.
  32514. * @returns The collision coordinator
  32515. */
  32516. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32517. /** @hidden */
  32518. readonly _isScene: boolean;
  32519. /**
  32520. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32521. */
  32522. autoClear: boolean;
  32523. /**
  32524. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32525. */
  32526. autoClearDepthAndStencil: boolean;
  32527. /**
  32528. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32529. */
  32530. clearColor: Color4;
  32531. /**
  32532. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32533. */
  32534. ambientColor: Color3;
  32535. /**
  32536. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32537. * It should only be one of the following (if not the default embedded one):
  32538. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32539. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32540. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32541. * The material properties need to be setup according to the type of texture in use.
  32542. */
  32543. environmentBRDFTexture: BaseTexture;
  32544. /** @hidden */
  32545. protected _environmentTexture: Nullable<BaseTexture>;
  32546. /**
  32547. * Texture used in all pbr material as the reflection texture.
  32548. * As in the majority of the scene they are the same (exception for multi room and so on),
  32549. * this is easier to reference from here than from all the materials.
  32550. */
  32551. /**
  32552. * Texture used in all pbr material as the reflection texture.
  32553. * As in the majority of the scene they are the same (exception for multi room and so on),
  32554. * this is easier to set here than in all the materials.
  32555. */
  32556. environmentTexture: Nullable<BaseTexture>;
  32557. /** @hidden */
  32558. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32559. /**
  32560. * Default image processing configuration used either in the rendering
  32561. * Forward main pass or through the imageProcessingPostProcess if present.
  32562. * As in the majority of the scene they are the same (exception for multi camera),
  32563. * this is easier to reference from here than from all the materials and post process.
  32564. *
  32565. * No setter as we it is a shared configuration, you can set the values instead.
  32566. */
  32567. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32568. private _forceWireframe;
  32569. /**
  32570. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32571. */
  32572. forceWireframe: boolean;
  32573. private _forcePointsCloud;
  32574. /**
  32575. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32576. */
  32577. forcePointsCloud: boolean;
  32578. /**
  32579. * Gets or sets the active clipplane 1
  32580. */
  32581. clipPlane: Nullable<Plane>;
  32582. /**
  32583. * Gets or sets the active clipplane 2
  32584. */
  32585. clipPlane2: Nullable<Plane>;
  32586. /**
  32587. * Gets or sets the active clipplane 3
  32588. */
  32589. clipPlane3: Nullable<Plane>;
  32590. /**
  32591. * Gets or sets the active clipplane 4
  32592. */
  32593. clipPlane4: Nullable<Plane>;
  32594. /**
  32595. * Gets or sets a boolean indicating if animations are enabled
  32596. */
  32597. animationsEnabled: boolean;
  32598. private _animationPropertiesOverride;
  32599. /**
  32600. * Gets or sets the animation properties override
  32601. */
  32602. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32603. /**
  32604. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32605. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32606. */
  32607. useConstantAnimationDeltaTime: boolean;
  32608. /**
  32609. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32610. * Please note that it requires to run a ray cast through the scene on every frame
  32611. */
  32612. constantlyUpdateMeshUnderPointer: boolean;
  32613. /**
  32614. * Defines the HTML cursor to use when hovering over interactive elements
  32615. */
  32616. hoverCursor: string;
  32617. /**
  32618. * Defines the HTML default cursor to use (empty by default)
  32619. */
  32620. defaultCursor: string;
  32621. /**
  32622. * This is used to call preventDefault() on pointer down
  32623. * in order to block unwanted artifacts like system double clicks
  32624. */
  32625. preventDefaultOnPointerDown: boolean;
  32626. /**
  32627. * This is used to call preventDefault() on pointer up
  32628. * in order to block unwanted artifacts like system double clicks
  32629. */
  32630. preventDefaultOnPointerUp: boolean;
  32631. /**
  32632. * Gets or sets user defined metadata
  32633. */
  32634. metadata: any;
  32635. /**
  32636. * For internal use only. Please do not use.
  32637. */
  32638. reservedDataStore: any;
  32639. /**
  32640. * Gets the name of the plugin used to load this scene (null by default)
  32641. */
  32642. loadingPluginName: string;
  32643. /**
  32644. * Use this array to add regular expressions used to disable offline support for specific urls
  32645. */
  32646. disableOfflineSupportExceptionRules: RegExp[];
  32647. /**
  32648. * An event triggered when the scene is disposed.
  32649. */
  32650. onDisposeObservable: Observable<Scene>;
  32651. private _onDisposeObserver;
  32652. /** Sets a function to be executed when this scene is disposed. */
  32653. onDispose: () => void;
  32654. /**
  32655. * An event triggered before rendering the scene (right after animations and physics)
  32656. */
  32657. onBeforeRenderObservable: Observable<Scene>;
  32658. private _onBeforeRenderObserver;
  32659. /** Sets a function to be executed before rendering this scene */
  32660. beforeRender: Nullable<() => void>;
  32661. /**
  32662. * An event triggered after rendering the scene
  32663. */
  32664. onAfterRenderObservable: Observable<Scene>;
  32665. private _onAfterRenderObserver;
  32666. /** Sets a function to be executed after rendering this scene */
  32667. afterRender: Nullable<() => void>;
  32668. /**
  32669. * An event triggered before animating the scene
  32670. */
  32671. onBeforeAnimationsObservable: Observable<Scene>;
  32672. /**
  32673. * An event triggered after animations processing
  32674. */
  32675. onAfterAnimationsObservable: Observable<Scene>;
  32676. /**
  32677. * An event triggered before draw calls are ready to be sent
  32678. */
  32679. onBeforeDrawPhaseObservable: Observable<Scene>;
  32680. /**
  32681. * An event triggered after draw calls have been sent
  32682. */
  32683. onAfterDrawPhaseObservable: Observable<Scene>;
  32684. /**
  32685. * An event triggered when the scene is ready
  32686. */
  32687. onReadyObservable: Observable<Scene>;
  32688. /**
  32689. * An event triggered before rendering a camera
  32690. */
  32691. onBeforeCameraRenderObservable: Observable<Camera>;
  32692. private _onBeforeCameraRenderObserver;
  32693. /** Sets a function to be executed before rendering a camera*/
  32694. beforeCameraRender: () => void;
  32695. /**
  32696. * An event triggered after rendering a camera
  32697. */
  32698. onAfterCameraRenderObservable: Observable<Camera>;
  32699. private _onAfterCameraRenderObserver;
  32700. /** Sets a function to be executed after rendering a camera*/
  32701. afterCameraRender: () => void;
  32702. /**
  32703. * An event triggered when active meshes evaluation is about to start
  32704. */
  32705. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32706. /**
  32707. * An event triggered when active meshes evaluation is done
  32708. */
  32709. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32710. /**
  32711. * An event triggered when particles rendering is about to start
  32712. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32713. */
  32714. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32715. /**
  32716. * An event triggered when particles rendering is done
  32717. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32718. */
  32719. onAfterParticlesRenderingObservable: Observable<Scene>;
  32720. /**
  32721. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32722. */
  32723. onDataLoadedObservable: Observable<Scene>;
  32724. /**
  32725. * An event triggered when a camera is created
  32726. */
  32727. onNewCameraAddedObservable: Observable<Camera>;
  32728. /**
  32729. * An event triggered when a camera is removed
  32730. */
  32731. onCameraRemovedObservable: Observable<Camera>;
  32732. /**
  32733. * An event triggered when a light is created
  32734. */
  32735. onNewLightAddedObservable: Observable<Light>;
  32736. /**
  32737. * An event triggered when a light is removed
  32738. */
  32739. onLightRemovedObservable: Observable<Light>;
  32740. /**
  32741. * An event triggered when a geometry is created
  32742. */
  32743. onNewGeometryAddedObservable: Observable<Geometry>;
  32744. /**
  32745. * An event triggered when a geometry is removed
  32746. */
  32747. onGeometryRemovedObservable: Observable<Geometry>;
  32748. /**
  32749. * An event triggered when a transform node is created
  32750. */
  32751. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32752. /**
  32753. * An event triggered when a transform node is removed
  32754. */
  32755. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32756. /**
  32757. * An event triggered when a mesh is created
  32758. */
  32759. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32760. /**
  32761. * An event triggered when a mesh is removed
  32762. */
  32763. onMeshRemovedObservable: Observable<AbstractMesh>;
  32764. /**
  32765. * An event triggered when a skeleton is created
  32766. */
  32767. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32768. /**
  32769. * An event triggered when a skeleton is removed
  32770. */
  32771. onSkeletonRemovedObservable: Observable<Skeleton>;
  32772. /**
  32773. * An event triggered when a material is created
  32774. */
  32775. onNewMaterialAddedObservable: Observable<Material>;
  32776. /**
  32777. * An event triggered when a material is removed
  32778. */
  32779. onMaterialRemovedObservable: Observable<Material>;
  32780. /**
  32781. * An event triggered when a texture is created
  32782. */
  32783. onNewTextureAddedObservable: Observable<BaseTexture>;
  32784. /**
  32785. * An event triggered when a texture is removed
  32786. */
  32787. onTextureRemovedObservable: Observable<BaseTexture>;
  32788. /**
  32789. * An event triggered when render targets are about to be rendered
  32790. * Can happen multiple times per frame.
  32791. */
  32792. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32793. /**
  32794. * An event triggered when render targets were rendered.
  32795. * Can happen multiple times per frame.
  32796. */
  32797. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32798. /**
  32799. * An event triggered before calculating deterministic simulation step
  32800. */
  32801. onBeforeStepObservable: Observable<Scene>;
  32802. /**
  32803. * An event triggered after calculating deterministic simulation step
  32804. */
  32805. onAfterStepObservable: Observable<Scene>;
  32806. /**
  32807. * An event triggered when the activeCamera property is updated
  32808. */
  32809. onActiveCameraChanged: Observable<Scene>;
  32810. /**
  32811. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32812. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32813. * 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)
  32814. */
  32815. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32816. /**
  32817. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32818. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32819. * 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)
  32820. */
  32821. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32822. /**
  32823. * This Observable will when a mesh has been imported into the scene.
  32824. */
  32825. onMeshImportedObservable: Observable<AbstractMesh>;
  32826. /**
  32827. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32828. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32829. */
  32830. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32831. /** @hidden */
  32832. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32833. /**
  32834. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32835. */
  32836. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32837. /**
  32838. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32839. */
  32840. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32841. /**
  32842. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32843. */
  32844. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32845. private _onPointerMove;
  32846. private _onPointerDown;
  32847. private _onPointerUp;
  32848. /** Callback called when a pointer move is detected */
  32849. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32850. /** Callback called when a pointer down is detected */
  32851. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32852. /** Callback called when a pointer up is detected */
  32853. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32854. /** Callback called when a pointer pick is detected */
  32855. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32856. /**
  32857. * 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).
  32858. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32859. */
  32860. onPrePointerObservable: Observable<PointerInfoPre>;
  32861. /**
  32862. * Observable event triggered each time an input event is received from the rendering canvas
  32863. */
  32864. onPointerObservable: Observable<PointerInfo>;
  32865. /**
  32866. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32867. */
  32868. readonly unTranslatedPointer: Vector2;
  32869. /** The distance in pixel that you have to move to prevent some events */
  32870. static DragMovementThreshold: number;
  32871. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32872. static LongPressDelay: number;
  32873. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32874. static DoubleClickDelay: number;
  32875. /** If you need to check double click without raising a single click at first click, enable this flag */
  32876. static ExclusiveDoubleClickMode: boolean;
  32877. private _initClickEvent;
  32878. private _initActionManager;
  32879. private _delayedSimpleClick;
  32880. private _delayedSimpleClickTimeout;
  32881. private _previousDelayedSimpleClickTimeout;
  32882. private _meshPickProceed;
  32883. private _previousButtonPressed;
  32884. private _currentPickResult;
  32885. private _previousPickResult;
  32886. private _totalPointersPressed;
  32887. private _doubleClickOccured;
  32888. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32889. cameraToUseForPointers: Nullable<Camera>;
  32890. private _pointerX;
  32891. private _pointerY;
  32892. private _unTranslatedPointerX;
  32893. private _unTranslatedPointerY;
  32894. private _startingPointerPosition;
  32895. private _previousStartingPointerPosition;
  32896. private _startingPointerTime;
  32897. private _previousStartingPointerTime;
  32898. private _pointerCaptures;
  32899. private _timeAccumulator;
  32900. private _currentStepId;
  32901. private _currentInternalStep;
  32902. /** @hidden */
  32903. _mirroredCameraPosition: Nullable<Vector3>;
  32904. /**
  32905. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32906. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32907. */
  32908. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32909. /**
  32910. * Observable event triggered each time an keyboard event is received from the hosting window
  32911. */
  32912. onKeyboardObservable: Observable<KeyboardInfo>;
  32913. private _onKeyDown;
  32914. private _onKeyUp;
  32915. private _onCanvasFocusObserver;
  32916. private _onCanvasBlurObserver;
  32917. private _useRightHandedSystem;
  32918. /**
  32919. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32920. */
  32921. useRightHandedSystem: boolean;
  32922. /**
  32923. * Sets the step Id used by deterministic lock step
  32924. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32925. * @param newStepId defines the step Id
  32926. */
  32927. setStepId(newStepId: number): void;
  32928. /**
  32929. * Gets the step Id used by deterministic lock step
  32930. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32931. * @returns the step Id
  32932. */
  32933. getStepId(): number;
  32934. /**
  32935. * Gets the internal step used by deterministic lock step
  32936. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32937. * @returns the internal step
  32938. */
  32939. getInternalStep(): number;
  32940. private _fogEnabled;
  32941. /**
  32942. * Gets or sets a boolean indicating if fog is enabled on this scene
  32943. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32944. * (Default is true)
  32945. */
  32946. fogEnabled: boolean;
  32947. private _fogMode;
  32948. /**
  32949. * Gets or sets the fog mode to use
  32950. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32951. * | mode | value |
  32952. * | --- | --- |
  32953. * | FOGMODE_NONE | 0 |
  32954. * | FOGMODE_EXP | 1 |
  32955. * | FOGMODE_EXP2 | 2 |
  32956. * | FOGMODE_LINEAR | 3 |
  32957. */
  32958. fogMode: number;
  32959. /**
  32960. * Gets or sets the fog color to use
  32961. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32962. * (Default is Color3(0.2, 0.2, 0.3))
  32963. */
  32964. fogColor: Color3;
  32965. /**
  32966. * Gets or sets the fog density to use
  32967. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32968. * (Default is 0.1)
  32969. */
  32970. fogDensity: number;
  32971. /**
  32972. * Gets or sets the fog start distance to use
  32973. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32974. * (Default is 0)
  32975. */
  32976. fogStart: number;
  32977. /**
  32978. * Gets or sets the fog end distance to use
  32979. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32980. * (Default is 1000)
  32981. */
  32982. fogEnd: number;
  32983. private _shadowsEnabled;
  32984. /**
  32985. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32986. */
  32987. shadowsEnabled: boolean;
  32988. private _lightsEnabled;
  32989. /**
  32990. * Gets or sets a boolean indicating if lights are enabled on this scene
  32991. */
  32992. lightsEnabled: boolean;
  32993. /** All of the active cameras added to this scene. */
  32994. activeCameras: Camera[];
  32995. /** @hidden */
  32996. _activeCamera: Nullable<Camera>;
  32997. /** Gets or sets the current active camera */
  32998. activeCamera: Nullable<Camera>;
  32999. private _defaultMaterial;
  33000. /** The default material used on meshes when no material is affected */
  33001. /** The default material used on meshes when no material is affected */
  33002. defaultMaterial: Material;
  33003. private _texturesEnabled;
  33004. /**
  33005. * Gets or sets a boolean indicating if textures are enabled on this scene
  33006. */
  33007. texturesEnabled: boolean;
  33008. /**
  33009. * Gets or sets a boolean indicating if particles are enabled on this scene
  33010. */
  33011. particlesEnabled: boolean;
  33012. /**
  33013. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33014. */
  33015. spritesEnabled: boolean;
  33016. private _skeletonsEnabled;
  33017. /**
  33018. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33019. */
  33020. skeletonsEnabled: boolean;
  33021. /**
  33022. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33023. */
  33024. lensFlaresEnabled: boolean;
  33025. /**
  33026. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33027. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33028. */
  33029. collisionsEnabled: boolean;
  33030. private _collisionCoordinator;
  33031. /** @hidden */
  33032. readonly collisionCoordinator: ICollisionCoordinator;
  33033. /**
  33034. * Defines the gravity applied to this scene (used only for collisions)
  33035. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33036. */
  33037. gravity: Vector3;
  33038. /**
  33039. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33040. */
  33041. postProcessesEnabled: boolean;
  33042. /**
  33043. * The list of postprocesses added to the scene
  33044. */
  33045. postProcesses: PostProcess[];
  33046. /**
  33047. * Gets the current postprocess manager
  33048. */
  33049. postProcessManager: PostProcessManager;
  33050. /**
  33051. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33052. */
  33053. renderTargetsEnabled: boolean;
  33054. /**
  33055. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33056. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33057. */
  33058. dumpNextRenderTargets: boolean;
  33059. /**
  33060. * The list of user defined render targets added to the scene
  33061. */
  33062. customRenderTargets: RenderTargetTexture[];
  33063. /**
  33064. * Defines if texture loading must be delayed
  33065. * If true, textures will only be loaded when they need to be rendered
  33066. */
  33067. useDelayedTextureLoading: boolean;
  33068. /**
  33069. * Gets the list of meshes imported to the scene through SceneLoader
  33070. */
  33071. importedMeshesFiles: String[];
  33072. /**
  33073. * Gets or sets a boolean indicating if probes are enabled on this scene
  33074. */
  33075. probesEnabled: boolean;
  33076. /**
  33077. * Gets or sets the current offline provider to use to store scene data
  33078. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33079. */
  33080. offlineProvider: IOfflineProvider;
  33081. /**
  33082. * Gets or sets the action manager associated with the scene
  33083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33084. */
  33085. actionManager: AbstractActionManager;
  33086. private _meshesForIntersections;
  33087. /**
  33088. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33089. */
  33090. proceduralTexturesEnabled: boolean;
  33091. private _engine;
  33092. private _totalVertices;
  33093. /** @hidden */
  33094. _activeIndices: PerfCounter;
  33095. /** @hidden */
  33096. _activeParticles: PerfCounter;
  33097. /** @hidden */
  33098. _activeBones: PerfCounter;
  33099. private _animationRatio;
  33100. /** @hidden */
  33101. _animationTimeLast: number;
  33102. /** @hidden */
  33103. _animationTime: number;
  33104. /**
  33105. * Gets or sets a general scale for animation speed
  33106. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33107. */
  33108. animationTimeScale: number;
  33109. /** @hidden */
  33110. _cachedMaterial: Nullable<Material>;
  33111. /** @hidden */
  33112. _cachedEffect: Nullable<Effect>;
  33113. /** @hidden */
  33114. _cachedVisibility: Nullable<number>;
  33115. private _renderId;
  33116. private _frameId;
  33117. private _executeWhenReadyTimeoutId;
  33118. private _intermediateRendering;
  33119. private _viewUpdateFlag;
  33120. private _projectionUpdateFlag;
  33121. /** @hidden */
  33122. _toBeDisposed: Nullable<IDisposable>[];
  33123. private _activeRequests;
  33124. /** @hidden */
  33125. _pendingData: any[];
  33126. private _isDisposed;
  33127. /**
  33128. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33129. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33130. */
  33131. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33132. private _activeMeshes;
  33133. private _processedMaterials;
  33134. private _renderTargets;
  33135. /** @hidden */
  33136. _activeParticleSystems: SmartArray<IParticleSystem>;
  33137. private _activeSkeletons;
  33138. private _softwareSkinnedMeshes;
  33139. private _renderingManager;
  33140. /** @hidden */
  33141. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33142. private _transformMatrix;
  33143. private _sceneUbo;
  33144. /** @hidden */
  33145. _viewMatrix: Matrix;
  33146. private _projectionMatrix;
  33147. private _wheelEventName;
  33148. /** @hidden */
  33149. _forcedViewPosition: Nullable<Vector3>;
  33150. /** @hidden */
  33151. _frustumPlanes: Plane[];
  33152. /**
  33153. * Gets the list of frustum planes (built from the active camera)
  33154. */
  33155. readonly frustumPlanes: Plane[];
  33156. /**
  33157. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33158. * This is useful if there are more lights that the maximum simulteanous authorized
  33159. */
  33160. requireLightSorting: boolean;
  33161. /** @hidden */
  33162. readonly useMaterialMeshMap: boolean;
  33163. /** @hidden */
  33164. readonly useClonedMeshhMap: boolean;
  33165. private _pointerOverMesh;
  33166. private _pickedDownMesh;
  33167. private _pickedUpMesh;
  33168. private _externalData;
  33169. private _uid;
  33170. /**
  33171. * @hidden
  33172. * Backing store of defined scene components.
  33173. */
  33174. _components: ISceneComponent[];
  33175. /**
  33176. * @hidden
  33177. * Backing store of defined scene components.
  33178. */
  33179. _serializableComponents: ISceneSerializableComponent[];
  33180. /**
  33181. * List of components to register on the next registration step.
  33182. */
  33183. private _transientComponents;
  33184. /**
  33185. * Registers the transient components if needed.
  33186. */
  33187. private _registerTransientComponents;
  33188. /**
  33189. * @hidden
  33190. * Add a component to the scene.
  33191. * Note that the ccomponent could be registered on th next frame if this is called after
  33192. * the register component stage.
  33193. * @param component Defines the component to add to the scene
  33194. */
  33195. _addComponent(component: ISceneComponent): void;
  33196. /**
  33197. * @hidden
  33198. * Gets a component from the scene.
  33199. * @param name defines the name of the component to retrieve
  33200. * @returns the component or null if not present
  33201. */
  33202. _getComponent(name: string): Nullable<ISceneComponent>;
  33203. /**
  33204. * @hidden
  33205. * Defines the actions happening before camera updates.
  33206. */
  33207. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33208. /**
  33209. * @hidden
  33210. * Defines the actions happening before clear the canvas.
  33211. */
  33212. _beforeClearStage: Stage<SimpleStageAction>;
  33213. /**
  33214. * @hidden
  33215. * Defines the actions when collecting render targets for the frame.
  33216. */
  33217. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33218. /**
  33219. * @hidden
  33220. * Defines the actions happening for one camera in the frame.
  33221. */
  33222. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33223. /**
  33224. * @hidden
  33225. * Defines the actions happening during the per mesh ready checks.
  33226. */
  33227. _isReadyForMeshStage: Stage<MeshStageAction>;
  33228. /**
  33229. * @hidden
  33230. * Defines the actions happening before evaluate active mesh checks.
  33231. */
  33232. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33233. /**
  33234. * @hidden
  33235. * Defines the actions happening during the evaluate sub mesh checks.
  33236. */
  33237. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33238. /**
  33239. * @hidden
  33240. * Defines the actions happening during the active mesh stage.
  33241. */
  33242. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33243. /**
  33244. * @hidden
  33245. * Defines the actions happening during the per camera render target step.
  33246. */
  33247. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33248. /**
  33249. * @hidden
  33250. * Defines the actions happening just before the active camera is drawing.
  33251. */
  33252. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33253. /**
  33254. * @hidden
  33255. * Defines the actions happening just before a render target is drawing.
  33256. */
  33257. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33258. /**
  33259. * @hidden
  33260. * Defines the actions happening just before a rendering group is drawing.
  33261. */
  33262. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33263. /**
  33264. * @hidden
  33265. * Defines the actions happening just before a mesh is drawing.
  33266. */
  33267. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33268. /**
  33269. * @hidden
  33270. * Defines the actions happening just after a mesh has been drawn.
  33271. */
  33272. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33273. /**
  33274. * @hidden
  33275. * Defines the actions happening just after a rendering group has been drawn.
  33276. */
  33277. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33278. /**
  33279. * @hidden
  33280. * Defines the actions happening just after the active camera has been drawn.
  33281. */
  33282. _afterCameraDrawStage: Stage<CameraStageAction>;
  33283. /**
  33284. * @hidden
  33285. * Defines the actions happening just after a render target has been drawn.
  33286. */
  33287. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33288. /**
  33289. * @hidden
  33290. * Defines the actions happening just after rendering all cameras and computing intersections.
  33291. */
  33292. _afterRenderStage: Stage<SimpleStageAction>;
  33293. /**
  33294. * @hidden
  33295. * Defines the actions happening when a pointer move event happens.
  33296. */
  33297. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33298. /**
  33299. * @hidden
  33300. * Defines the actions happening when a pointer down event happens.
  33301. */
  33302. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33303. /**
  33304. * @hidden
  33305. * Defines the actions happening when a pointer up event happens.
  33306. */
  33307. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33308. /**
  33309. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33310. */
  33311. private geometriesByUniqueId;
  33312. /**
  33313. * Creates a new Scene
  33314. * @param engine defines the engine to use to render this scene
  33315. * @param options defines the scene options
  33316. */
  33317. constructor(engine: Engine, options?: SceneOptions);
  33318. /**
  33319. * Gets a string idenfifying the name of the class
  33320. * @returns "Scene" string
  33321. */
  33322. getClassName(): string;
  33323. private _defaultMeshCandidates;
  33324. /**
  33325. * @hidden
  33326. */
  33327. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33328. private _defaultSubMeshCandidates;
  33329. /**
  33330. * @hidden
  33331. */
  33332. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33333. /**
  33334. * Sets the default candidate providers for the scene.
  33335. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33336. * and getCollidingSubMeshCandidates to their default function
  33337. */
  33338. setDefaultCandidateProviders(): void;
  33339. /**
  33340. * Gets the mesh that is currently under the pointer
  33341. */
  33342. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33343. /**
  33344. * Gets or sets the current on-screen X position of the pointer
  33345. */
  33346. pointerX: number;
  33347. /**
  33348. * Gets or sets the current on-screen Y position of the pointer
  33349. */
  33350. pointerY: number;
  33351. /**
  33352. * Gets the cached material (ie. the latest rendered one)
  33353. * @returns the cached material
  33354. */
  33355. getCachedMaterial(): Nullable<Material>;
  33356. /**
  33357. * Gets the cached effect (ie. the latest rendered one)
  33358. * @returns the cached effect
  33359. */
  33360. getCachedEffect(): Nullable<Effect>;
  33361. /**
  33362. * Gets the cached visibility state (ie. the latest rendered one)
  33363. * @returns the cached visibility state
  33364. */
  33365. getCachedVisibility(): Nullable<number>;
  33366. /**
  33367. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33368. * @param material defines the current material
  33369. * @param effect defines the current effect
  33370. * @param visibility defines the current visibility state
  33371. * @returns true if one parameter is not cached
  33372. */
  33373. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33374. /**
  33375. * Gets the engine associated with the scene
  33376. * @returns an Engine
  33377. */
  33378. getEngine(): Engine;
  33379. /**
  33380. * Gets the total number of vertices rendered per frame
  33381. * @returns the total number of vertices rendered per frame
  33382. */
  33383. getTotalVertices(): number;
  33384. /**
  33385. * Gets the performance counter for total vertices
  33386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33387. */
  33388. readonly totalVerticesPerfCounter: PerfCounter;
  33389. /**
  33390. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33391. * @returns the total number of active indices rendered per frame
  33392. */
  33393. getActiveIndices(): number;
  33394. /**
  33395. * Gets the performance counter for active indices
  33396. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33397. */
  33398. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33399. /**
  33400. * Gets the total number of active particles rendered per frame
  33401. * @returns the total number of active particles rendered per frame
  33402. */
  33403. getActiveParticles(): number;
  33404. /**
  33405. * Gets the performance counter for active particles
  33406. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33407. */
  33408. readonly activeParticlesPerfCounter: PerfCounter;
  33409. /**
  33410. * Gets the total number of active bones rendered per frame
  33411. * @returns the total number of active bones rendered per frame
  33412. */
  33413. getActiveBones(): number;
  33414. /**
  33415. * Gets the performance counter for active bones
  33416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33417. */
  33418. readonly activeBonesPerfCounter: PerfCounter;
  33419. /**
  33420. * Gets the array of active meshes
  33421. * @returns an array of AbstractMesh
  33422. */
  33423. getActiveMeshes(): SmartArray<AbstractMesh>;
  33424. /**
  33425. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33426. * @returns a number
  33427. */
  33428. getAnimationRatio(): number;
  33429. /**
  33430. * Gets an unique Id for the current render phase
  33431. * @returns a number
  33432. */
  33433. getRenderId(): number;
  33434. /**
  33435. * Gets an unique Id for the current frame
  33436. * @returns a number
  33437. */
  33438. getFrameId(): number;
  33439. /** Call this function if you want to manually increment the render Id*/
  33440. incrementRenderId(): void;
  33441. private _updatePointerPosition;
  33442. private _createUbo;
  33443. private _setRayOnPointerInfo;
  33444. /**
  33445. * Use this method to simulate a pointer move on a mesh
  33446. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33447. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33448. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33449. * @returns the current scene
  33450. */
  33451. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33452. private _processPointerMove;
  33453. private _checkPrePointerObservable;
  33454. /**
  33455. * Use this method to simulate a pointer down on a mesh
  33456. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33457. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33458. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33459. * @returns the current scene
  33460. */
  33461. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33462. private _processPointerDown;
  33463. /**
  33464. * Use this method to simulate a pointer up on a mesh
  33465. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33466. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33467. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33468. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33469. * @returns the current scene
  33470. */
  33471. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33472. private _processPointerUp;
  33473. /**
  33474. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33475. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33476. * @returns true if the pointer was captured
  33477. */
  33478. isPointerCaptured(pointerId?: number): boolean;
  33479. /** @hidden */
  33480. _isPointerSwiping(): boolean;
  33481. /**
  33482. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33483. * @param attachUp defines if you want to attach events to pointerup
  33484. * @param attachDown defines if you want to attach events to pointerdown
  33485. * @param attachMove defines if you want to attach events to pointermove
  33486. */
  33487. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33488. /** Detaches all event handlers*/
  33489. detachControl(): void;
  33490. /**
  33491. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33492. * Delay loaded resources are not taking in account
  33493. * @return true if all required resources are ready
  33494. */
  33495. isReady(): boolean;
  33496. /** Resets all cached information relative to material (including effect and visibility) */
  33497. resetCachedMaterial(): void;
  33498. /**
  33499. * Registers a function to be called before every frame render
  33500. * @param func defines the function to register
  33501. */
  33502. registerBeforeRender(func: () => void): void;
  33503. /**
  33504. * Unregisters a function called before every frame render
  33505. * @param func defines the function to unregister
  33506. */
  33507. unregisterBeforeRender(func: () => void): void;
  33508. /**
  33509. * Registers a function to be called after every frame render
  33510. * @param func defines the function to register
  33511. */
  33512. registerAfterRender(func: () => void): void;
  33513. /**
  33514. * Unregisters a function called after every frame render
  33515. * @param func defines the function to unregister
  33516. */
  33517. unregisterAfterRender(func: () => void): void;
  33518. private _executeOnceBeforeRender;
  33519. /**
  33520. * The provided function will run before render once and will be disposed afterwards.
  33521. * A timeout delay can be provided so that the function will be executed in N ms.
  33522. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33523. * @param func The function to be executed.
  33524. * @param timeout optional delay in ms
  33525. */
  33526. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33527. /** @hidden */
  33528. _addPendingData(data: any): void;
  33529. /** @hidden */
  33530. _removePendingData(data: any): void;
  33531. /**
  33532. * Returns the number of items waiting to be loaded
  33533. * @returns the number of items waiting to be loaded
  33534. */
  33535. getWaitingItemsCount(): number;
  33536. /**
  33537. * Returns a boolean indicating if the scene is still loading data
  33538. */
  33539. readonly isLoading: boolean;
  33540. /**
  33541. * Registers a function to be executed when the scene is ready
  33542. * @param {Function} func - the function to be executed
  33543. */
  33544. executeWhenReady(func: () => void): void;
  33545. /**
  33546. * Returns a promise that resolves when the scene is ready
  33547. * @returns A promise that resolves when the scene is ready
  33548. */
  33549. whenReadyAsync(): Promise<void>;
  33550. /** @hidden */
  33551. _checkIsReady(): void;
  33552. /**
  33553. * Gets all animatable attached to the scene
  33554. */
  33555. readonly animatables: Animatable[];
  33556. /**
  33557. * Resets the last animation time frame.
  33558. * Useful to override when animations start running when loading a scene for the first time.
  33559. */
  33560. resetLastAnimationTimeFrame(): void;
  33561. /**
  33562. * Gets the current view matrix
  33563. * @returns a Matrix
  33564. */
  33565. getViewMatrix(): Matrix;
  33566. /**
  33567. * Gets the current projection matrix
  33568. * @returns a Matrix
  33569. */
  33570. getProjectionMatrix(): Matrix;
  33571. /**
  33572. * Gets the current transform matrix
  33573. * @returns a Matrix made of View * Projection
  33574. */
  33575. getTransformMatrix(): Matrix;
  33576. /**
  33577. * Sets the current transform matrix
  33578. * @param viewL defines the View matrix to use
  33579. * @param projectionL defines the Projection matrix to use
  33580. * @param viewR defines the right View matrix to use (if provided)
  33581. * @param projectionR defines the right Projection matrix to use (if provided)
  33582. */
  33583. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33584. /**
  33585. * Gets the uniform buffer used to store scene data
  33586. * @returns a UniformBuffer
  33587. */
  33588. getSceneUniformBuffer(): UniformBuffer;
  33589. /**
  33590. * Gets an unique (relatively to the current scene) Id
  33591. * @returns an unique number for the scene
  33592. */
  33593. getUniqueId(): number;
  33594. /**
  33595. * Add a mesh to the list of scene's meshes
  33596. * @param newMesh defines the mesh to add
  33597. * @param recursive if all child meshes should also be added to the scene
  33598. */
  33599. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33600. /**
  33601. * Remove a mesh for the list of scene's meshes
  33602. * @param toRemove defines the mesh to remove
  33603. * @param recursive if all child meshes should also be removed from the scene
  33604. * @returns the index where the mesh was in the mesh list
  33605. */
  33606. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33607. /**
  33608. * Add a transform node to the list of scene's transform nodes
  33609. * @param newTransformNode defines the transform node to add
  33610. */
  33611. addTransformNode(newTransformNode: TransformNode): void;
  33612. /**
  33613. * Remove a transform node for the list of scene's transform nodes
  33614. * @param toRemove defines the transform node to remove
  33615. * @returns the index where the transform node was in the transform node list
  33616. */
  33617. removeTransformNode(toRemove: TransformNode): number;
  33618. /**
  33619. * Remove a skeleton for the list of scene's skeletons
  33620. * @param toRemove defines the skeleton to remove
  33621. * @returns the index where the skeleton was in the skeleton list
  33622. */
  33623. removeSkeleton(toRemove: Skeleton): number;
  33624. /**
  33625. * Remove a morph target for the list of scene's morph targets
  33626. * @param toRemove defines the morph target to remove
  33627. * @returns the index where the morph target was in the morph target list
  33628. */
  33629. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33630. /**
  33631. * Remove a light for the list of scene's lights
  33632. * @param toRemove defines the light to remove
  33633. * @returns the index where the light was in the light list
  33634. */
  33635. removeLight(toRemove: Light): number;
  33636. /**
  33637. * Remove a camera for the list of scene's cameras
  33638. * @param toRemove defines the camera to remove
  33639. * @returns the index where the camera was in the camera list
  33640. */
  33641. removeCamera(toRemove: Camera): number;
  33642. /**
  33643. * Remove a particle system for the list of scene's particle systems
  33644. * @param toRemove defines the particle system to remove
  33645. * @returns the index where the particle system was in the particle system list
  33646. */
  33647. removeParticleSystem(toRemove: IParticleSystem): number;
  33648. /**
  33649. * Remove a animation for the list of scene's animations
  33650. * @param toRemove defines the animation to remove
  33651. * @returns the index where the animation was in the animation list
  33652. */
  33653. removeAnimation(toRemove: Animation): number;
  33654. /**
  33655. * Removes the given animation group from this scene.
  33656. * @param toRemove The animation group to remove
  33657. * @returns The index of the removed animation group
  33658. */
  33659. removeAnimationGroup(toRemove: AnimationGroup): number;
  33660. /**
  33661. * Removes the given multi-material from this scene.
  33662. * @param toRemove The multi-material to remove
  33663. * @returns The index of the removed multi-material
  33664. */
  33665. removeMultiMaterial(toRemove: MultiMaterial): number;
  33666. /**
  33667. * Removes the given material from this scene.
  33668. * @param toRemove The material to remove
  33669. * @returns The index of the removed material
  33670. */
  33671. removeMaterial(toRemove: Material): number;
  33672. /**
  33673. * Removes the given action manager from this scene.
  33674. * @param toRemove The action manager to remove
  33675. * @returns The index of the removed action manager
  33676. */
  33677. removeActionManager(toRemove: AbstractActionManager): number;
  33678. /**
  33679. * Removes the given texture from this scene.
  33680. * @param toRemove The texture to remove
  33681. * @returns The index of the removed texture
  33682. */
  33683. removeTexture(toRemove: BaseTexture): number;
  33684. /**
  33685. * Adds the given light to this scene
  33686. * @param newLight The light to add
  33687. */
  33688. addLight(newLight: Light): void;
  33689. /**
  33690. * Sorts the list list based on light priorities
  33691. */
  33692. sortLightsByPriority(): void;
  33693. /**
  33694. * Adds the given camera to this scene
  33695. * @param newCamera The camera to add
  33696. */
  33697. addCamera(newCamera: Camera): void;
  33698. /**
  33699. * Adds the given skeleton to this scene
  33700. * @param newSkeleton The skeleton to add
  33701. */
  33702. addSkeleton(newSkeleton: Skeleton): void;
  33703. /**
  33704. * Adds the given particle system to this scene
  33705. * @param newParticleSystem The particle system to add
  33706. */
  33707. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33708. /**
  33709. * Adds the given animation to this scene
  33710. * @param newAnimation The animation to add
  33711. */
  33712. addAnimation(newAnimation: Animation): void;
  33713. /**
  33714. * Adds the given animation group to this scene.
  33715. * @param newAnimationGroup The animation group to add
  33716. */
  33717. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33718. /**
  33719. * Adds the given multi-material to this scene
  33720. * @param newMultiMaterial The multi-material to add
  33721. */
  33722. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33723. /**
  33724. * Adds the given material to this scene
  33725. * @param newMaterial The material to add
  33726. */
  33727. addMaterial(newMaterial: Material): void;
  33728. /**
  33729. * Adds the given morph target to this scene
  33730. * @param newMorphTargetManager The morph target to add
  33731. */
  33732. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33733. /**
  33734. * Adds the given geometry to this scene
  33735. * @param newGeometry The geometry to add
  33736. */
  33737. addGeometry(newGeometry: Geometry): void;
  33738. /**
  33739. * Adds the given action manager to this scene
  33740. * @param newActionManager The action manager to add
  33741. */
  33742. addActionManager(newActionManager: AbstractActionManager): void;
  33743. /**
  33744. * Adds the given texture to this scene.
  33745. * @param newTexture The texture to add
  33746. */
  33747. addTexture(newTexture: BaseTexture): void;
  33748. /**
  33749. * Switch active camera
  33750. * @param newCamera defines the new active camera
  33751. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33752. */
  33753. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33754. /**
  33755. * sets the active camera of the scene using its ID
  33756. * @param id defines the camera's ID
  33757. * @return the new active camera or null if none found.
  33758. */
  33759. setActiveCameraByID(id: string): Nullable<Camera>;
  33760. /**
  33761. * sets the active camera of the scene using its name
  33762. * @param name defines the camera's name
  33763. * @returns the new active camera or null if none found.
  33764. */
  33765. setActiveCameraByName(name: string): Nullable<Camera>;
  33766. /**
  33767. * get an animation group using its name
  33768. * @param name defines the material's name
  33769. * @return the animation group or null if none found.
  33770. */
  33771. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33772. /**
  33773. * Get a material using its unique id
  33774. * @param uniqueId defines the material's unique id
  33775. * @return the material or null if none found.
  33776. */
  33777. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33778. /**
  33779. * get a material using its id
  33780. * @param id defines the material's ID
  33781. * @return the material or null if none found.
  33782. */
  33783. getMaterialByID(id: string): Nullable<Material>;
  33784. /**
  33785. * Gets a material using its name
  33786. * @param name defines the material's name
  33787. * @return the material or null if none found.
  33788. */
  33789. getMaterialByName(name: string): Nullable<Material>;
  33790. /**
  33791. * Gets a camera using its id
  33792. * @param id defines the id to look for
  33793. * @returns the camera or null if not found
  33794. */
  33795. getCameraByID(id: string): Nullable<Camera>;
  33796. /**
  33797. * Gets a camera using its unique id
  33798. * @param uniqueId defines the unique id to look for
  33799. * @returns the camera or null if not found
  33800. */
  33801. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33802. /**
  33803. * Gets a camera using its name
  33804. * @param name defines the camera's name
  33805. * @return the camera or null if none found.
  33806. */
  33807. getCameraByName(name: string): Nullable<Camera>;
  33808. /**
  33809. * Gets a bone using its id
  33810. * @param id defines the bone's id
  33811. * @return the bone or null if not found
  33812. */
  33813. getBoneByID(id: string): Nullable<Bone>;
  33814. /**
  33815. * Gets a bone using its id
  33816. * @param name defines the bone's name
  33817. * @return the bone or null if not found
  33818. */
  33819. getBoneByName(name: string): Nullable<Bone>;
  33820. /**
  33821. * Gets a light node using its name
  33822. * @param name defines the the light's name
  33823. * @return the light or null if none found.
  33824. */
  33825. getLightByName(name: string): Nullable<Light>;
  33826. /**
  33827. * Gets a light node using its id
  33828. * @param id defines the light's id
  33829. * @return the light or null if none found.
  33830. */
  33831. getLightByID(id: string): Nullable<Light>;
  33832. /**
  33833. * Gets a light node using its scene-generated unique ID
  33834. * @param uniqueId defines the light's unique id
  33835. * @return the light or null if none found.
  33836. */
  33837. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33838. /**
  33839. * Gets a particle system by id
  33840. * @param id defines the particle system id
  33841. * @return the corresponding system or null if none found
  33842. */
  33843. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33844. /**
  33845. * Gets a geometry using its ID
  33846. * @param id defines the geometry's id
  33847. * @return the geometry or null if none found.
  33848. */
  33849. getGeometryByID(id: string): Nullable<Geometry>;
  33850. private _getGeometryByUniqueID;
  33851. /**
  33852. * Add a new geometry to this scene
  33853. * @param geometry defines the geometry to be added to the scene.
  33854. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33855. * @return a boolean defining if the geometry was added or not
  33856. */
  33857. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33858. /**
  33859. * Removes an existing geometry
  33860. * @param geometry defines the geometry to be removed from the scene
  33861. * @return a boolean defining if the geometry was removed or not
  33862. */
  33863. removeGeometry(geometry: Geometry): boolean;
  33864. /**
  33865. * Gets the list of geometries attached to the scene
  33866. * @returns an array of Geometry
  33867. */
  33868. getGeometries(): Geometry[];
  33869. /**
  33870. * Gets the first added mesh found of a given ID
  33871. * @param id defines the id to search for
  33872. * @return the mesh found or null if not found at all
  33873. */
  33874. getMeshByID(id: string): Nullable<AbstractMesh>;
  33875. /**
  33876. * Gets a list of meshes using their id
  33877. * @param id defines the id to search for
  33878. * @returns a list of meshes
  33879. */
  33880. getMeshesByID(id: string): Array<AbstractMesh>;
  33881. /**
  33882. * Gets the first added transform node found of a given ID
  33883. * @param id defines the id to search for
  33884. * @return the found transform node or null if not found at all.
  33885. */
  33886. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33887. /**
  33888. * Gets a transform node with its auto-generated unique id
  33889. * @param uniqueId efines the unique id to search for
  33890. * @return the found transform node or null if not found at all.
  33891. */
  33892. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33893. /**
  33894. * Gets a list of transform nodes using their id
  33895. * @param id defines the id to search for
  33896. * @returns a list of transform nodes
  33897. */
  33898. getTransformNodesByID(id: string): Array<TransformNode>;
  33899. /**
  33900. * Gets a mesh with its auto-generated unique id
  33901. * @param uniqueId defines the unique id to search for
  33902. * @return the found mesh or null if not found at all.
  33903. */
  33904. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33905. /**
  33906. * Gets a the last added mesh using a given id
  33907. * @param id defines the id to search for
  33908. * @return the found mesh or null if not found at all.
  33909. */
  33910. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33911. /**
  33912. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33913. * @param id defines the id to search for
  33914. * @return the found node or null if not found at all
  33915. */
  33916. getLastEntryByID(id: string): Nullable<Node>;
  33917. /**
  33918. * Gets a node (Mesh, Camera, Light) using a given id
  33919. * @param id defines the id to search for
  33920. * @return the found node or null if not found at all
  33921. */
  33922. getNodeByID(id: string): Nullable<Node>;
  33923. /**
  33924. * Gets a node (Mesh, Camera, Light) using a given name
  33925. * @param name defines the name to search for
  33926. * @return the found node or null if not found at all.
  33927. */
  33928. getNodeByName(name: string): Nullable<Node>;
  33929. /**
  33930. * Gets a mesh using a given name
  33931. * @param name defines the name to search for
  33932. * @return the found mesh or null if not found at all.
  33933. */
  33934. getMeshByName(name: string): Nullable<AbstractMesh>;
  33935. /**
  33936. * Gets a transform node using a given name
  33937. * @param name defines the name to search for
  33938. * @return the found transform node or null if not found at all.
  33939. */
  33940. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33941. /**
  33942. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33943. * @param id defines the id to search for
  33944. * @return the found skeleton or null if not found at all.
  33945. */
  33946. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33947. /**
  33948. * Gets a skeleton using a given auto generated unique id
  33949. * @param uniqueId defines the unique id to search for
  33950. * @return the found skeleton or null if not found at all.
  33951. */
  33952. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33953. /**
  33954. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33955. * @param id defines the id to search for
  33956. * @return the found skeleton or null if not found at all.
  33957. */
  33958. getSkeletonById(id: string): Nullable<Skeleton>;
  33959. /**
  33960. * Gets a skeleton using a given name
  33961. * @param name defines the name to search for
  33962. * @return the found skeleton or null if not found at all.
  33963. */
  33964. getSkeletonByName(name: string): Nullable<Skeleton>;
  33965. /**
  33966. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33967. * @param id defines the id to search for
  33968. * @return the found morph target manager or null if not found at all.
  33969. */
  33970. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33971. /**
  33972. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33973. * @param id defines the id to search for
  33974. * @return the found morph target or null if not found at all.
  33975. */
  33976. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33977. /**
  33978. * Gets a boolean indicating if the given mesh is active
  33979. * @param mesh defines the mesh to look for
  33980. * @returns true if the mesh is in the active list
  33981. */
  33982. isActiveMesh(mesh: AbstractMesh): boolean;
  33983. /**
  33984. * Return a unique id as a string which can serve as an identifier for the scene
  33985. */
  33986. readonly uid: string;
  33987. /**
  33988. * Add an externaly attached data from its key.
  33989. * This method call will fail and return false, if such key already exists.
  33990. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33991. * @param key the unique key that identifies the data
  33992. * @param data the data object to associate to the key for this Engine instance
  33993. * @return true if no such key were already present and the data was added successfully, false otherwise
  33994. */
  33995. addExternalData<T>(key: string, data: T): boolean;
  33996. /**
  33997. * Get an externaly attached data from its key
  33998. * @param key the unique key that identifies the data
  33999. * @return the associated data, if present (can be null), or undefined if not present
  34000. */
  34001. getExternalData<T>(key: string): Nullable<T>;
  34002. /**
  34003. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34004. * @param key the unique key that identifies the data
  34005. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34006. * @return the associated data, can be null if the factory returned null.
  34007. */
  34008. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34009. /**
  34010. * Remove an externaly attached data from the Engine instance
  34011. * @param key the unique key that identifies the data
  34012. * @return true if the data was successfully removed, false if it doesn't exist
  34013. */
  34014. removeExternalData(key: string): boolean;
  34015. private _evaluateSubMesh;
  34016. /**
  34017. * Clear the processed materials smart array preventing retention point in material dispose.
  34018. */
  34019. freeProcessedMaterials(): void;
  34020. private _preventFreeActiveMeshesAndRenderingGroups;
  34021. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34022. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34023. * when disposing several meshes in a row or a hierarchy of meshes.
  34024. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34025. */
  34026. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34027. /**
  34028. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34029. */
  34030. freeActiveMeshes(): void;
  34031. /**
  34032. * Clear the info related to rendering groups preventing retention points during dispose.
  34033. */
  34034. freeRenderingGroups(): void;
  34035. /** @hidden */
  34036. _isInIntermediateRendering(): boolean;
  34037. /**
  34038. * Lambda returning the list of potentially active meshes.
  34039. */
  34040. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34041. /**
  34042. * Lambda returning the list of potentially active sub meshes.
  34043. */
  34044. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34045. /**
  34046. * Lambda returning the list of potentially intersecting sub meshes.
  34047. */
  34048. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34049. /**
  34050. * Lambda returning the list of potentially colliding sub meshes.
  34051. */
  34052. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34053. private _activeMeshesFrozen;
  34054. /**
  34055. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34056. * @returns the current scene
  34057. */
  34058. freezeActiveMeshes(): Scene;
  34059. /**
  34060. * Use this function to restart evaluating active meshes on every frame
  34061. * @returns the current scene
  34062. */
  34063. unfreezeActiveMeshes(): Scene;
  34064. private _evaluateActiveMeshes;
  34065. private _activeMesh;
  34066. /**
  34067. * Update the transform matrix to update from the current active camera
  34068. * @param force defines a boolean used to force the update even if cache is up to date
  34069. */
  34070. updateTransformMatrix(force?: boolean): void;
  34071. private _bindFrameBuffer;
  34072. /** @hidden */
  34073. _allowPostProcessClearColor: boolean;
  34074. /** @hidden */
  34075. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34076. private _processSubCameras;
  34077. private _checkIntersections;
  34078. /** @hidden */
  34079. _advancePhysicsEngineStep(step: number): void;
  34080. /**
  34081. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34082. */
  34083. getDeterministicFrameTime: () => number;
  34084. /** @hidden */
  34085. _animate(): void;
  34086. /** Execute all animations (for a frame) */
  34087. animate(): void;
  34088. /**
  34089. * Render the scene
  34090. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34091. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34092. */
  34093. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34094. /**
  34095. * Freeze all materials
  34096. * A frozen material will not be updatable but should be faster to render
  34097. */
  34098. freezeMaterials(): void;
  34099. /**
  34100. * Unfreeze all materials
  34101. * A frozen material will not be updatable but should be faster to render
  34102. */
  34103. unfreezeMaterials(): void;
  34104. /**
  34105. * Releases all held ressources
  34106. */
  34107. dispose(): void;
  34108. /**
  34109. * Gets if the scene is already disposed
  34110. */
  34111. readonly isDisposed: boolean;
  34112. /**
  34113. * Call this function to reduce memory footprint of the scene.
  34114. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34115. */
  34116. clearCachedVertexData(): void;
  34117. /**
  34118. * This function will remove the local cached buffer data from texture.
  34119. * It will save memory but will prevent the texture from being rebuilt
  34120. */
  34121. cleanCachedTextureBuffer(): void;
  34122. /**
  34123. * Get the world extend vectors with an optional filter
  34124. *
  34125. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34126. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34127. */
  34128. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34129. min: Vector3;
  34130. max: Vector3;
  34131. };
  34132. /**
  34133. * Creates a ray that can be used to pick in the scene
  34134. * @param x defines the x coordinate of the origin (on-screen)
  34135. * @param y defines the y coordinate of the origin (on-screen)
  34136. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34137. * @param camera defines the camera to use for the picking
  34138. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34139. * @returns a Ray
  34140. */
  34141. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34142. /**
  34143. * Creates a ray that can be used to pick in the scene
  34144. * @param x defines the x coordinate of the origin (on-screen)
  34145. * @param y defines the y coordinate of the origin (on-screen)
  34146. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34147. * @param result defines the ray where to store the picking ray
  34148. * @param camera defines the camera to use for the picking
  34149. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34150. * @returns the current scene
  34151. */
  34152. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34153. /**
  34154. * Creates a ray that can be used to pick in the scene
  34155. * @param x defines the x coordinate of the origin (on-screen)
  34156. * @param y defines the y coordinate of the origin (on-screen)
  34157. * @param camera defines the camera to use for the picking
  34158. * @returns a Ray
  34159. */
  34160. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34161. /**
  34162. * Creates a ray that can be used to pick in the scene
  34163. * @param x defines the x coordinate of the origin (on-screen)
  34164. * @param y defines the y coordinate of the origin (on-screen)
  34165. * @param result defines the ray where to store the picking ray
  34166. * @param camera defines the camera to use for the picking
  34167. * @returns the current scene
  34168. */
  34169. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34170. /** Launch a ray to try to pick a mesh in the scene
  34171. * @param x position on screen
  34172. * @param y position on screen
  34173. * @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
  34174. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34175. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34176. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34177. * @returns a PickingInfo
  34178. */
  34179. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34180. /** Use the given ray to pick a mesh in the scene
  34181. * @param ray The ray to use to pick meshes
  34182. * @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
  34183. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34184. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34185. * @returns a PickingInfo
  34186. */
  34187. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34188. /**
  34189. * Launch a ray to try to pick a mesh in the scene
  34190. * @param x X position on screen
  34191. * @param y Y position on screen
  34192. * @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
  34193. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34194. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34195. * @returns an array of PickingInfo
  34196. */
  34197. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34198. /**
  34199. * Launch a ray to try to pick a mesh in the scene
  34200. * @param ray Ray to use
  34201. * @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
  34202. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34203. * @returns an array of PickingInfo
  34204. */
  34205. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34206. /**
  34207. * Force the value of meshUnderPointer
  34208. * @param mesh defines the mesh to use
  34209. */
  34210. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34211. /**
  34212. * Gets the mesh under the pointer
  34213. * @returns a Mesh or null if no mesh is under the pointer
  34214. */
  34215. getPointerOverMesh(): Nullable<AbstractMesh>;
  34216. /** @hidden */
  34217. _rebuildGeometries(): void;
  34218. /** @hidden */
  34219. _rebuildTextures(): void;
  34220. private _getByTags;
  34221. /**
  34222. * Get a list of meshes by tags
  34223. * @param tagsQuery defines the tags query to use
  34224. * @param forEach defines a predicate used to filter results
  34225. * @returns an array of Mesh
  34226. */
  34227. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34228. /**
  34229. * Get a list of cameras by tags
  34230. * @param tagsQuery defines the tags query to use
  34231. * @param forEach defines a predicate used to filter results
  34232. * @returns an array of Camera
  34233. */
  34234. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34235. /**
  34236. * Get a list of lights by tags
  34237. * @param tagsQuery defines the tags query to use
  34238. * @param forEach defines a predicate used to filter results
  34239. * @returns an array of Light
  34240. */
  34241. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34242. /**
  34243. * Get a list of materials by tags
  34244. * @param tagsQuery defines the tags query to use
  34245. * @param forEach defines a predicate used to filter results
  34246. * @returns an array of Material
  34247. */
  34248. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34249. /**
  34250. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34251. * This allowed control for front to back rendering or reversly depending of the special needs.
  34252. *
  34253. * @param renderingGroupId The rendering group id corresponding to its index
  34254. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34255. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34256. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34257. */
  34258. 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;
  34259. /**
  34260. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34261. *
  34262. * @param renderingGroupId The rendering group id corresponding to its index
  34263. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34264. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34265. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34266. */
  34267. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34268. /**
  34269. * Gets the current auto clear configuration for one rendering group of the rendering
  34270. * manager.
  34271. * @param index the rendering group index to get the information for
  34272. * @returns The auto clear setup for the requested rendering group
  34273. */
  34274. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34275. private _blockMaterialDirtyMechanism;
  34276. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34277. blockMaterialDirtyMechanism: boolean;
  34278. /**
  34279. * Will flag all materials as dirty to trigger new shader compilation
  34280. * @param flag defines the flag used to specify which material part must be marked as dirty
  34281. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34282. */
  34283. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34284. /** @hidden */
  34285. _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;
  34286. /** @hidden */
  34287. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34288. }
  34289. }
  34290. declare module "babylonjs/assetContainer" {
  34291. import { AbstractScene } from "babylonjs/abstractScene";
  34292. import { Scene } from "babylonjs/scene";
  34293. import { Mesh } from "babylonjs/Meshes/mesh";
  34294. /**
  34295. * Set of assets to keep when moving a scene into an asset container.
  34296. */
  34297. export class KeepAssets extends AbstractScene {
  34298. }
  34299. /**
  34300. * Container with a set of assets that can be added or removed from a scene.
  34301. */
  34302. export class AssetContainer extends AbstractScene {
  34303. /**
  34304. * The scene the AssetContainer belongs to.
  34305. */
  34306. scene: Scene;
  34307. /**
  34308. * Instantiates an AssetContainer.
  34309. * @param scene The scene the AssetContainer belongs to.
  34310. */
  34311. constructor(scene: Scene);
  34312. /**
  34313. * Adds all the assets from the container to the scene.
  34314. */
  34315. addAllToScene(): void;
  34316. /**
  34317. * Removes all the assets in the container from the scene
  34318. */
  34319. removeAllFromScene(): void;
  34320. /**
  34321. * Disposes all the assets in the container
  34322. */
  34323. dispose(): void;
  34324. private _moveAssets;
  34325. /**
  34326. * Removes all the assets contained in the scene and adds them to the container.
  34327. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34328. */
  34329. moveAllFromScene(keepAssets?: KeepAssets): void;
  34330. /**
  34331. * 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.
  34332. * @returns the root mesh
  34333. */
  34334. createRootMesh(): Mesh;
  34335. }
  34336. }
  34337. declare module "babylonjs/abstractScene" {
  34338. import { Scene } from "babylonjs/scene";
  34339. import { Nullable } from "babylonjs/types";
  34340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34341. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34342. import { Geometry } from "babylonjs/Meshes/geometry";
  34343. import { Skeleton } from "babylonjs/Bones/skeleton";
  34344. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34345. import { AssetContainer } from "babylonjs/assetContainer";
  34346. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34347. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34348. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34349. import { Material } from "babylonjs/Materials/material";
  34350. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34351. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34352. import { Camera } from "babylonjs/Cameras/camera";
  34353. import { Light } from "babylonjs/Lights/light";
  34354. import { Node } from "babylonjs/node";
  34355. import { Animation } from "babylonjs/Animations/animation";
  34356. /**
  34357. * Defines how the parser contract is defined.
  34358. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34359. */
  34360. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34361. /**
  34362. * Defines how the individual parser contract is defined.
  34363. * These parser can parse an individual asset
  34364. */
  34365. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34366. /**
  34367. * Base class of the scene acting as a container for the different elements composing a scene.
  34368. * This class is dynamically extended by the different components of the scene increasing
  34369. * flexibility and reducing coupling
  34370. */
  34371. export abstract class AbstractScene {
  34372. /**
  34373. * Stores the list of available parsers in the application.
  34374. */
  34375. private static _BabylonFileParsers;
  34376. /**
  34377. * Stores the list of available individual parsers in the application.
  34378. */
  34379. private static _IndividualBabylonFileParsers;
  34380. /**
  34381. * Adds a parser in the list of available ones
  34382. * @param name Defines the name of the parser
  34383. * @param parser Defines the parser to add
  34384. */
  34385. static AddParser(name: string, parser: BabylonFileParser): void;
  34386. /**
  34387. * Gets a general parser from the list of avaialble ones
  34388. * @param name Defines the name of the parser
  34389. * @returns the requested parser or null
  34390. */
  34391. static GetParser(name: string): Nullable<BabylonFileParser>;
  34392. /**
  34393. * Adds n individual parser in the list of available ones
  34394. * @param name Defines the name of the parser
  34395. * @param parser Defines the parser to add
  34396. */
  34397. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34398. /**
  34399. * Gets an individual parser from the list of avaialble ones
  34400. * @param name Defines the name of the parser
  34401. * @returns the requested parser or null
  34402. */
  34403. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34404. /**
  34405. * Parser json data and populate both a scene and its associated container object
  34406. * @param jsonData Defines the data to parse
  34407. * @param scene Defines the scene to parse the data for
  34408. * @param container Defines the container attached to the parsing sequence
  34409. * @param rootUrl Defines the root url of the data
  34410. */
  34411. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34412. /**
  34413. * Gets the list of root nodes (ie. nodes with no parent)
  34414. */
  34415. rootNodes: Node[];
  34416. /** All of the cameras added to this scene
  34417. * @see http://doc.babylonjs.com/babylon101/cameras
  34418. */
  34419. cameras: Camera[];
  34420. /**
  34421. * All of the lights added to this scene
  34422. * @see http://doc.babylonjs.com/babylon101/lights
  34423. */
  34424. lights: Light[];
  34425. /**
  34426. * All of the (abstract) meshes added to this scene
  34427. */
  34428. meshes: AbstractMesh[];
  34429. /**
  34430. * The list of skeletons added to the scene
  34431. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34432. */
  34433. skeletons: Skeleton[];
  34434. /**
  34435. * All of the particle systems added to this scene
  34436. * @see http://doc.babylonjs.com/babylon101/particles
  34437. */
  34438. particleSystems: IParticleSystem[];
  34439. /**
  34440. * Gets a list of Animations associated with the scene
  34441. */
  34442. animations: Animation[];
  34443. /**
  34444. * All of the animation groups added to this scene
  34445. * @see http://doc.babylonjs.com/how_to/group
  34446. */
  34447. animationGroups: AnimationGroup[];
  34448. /**
  34449. * All of the multi-materials added to this scene
  34450. * @see http://doc.babylonjs.com/how_to/multi_materials
  34451. */
  34452. multiMaterials: MultiMaterial[];
  34453. /**
  34454. * All of the materials added to this scene
  34455. * In the context of a Scene, it is not supposed to be modified manually.
  34456. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34457. * Note also that the order of the Material wihin the array is not significant and might change.
  34458. * @see http://doc.babylonjs.com/babylon101/materials
  34459. */
  34460. materials: Material[];
  34461. /**
  34462. * The list of morph target managers added to the scene
  34463. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34464. */
  34465. morphTargetManagers: MorphTargetManager[];
  34466. /**
  34467. * The list of geometries used in the scene.
  34468. */
  34469. geometries: Geometry[];
  34470. /**
  34471. * All of the tranform nodes added to this scene
  34472. * In the context of a Scene, it is not supposed to be modified manually.
  34473. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34474. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34475. * @see http://doc.babylonjs.com/how_to/transformnode
  34476. */
  34477. transformNodes: TransformNode[];
  34478. /**
  34479. * ActionManagers available on the scene.
  34480. */
  34481. actionManagers: AbstractActionManager[];
  34482. /**
  34483. * Textures to keep.
  34484. */
  34485. textures: BaseTexture[];
  34486. /**
  34487. * Environment texture for the scene
  34488. */
  34489. environmentTexture: Nullable<BaseTexture>;
  34490. }
  34491. }
  34492. declare module "babylonjs/Audio/sound" {
  34493. import { Observable } from "babylonjs/Misc/observable";
  34494. import { Vector3 } from "babylonjs/Maths/math";
  34495. import { Nullable } from "babylonjs/types";
  34496. import { Scene } from "babylonjs/scene";
  34497. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34498. /**
  34499. * Defines a sound that can be played in the application.
  34500. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34502. */
  34503. export class Sound {
  34504. /**
  34505. * The name of the sound in the scene.
  34506. */
  34507. name: string;
  34508. /**
  34509. * Does the sound autoplay once loaded.
  34510. */
  34511. autoplay: boolean;
  34512. /**
  34513. * Does the sound loop after it finishes playing once.
  34514. */
  34515. loop: boolean;
  34516. /**
  34517. * Does the sound use a custom attenuation curve to simulate the falloff
  34518. * happening when the source gets further away from the camera.
  34519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34520. */
  34521. useCustomAttenuation: boolean;
  34522. /**
  34523. * The sound track id this sound belongs to.
  34524. */
  34525. soundTrackId: number;
  34526. /**
  34527. * Is this sound currently played.
  34528. */
  34529. isPlaying: boolean;
  34530. /**
  34531. * Is this sound currently paused.
  34532. */
  34533. isPaused: boolean;
  34534. /**
  34535. * Does this sound enables spatial sound.
  34536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34537. */
  34538. spatialSound: boolean;
  34539. /**
  34540. * Define the reference distance the sound should be heard perfectly.
  34541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34542. */
  34543. refDistance: number;
  34544. /**
  34545. * Define the roll off factor of spatial sounds.
  34546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34547. */
  34548. rolloffFactor: number;
  34549. /**
  34550. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34552. */
  34553. maxDistance: number;
  34554. /**
  34555. * Define the distance attenuation model the sound will follow.
  34556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34557. */
  34558. distanceModel: string;
  34559. /**
  34560. * @hidden
  34561. * Back Compat
  34562. **/
  34563. onended: () => any;
  34564. /**
  34565. * Observable event when the current playing sound finishes.
  34566. */
  34567. onEndedObservable: Observable<Sound>;
  34568. private _panningModel;
  34569. private _playbackRate;
  34570. private _streaming;
  34571. private _startTime;
  34572. private _startOffset;
  34573. private _position;
  34574. /** @hidden */
  34575. _positionInEmitterSpace: boolean;
  34576. private _localDirection;
  34577. private _volume;
  34578. private _isReadyToPlay;
  34579. private _isDirectional;
  34580. private _readyToPlayCallback;
  34581. private _audioBuffer;
  34582. private _soundSource;
  34583. private _streamingSource;
  34584. private _soundPanner;
  34585. private _soundGain;
  34586. private _inputAudioNode;
  34587. private _outputAudioNode;
  34588. private _coneInnerAngle;
  34589. private _coneOuterAngle;
  34590. private _coneOuterGain;
  34591. private _scene;
  34592. private _connectedTransformNode;
  34593. private _customAttenuationFunction;
  34594. private _registerFunc;
  34595. private _isOutputConnected;
  34596. private _htmlAudioElement;
  34597. private _urlType;
  34598. /** @hidden */
  34599. static _SceneComponentInitialization: (scene: Scene) => void;
  34600. /**
  34601. * Create a sound and attach it to a scene
  34602. * @param name Name of your sound
  34603. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34604. * @param scene defines the scene the sound belongs to
  34605. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34606. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34607. */
  34608. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34609. /**
  34610. * Release the sound and its associated resources
  34611. */
  34612. dispose(): void;
  34613. /**
  34614. * Gets if the sounds is ready to be played or not.
  34615. * @returns true if ready, otherwise false
  34616. */
  34617. isReady(): boolean;
  34618. private _soundLoaded;
  34619. /**
  34620. * Sets the data of the sound from an audiobuffer
  34621. * @param audioBuffer The audioBuffer containing the data
  34622. */
  34623. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34624. /**
  34625. * Updates the current sounds options such as maxdistance, loop...
  34626. * @param options A JSON object containing values named as the object properties
  34627. */
  34628. updateOptions(options: any): void;
  34629. private _createSpatialParameters;
  34630. private _updateSpatialParameters;
  34631. /**
  34632. * Switch the panning model to HRTF:
  34633. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34635. */
  34636. switchPanningModelToHRTF(): void;
  34637. /**
  34638. * Switch the panning model to Equal Power:
  34639. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34641. */
  34642. switchPanningModelToEqualPower(): void;
  34643. private _switchPanningModel;
  34644. /**
  34645. * Connect this sound to a sound track audio node like gain...
  34646. * @param soundTrackAudioNode the sound track audio node to connect to
  34647. */
  34648. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34649. /**
  34650. * Transform this sound into a directional source
  34651. * @param coneInnerAngle Size of the inner cone in degree
  34652. * @param coneOuterAngle Size of the outer cone in degree
  34653. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34654. */
  34655. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34656. /**
  34657. * Gets or sets the inner angle for the directional cone.
  34658. */
  34659. /**
  34660. * Gets or sets the inner angle for the directional cone.
  34661. */
  34662. directionalConeInnerAngle: number;
  34663. /**
  34664. * Gets or sets the outer angle for the directional cone.
  34665. */
  34666. /**
  34667. * Gets or sets the outer angle for the directional cone.
  34668. */
  34669. directionalConeOuterAngle: number;
  34670. /**
  34671. * Sets the position of the emitter if spatial sound is enabled
  34672. * @param newPosition Defines the new posisiton
  34673. */
  34674. setPosition(newPosition: Vector3): void;
  34675. /**
  34676. * Sets the local direction of the emitter if spatial sound is enabled
  34677. * @param newLocalDirection Defines the new local direction
  34678. */
  34679. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34680. private _updateDirection;
  34681. /** @hidden */
  34682. updateDistanceFromListener(): void;
  34683. /**
  34684. * Sets a new custom attenuation function for the sound.
  34685. * @param callback Defines the function used for the attenuation
  34686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34687. */
  34688. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34689. /**
  34690. * Play the sound
  34691. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34692. * @param offset (optional) Start the sound setting it at a specific time
  34693. */
  34694. play(time?: number, offset?: number): void;
  34695. private _onended;
  34696. /**
  34697. * Stop the sound
  34698. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34699. */
  34700. stop(time?: number): void;
  34701. /**
  34702. * Put the sound in pause
  34703. */
  34704. pause(): void;
  34705. /**
  34706. * Sets a dedicated volume for this sounds
  34707. * @param newVolume Define the new volume of the sound
  34708. * @param time Define in how long the sound should be at this value
  34709. */
  34710. setVolume(newVolume: number, time?: number): void;
  34711. /**
  34712. * Set the sound play back rate
  34713. * @param newPlaybackRate Define the playback rate the sound should be played at
  34714. */
  34715. setPlaybackRate(newPlaybackRate: number): void;
  34716. /**
  34717. * Gets the volume of the sound.
  34718. * @returns the volume of the sound
  34719. */
  34720. getVolume(): number;
  34721. /**
  34722. * Attach the sound to a dedicated mesh
  34723. * @param transformNode The transform node to connect the sound with
  34724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34725. */
  34726. attachToMesh(transformNode: TransformNode): void;
  34727. /**
  34728. * Detach the sound from the previously attached mesh
  34729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34730. */
  34731. detachFromMesh(): void;
  34732. private _onRegisterAfterWorldMatrixUpdate;
  34733. /**
  34734. * Clone the current sound in the scene.
  34735. * @returns the new sound clone
  34736. */
  34737. clone(): Nullable<Sound>;
  34738. /**
  34739. * Gets the current underlying audio buffer containing the data
  34740. * @returns the audio buffer
  34741. */
  34742. getAudioBuffer(): Nullable<AudioBuffer>;
  34743. /**
  34744. * Serializes the Sound in a JSON representation
  34745. * @returns the JSON representation of the sound
  34746. */
  34747. serialize(): any;
  34748. /**
  34749. * Parse a JSON representation of a sound to innstantiate in a given scene
  34750. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34751. * @param scene Define the scene the new parsed sound should be created in
  34752. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34753. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34754. * @returns the newly parsed sound
  34755. */
  34756. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34757. }
  34758. }
  34759. declare module "babylonjs/Actions/directAudioActions" {
  34760. import { Action } from "babylonjs/Actions/action";
  34761. import { Condition } from "babylonjs/Actions/condition";
  34762. import { Sound } from "babylonjs/Audio/sound";
  34763. /**
  34764. * This defines an action helpful to play a defined sound on a triggered action.
  34765. */
  34766. export class PlaySoundAction extends Action {
  34767. private _sound;
  34768. /**
  34769. * Instantiate the action
  34770. * @param triggerOptions defines the trigger options
  34771. * @param sound defines the sound to play
  34772. * @param condition defines the trigger related conditions
  34773. */
  34774. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34775. /** @hidden */
  34776. _prepare(): void;
  34777. /**
  34778. * Execute the action and play the sound.
  34779. */
  34780. execute(): void;
  34781. /**
  34782. * Serializes the actions and its related information.
  34783. * @param parent defines the object to serialize in
  34784. * @returns the serialized object
  34785. */
  34786. serialize(parent: any): any;
  34787. }
  34788. /**
  34789. * This defines an action helpful to stop a defined sound on a triggered action.
  34790. */
  34791. export class StopSoundAction extends Action {
  34792. private _sound;
  34793. /**
  34794. * Instantiate the action
  34795. * @param triggerOptions defines the trigger options
  34796. * @param sound defines the sound to stop
  34797. * @param condition defines the trigger related conditions
  34798. */
  34799. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34800. /** @hidden */
  34801. _prepare(): void;
  34802. /**
  34803. * Execute the action and stop the sound.
  34804. */
  34805. execute(): void;
  34806. /**
  34807. * Serializes the actions and its related information.
  34808. * @param parent defines the object to serialize in
  34809. * @returns the serialized object
  34810. */
  34811. serialize(parent: any): any;
  34812. }
  34813. }
  34814. declare module "babylonjs/Actions/interpolateValueAction" {
  34815. import { Action } from "babylonjs/Actions/action";
  34816. import { Condition } from "babylonjs/Actions/condition";
  34817. import { Observable } from "babylonjs/Misc/observable";
  34818. /**
  34819. * This defines an action responsible to change the value of a property
  34820. * by interpolating between its current value and the newly set one once triggered.
  34821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34822. */
  34823. export class InterpolateValueAction extends Action {
  34824. /**
  34825. * Defines the path of the property where the value should be interpolated
  34826. */
  34827. propertyPath: string;
  34828. /**
  34829. * Defines the target value at the end of the interpolation.
  34830. */
  34831. value: any;
  34832. /**
  34833. * Defines the time it will take for the property to interpolate to the value.
  34834. */
  34835. duration: number;
  34836. /**
  34837. * Defines if the other scene animations should be stopped when the action has been triggered
  34838. */
  34839. stopOtherAnimations?: boolean;
  34840. /**
  34841. * Defines a callback raised once the interpolation animation has been done.
  34842. */
  34843. onInterpolationDone?: () => void;
  34844. /**
  34845. * Observable triggered once the interpolation animation has been done.
  34846. */
  34847. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34848. private _target;
  34849. private _effectiveTarget;
  34850. private _property;
  34851. /**
  34852. * Instantiate the action
  34853. * @param triggerOptions defines the trigger options
  34854. * @param target defines the object containing the value to interpolate
  34855. * @param propertyPath defines the path to the property in the target object
  34856. * @param value defines the target value at the end of the interpolation
  34857. * @param duration deines the time it will take for the property to interpolate to the value.
  34858. * @param condition defines the trigger related conditions
  34859. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34860. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34861. */
  34862. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34863. /** @hidden */
  34864. _prepare(): void;
  34865. /**
  34866. * Execute the action starts the value interpolation.
  34867. */
  34868. execute(): void;
  34869. /**
  34870. * Serializes the actions and its related information.
  34871. * @param parent defines the object to serialize in
  34872. * @returns the serialized object
  34873. */
  34874. serialize(parent: any): any;
  34875. }
  34876. }
  34877. declare module "babylonjs/Actions/index" {
  34878. export * from "babylonjs/Actions/action";
  34879. export * from "babylonjs/Actions/actionEvent";
  34880. export * from "babylonjs/Actions/actionManager";
  34881. export * from "babylonjs/Actions/condition";
  34882. export * from "babylonjs/Actions/directActions";
  34883. export * from "babylonjs/Actions/directAudioActions";
  34884. export * from "babylonjs/Actions/interpolateValueAction";
  34885. }
  34886. declare module "babylonjs/Animations/index" {
  34887. export * from "babylonjs/Animations/animatable";
  34888. export * from "babylonjs/Animations/animation";
  34889. export * from "babylonjs/Animations/animationGroup";
  34890. export * from "babylonjs/Animations/animationPropertiesOverride";
  34891. export * from "babylonjs/Animations/easing";
  34892. export * from "babylonjs/Animations/runtimeAnimation";
  34893. export * from "babylonjs/Animations/animationEvent";
  34894. export * from "babylonjs/Animations/animationGroup";
  34895. export * from "babylonjs/Animations/animationKey";
  34896. export * from "babylonjs/Animations/animationRange";
  34897. }
  34898. declare module "babylonjs/Audio/soundTrack" {
  34899. import { Sound } from "babylonjs/Audio/sound";
  34900. import { Analyser } from "babylonjs/Audio/analyser";
  34901. import { Scene } from "babylonjs/scene";
  34902. /**
  34903. * Options allowed during the creation of a sound track.
  34904. */
  34905. export interface ISoundTrackOptions {
  34906. /**
  34907. * The volume the sound track should take during creation
  34908. */
  34909. volume?: number;
  34910. /**
  34911. * Define if the sound track is the main sound track of the scene
  34912. */
  34913. mainTrack?: boolean;
  34914. }
  34915. /**
  34916. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34917. * It will be also used in a future release to apply effects on a specific track.
  34918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34919. */
  34920. export class SoundTrack {
  34921. /**
  34922. * The unique identifier of the sound track in the scene.
  34923. */
  34924. id: number;
  34925. /**
  34926. * The list of sounds included in the sound track.
  34927. */
  34928. soundCollection: Array<Sound>;
  34929. private _outputAudioNode;
  34930. private _scene;
  34931. private _isMainTrack;
  34932. private _connectedAnalyser;
  34933. private _options;
  34934. private _isInitialized;
  34935. /**
  34936. * Creates a new sound track.
  34937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34938. * @param scene Define the scene the sound track belongs to
  34939. * @param options
  34940. */
  34941. constructor(scene: Scene, options?: ISoundTrackOptions);
  34942. private _initializeSoundTrackAudioGraph;
  34943. /**
  34944. * Release the sound track and its associated resources
  34945. */
  34946. dispose(): void;
  34947. /**
  34948. * Adds a sound to this sound track
  34949. * @param sound define the cound to add
  34950. * @ignoreNaming
  34951. */
  34952. AddSound(sound: Sound): void;
  34953. /**
  34954. * Removes a sound to this sound track
  34955. * @param sound define the cound to remove
  34956. * @ignoreNaming
  34957. */
  34958. RemoveSound(sound: Sound): void;
  34959. /**
  34960. * Set a global volume for the full sound track.
  34961. * @param newVolume Define the new volume of the sound track
  34962. */
  34963. setVolume(newVolume: number): void;
  34964. /**
  34965. * Switch the panning model to HRTF:
  34966. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34968. */
  34969. switchPanningModelToHRTF(): void;
  34970. /**
  34971. * Switch the panning model to Equal Power:
  34972. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34974. */
  34975. switchPanningModelToEqualPower(): void;
  34976. /**
  34977. * Connect the sound track to an audio analyser allowing some amazing
  34978. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34980. * @param analyser The analyser to connect to the engine
  34981. */
  34982. connectToAnalyser(analyser: Analyser): void;
  34983. }
  34984. }
  34985. declare module "babylonjs/Audio/audioSceneComponent" {
  34986. import { Sound } from "babylonjs/Audio/sound";
  34987. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34988. import { Nullable } from "babylonjs/types";
  34989. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34990. import { Scene } from "babylonjs/scene";
  34991. import { AbstractScene } from "babylonjs/abstractScene";
  34992. module "babylonjs/abstractScene" {
  34993. interface AbstractScene {
  34994. /**
  34995. * The list of sounds used in the scene.
  34996. */
  34997. sounds: Nullable<Array<Sound>>;
  34998. }
  34999. }
  35000. module "babylonjs/scene" {
  35001. interface Scene {
  35002. /**
  35003. * @hidden
  35004. * Backing field
  35005. */
  35006. _mainSoundTrack: SoundTrack;
  35007. /**
  35008. * The main sound track played by the scene.
  35009. * It cotains your primary collection of sounds.
  35010. */
  35011. mainSoundTrack: SoundTrack;
  35012. /**
  35013. * The list of sound tracks added to the scene
  35014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35015. */
  35016. soundTracks: Nullable<Array<SoundTrack>>;
  35017. /**
  35018. * Gets a sound using a given name
  35019. * @param name defines the name to search for
  35020. * @return the found sound or null if not found at all.
  35021. */
  35022. getSoundByName(name: string): Nullable<Sound>;
  35023. /**
  35024. * Gets or sets if audio support is enabled
  35025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35026. */
  35027. audioEnabled: boolean;
  35028. /**
  35029. * Gets or sets if audio will be output to headphones
  35030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35031. */
  35032. headphone: boolean;
  35033. }
  35034. }
  35035. /**
  35036. * Defines the sound scene component responsible to manage any sounds
  35037. * in a given scene.
  35038. */
  35039. export class AudioSceneComponent implements ISceneSerializableComponent {
  35040. /**
  35041. * The component name helpfull to identify the component in the list of scene components.
  35042. */
  35043. readonly name: string;
  35044. /**
  35045. * The scene the component belongs to.
  35046. */
  35047. scene: Scene;
  35048. private _audioEnabled;
  35049. /**
  35050. * Gets whether audio is enabled or not.
  35051. * Please use related enable/disable method to switch state.
  35052. */
  35053. readonly audioEnabled: boolean;
  35054. private _headphone;
  35055. /**
  35056. * Gets whether audio is outputing to headphone or not.
  35057. * Please use the according Switch methods to change output.
  35058. */
  35059. readonly headphone: boolean;
  35060. /**
  35061. * Creates a new instance of the component for the given scene
  35062. * @param scene Defines the scene to register the component in
  35063. */
  35064. constructor(scene: Scene);
  35065. /**
  35066. * Registers the component in a given scene
  35067. */
  35068. register(): void;
  35069. /**
  35070. * Rebuilds the elements related to this component in case of
  35071. * context lost for instance.
  35072. */
  35073. rebuild(): void;
  35074. /**
  35075. * Serializes the component data to the specified json object
  35076. * @param serializationObject The object to serialize to
  35077. */
  35078. serialize(serializationObject: any): void;
  35079. /**
  35080. * Adds all the element from the container to the scene
  35081. * @param container the container holding the elements
  35082. */
  35083. addFromContainer(container: AbstractScene): void;
  35084. /**
  35085. * Removes all the elements in the container from the scene
  35086. * @param container contains the elements to remove
  35087. * @param dispose if the removed element should be disposed (default: false)
  35088. */
  35089. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35090. /**
  35091. * Disposes the component and the associated ressources.
  35092. */
  35093. dispose(): void;
  35094. /**
  35095. * Disables audio in the associated scene.
  35096. */
  35097. disableAudio(): void;
  35098. /**
  35099. * Enables audio in the associated scene.
  35100. */
  35101. enableAudio(): void;
  35102. /**
  35103. * Switch audio to headphone output.
  35104. */
  35105. switchAudioModeForHeadphones(): void;
  35106. /**
  35107. * Switch audio to normal speakers.
  35108. */
  35109. switchAudioModeForNormalSpeakers(): void;
  35110. private _afterRender;
  35111. }
  35112. }
  35113. declare module "babylonjs/Audio/weightedsound" {
  35114. import { Sound } from "babylonjs/Audio/sound";
  35115. /**
  35116. * Wraps one or more Sound objects and selects one with random weight for playback.
  35117. */
  35118. export class WeightedSound {
  35119. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35120. loop: boolean;
  35121. private _coneInnerAngle;
  35122. private _coneOuterAngle;
  35123. private _volume;
  35124. /** A Sound is currently playing. */
  35125. isPlaying: boolean;
  35126. /** A Sound is currently paused. */
  35127. isPaused: boolean;
  35128. private _sounds;
  35129. private _weights;
  35130. private _currentIndex?;
  35131. /**
  35132. * Creates a new WeightedSound from the list of sounds given.
  35133. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35134. * @param sounds Array of Sounds that will be selected from.
  35135. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35136. */
  35137. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35138. /**
  35139. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35140. */
  35141. /**
  35142. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35143. */
  35144. directionalConeInnerAngle: number;
  35145. /**
  35146. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35147. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35148. */
  35149. /**
  35150. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35151. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35152. */
  35153. directionalConeOuterAngle: number;
  35154. /**
  35155. * Playback volume.
  35156. */
  35157. /**
  35158. * Playback volume.
  35159. */
  35160. volume: number;
  35161. private _onended;
  35162. /**
  35163. * Suspend playback
  35164. */
  35165. pause(): void;
  35166. /**
  35167. * Stop playback
  35168. */
  35169. stop(): void;
  35170. /**
  35171. * Start playback.
  35172. * @param startOffset Position the clip head at a specific time in seconds.
  35173. */
  35174. play(startOffset?: number): void;
  35175. }
  35176. }
  35177. declare module "babylonjs/Audio/index" {
  35178. export * from "babylonjs/Audio/analyser";
  35179. export * from "babylonjs/Audio/audioEngine";
  35180. export * from "babylonjs/Audio/audioSceneComponent";
  35181. export * from "babylonjs/Audio/sound";
  35182. export * from "babylonjs/Audio/soundTrack";
  35183. export * from "babylonjs/Audio/weightedsound";
  35184. }
  35185. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35186. import { Behavior } from "babylonjs/Behaviors/behavior";
  35187. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35188. import { BackEase } from "babylonjs/Animations/easing";
  35189. /**
  35190. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35191. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35192. */
  35193. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35194. /**
  35195. * Gets the name of the behavior.
  35196. */
  35197. readonly name: string;
  35198. /**
  35199. * The easing function used by animations
  35200. */
  35201. static EasingFunction: BackEase;
  35202. /**
  35203. * The easing mode used by animations
  35204. */
  35205. static EasingMode: number;
  35206. /**
  35207. * The duration of the animation, in milliseconds
  35208. */
  35209. transitionDuration: number;
  35210. /**
  35211. * Length of the distance animated by the transition when lower radius is reached
  35212. */
  35213. lowerRadiusTransitionRange: number;
  35214. /**
  35215. * Length of the distance animated by the transition when upper radius is reached
  35216. */
  35217. upperRadiusTransitionRange: number;
  35218. private _autoTransitionRange;
  35219. /**
  35220. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35221. */
  35222. /**
  35223. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35224. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35225. */
  35226. autoTransitionRange: boolean;
  35227. private _attachedCamera;
  35228. private _onAfterCheckInputsObserver;
  35229. private _onMeshTargetChangedObserver;
  35230. /**
  35231. * Initializes the behavior.
  35232. */
  35233. init(): void;
  35234. /**
  35235. * Attaches the behavior to its arc rotate camera.
  35236. * @param camera Defines the camera to attach the behavior to
  35237. */
  35238. attach(camera: ArcRotateCamera): void;
  35239. /**
  35240. * Detaches the behavior from its current arc rotate camera.
  35241. */
  35242. detach(): void;
  35243. private _radiusIsAnimating;
  35244. private _radiusBounceTransition;
  35245. private _animatables;
  35246. private _cachedWheelPrecision;
  35247. /**
  35248. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35249. * @param radiusLimit The limit to check against.
  35250. * @return Bool to indicate if at limit.
  35251. */
  35252. private _isRadiusAtLimit;
  35253. /**
  35254. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35255. * @param radiusDelta The delta by which to animate to. Can be negative.
  35256. */
  35257. private _applyBoundRadiusAnimation;
  35258. /**
  35259. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35260. */
  35261. protected _clearAnimationLocks(): void;
  35262. /**
  35263. * Stops and removes all animations that have been applied to the camera
  35264. */
  35265. stopAllAnimations(): void;
  35266. }
  35267. }
  35268. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35269. import { Behavior } from "babylonjs/Behaviors/behavior";
  35270. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35271. import { ExponentialEase } from "babylonjs/Animations/easing";
  35272. import { Nullable } from "babylonjs/types";
  35273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35274. import { Vector3 } from "babylonjs/Maths/math";
  35275. /**
  35276. * 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.
  35277. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35278. */
  35279. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35280. /**
  35281. * Gets the name of the behavior.
  35282. */
  35283. readonly name: string;
  35284. private _mode;
  35285. private _radiusScale;
  35286. private _positionScale;
  35287. private _defaultElevation;
  35288. private _elevationReturnTime;
  35289. private _elevationReturnWaitTime;
  35290. private _zoomStopsAnimation;
  35291. private _framingTime;
  35292. /**
  35293. * The easing function used by animations
  35294. */
  35295. static EasingFunction: ExponentialEase;
  35296. /**
  35297. * The easing mode used by animations
  35298. */
  35299. static EasingMode: number;
  35300. /**
  35301. * Sets the current mode used by the behavior
  35302. */
  35303. /**
  35304. * Gets current mode used by the behavior.
  35305. */
  35306. mode: number;
  35307. /**
  35308. * Sets the scale applied to the radius (1 by default)
  35309. */
  35310. /**
  35311. * Gets the scale applied to the radius
  35312. */
  35313. radiusScale: number;
  35314. /**
  35315. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35316. */
  35317. /**
  35318. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35319. */
  35320. positionScale: number;
  35321. /**
  35322. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35323. * behaviour is triggered, in radians.
  35324. */
  35325. /**
  35326. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35327. * behaviour is triggered, in radians.
  35328. */
  35329. defaultElevation: number;
  35330. /**
  35331. * Sets the time (in milliseconds) taken to return to the default beta position.
  35332. * Negative value indicates camera should not return to default.
  35333. */
  35334. /**
  35335. * Gets the time (in milliseconds) taken to return to the default beta position.
  35336. * Negative value indicates camera should not return to default.
  35337. */
  35338. elevationReturnTime: number;
  35339. /**
  35340. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35341. */
  35342. /**
  35343. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35344. */
  35345. elevationReturnWaitTime: number;
  35346. /**
  35347. * Sets the flag that indicates if user zooming should stop animation.
  35348. */
  35349. /**
  35350. * Gets the flag that indicates if user zooming should stop animation.
  35351. */
  35352. zoomStopsAnimation: boolean;
  35353. /**
  35354. * Sets the transition time when framing the mesh, in milliseconds
  35355. */
  35356. /**
  35357. * Gets the transition time when framing the mesh, in milliseconds
  35358. */
  35359. framingTime: number;
  35360. /**
  35361. * Define if the behavior should automatically change the configured
  35362. * camera limits and sensibilities.
  35363. */
  35364. autoCorrectCameraLimitsAndSensibility: boolean;
  35365. private _onPrePointerObservableObserver;
  35366. private _onAfterCheckInputsObserver;
  35367. private _onMeshTargetChangedObserver;
  35368. private _attachedCamera;
  35369. private _isPointerDown;
  35370. private _lastInteractionTime;
  35371. /**
  35372. * Initializes the behavior.
  35373. */
  35374. init(): void;
  35375. /**
  35376. * Attaches the behavior to its arc rotate camera.
  35377. * @param camera Defines the camera to attach the behavior to
  35378. */
  35379. attach(camera: ArcRotateCamera): void;
  35380. /**
  35381. * Detaches the behavior from its current arc rotate camera.
  35382. */
  35383. detach(): void;
  35384. private _animatables;
  35385. private _betaIsAnimating;
  35386. private _betaTransition;
  35387. private _radiusTransition;
  35388. private _vectorTransition;
  35389. /**
  35390. * Targets the given mesh and updates zoom level accordingly.
  35391. * @param mesh The mesh to target.
  35392. * @param radius Optional. If a cached radius position already exists, overrides default.
  35393. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35394. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35395. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35396. */
  35397. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35398. /**
  35399. * Targets the given mesh with its children and updates zoom level accordingly.
  35400. * @param mesh The mesh to target.
  35401. * @param radius Optional. If a cached radius position already exists, overrides default.
  35402. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35403. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35404. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35405. */
  35406. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35407. /**
  35408. * Targets the given meshes with their children and updates zoom level accordingly.
  35409. * @param meshes The mesh to target.
  35410. * @param radius Optional. If a cached radius position already exists, overrides default.
  35411. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35412. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35413. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35414. */
  35415. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35416. /**
  35417. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35418. * @param minimumWorld Determines the smaller position of the bounding box extend
  35419. * @param maximumWorld Determines the bigger position of the bounding box extend
  35420. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35421. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35422. */
  35423. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35424. /**
  35425. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35426. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35427. * frustum width.
  35428. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35429. * to fully enclose the mesh in the viewing frustum.
  35430. */
  35431. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35432. /**
  35433. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35434. * is automatically returned to its default position (expected to be above ground plane).
  35435. */
  35436. private _maintainCameraAboveGround;
  35437. /**
  35438. * Returns the frustum slope based on the canvas ratio and camera FOV
  35439. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35440. */
  35441. private _getFrustumSlope;
  35442. /**
  35443. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35444. */
  35445. private _clearAnimationLocks;
  35446. /**
  35447. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35448. */
  35449. private _applyUserInteraction;
  35450. /**
  35451. * Stops and removes all animations that have been applied to the camera
  35452. */
  35453. stopAllAnimations(): void;
  35454. /**
  35455. * Gets a value indicating if the user is moving the camera
  35456. */
  35457. readonly isUserIsMoving: boolean;
  35458. /**
  35459. * The camera can move all the way towards the mesh.
  35460. */
  35461. static IgnoreBoundsSizeMode: number;
  35462. /**
  35463. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35464. */
  35465. static FitFrustumSidesMode: number;
  35466. }
  35467. }
  35468. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35469. import { Nullable } from "babylonjs/types";
  35470. import { Camera } from "babylonjs/Cameras/camera";
  35471. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35472. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35473. /**
  35474. * Base class for Camera Pointer Inputs.
  35475. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35476. * for example usage.
  35477. */
  35478. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35479. /**
  35480. * Defines the camera the input is attached to.
  35481. */
  35482. abstract camera: Camera;
  35483. /**
  35484. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35485. */
  35486. protected _altKey: boolean;
  35487. protected _ctrlKey: boolean;
  35488. protected _metaKey: boolean;
  35489. protected _shiftKey: boolean;
  35490. /**
  35491. * Which mouse buttons were pressed at time of last mouse event.
  35492. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35493. */
  35494. protected _buttonsPressed: number;
  35495. /**
  35496. * Defines the buttons associated with the input to handle camera move.
  35497. */
  35498. buttons: number[];
  35499. /**
  35500. * Attach the input controls to a specific dom element to get the input from.
  35501. * @param element Defines the element the controls should be listened from
  35502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35503. */
  35504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35505. /**
  35506. * Detach the current controls from the specified dom element.
  35507. * @param element Defines the element to stop listening the inputs from
  35508. */
  35509. detachControl(element: Nullable<HTMLElement>): void;
  35510. /**
  35511. * Gets the class name of the current input.
  35512. * @returns the class name
  35513. */
  35514. getClassName(): string;
  35515. /**
  35516. * Get the friendly name associated with the input class.
  35517. * @returns the input friendly name
  35518. */
  35519. getSimpleName(): string;
  35520. /**
  35521. * Called on pointer POINTERDOUBLETAP event.
  35522. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35523. */
  35524. protected onDoubleTap(type: string): void;
  35525. /**
  35526. * Called on pointer POINTERMOVE event if only a single touch is active.
  35527. * Override this method to provide functionality.
  35528. */
  35529. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35530. /**
  35531. * Called on pointer POINTERMOVE event if multiple touches are active.
  35532. * Override this method to provide functionality.
  35533. */
  35534. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35535. /**
  35536. * Called on JS contextmenu event.
  35537. * Override this method to provide functionality.
  35538. */
  35539. protected onContextMenu(evt: PointerEvent): void;
  35540. /**
  35541. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35542. * press.
  35543. * Override this method to provide functionality.
  35544. */
  35545. protected onButtonDown(evt: PointerEvent): void;
  35546. /**
  35547. * Called each time a new POINTERUP event occurs. Ie, for each button
  35548. * release.
  35549. * Override this method to provide functionality.
  35550. */
  35551. protected onButtonUp(evt: PointerEvent): void;
  35552. /**
  35553. * Called when window becomes inactive.
  35554. * Override this method to provide functionality.
  35555. */
  35556. protected onLostFocus(): void;
  35557. private _pointerInput;
  35558. private _observer;
  35559. private _onLostFocus;
  35560. private pointA;
  35561. private pointB;
  35562. }
  35563. }
  35564. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35565. import { Nullable } from "babylonjs/types";
  35566. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35567. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35568. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35569. /**
  35570. * Manage the pointers inputs to control an arc rotate camera.
  35571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35572. */
  35573. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35574. /**
  35575. * Defines the camera the input is attached to.
  35576. */
  35577. camera: ArcRotateCamera;
  35578. /**
  35579. * Gets the class name of the current input.
  35580. * @returns the class name
  35581. */
  35582. getClassName(): string;
  35583. /**
  35584. * Defines the buttons associated with the input to handle camera move.
  35585. */
  35586. buttons: number[];
  35587. /**
  35588. * Defines the pointer angular sensibility along the X axis or how fast is
  35589. * the camera rotating.
  35590. */
  35591. angularSensibilityX: number;
  35592. /**
  35593. * Defines the pointer angular sensibility along the Y axis or how fast is
  35594. * the camera rotating.
  35595. */
  35596. angularSensibilityY: number;
  35597. /**
  35598. * Defines the pointer pinch precision or how fast is the camera zooming.
  35599. */
  35600. pinchPrecision: number;
  35601. /**
  35602. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35603. * from 0.
  35604. * It defines the percentage of current camera.radius to use as delta when
  35605. * pinch zoom is used.
  35606. */
  35607. pinchDeltaPercentage: number;
  35608. /**
  35609. * Defines the pointer panning sensibility or how fast is the camera moving.
  35610. */
  35611. panningSensibility: number;
  35612. /**
  35613. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35614. */
  35615. multiTouchPanning: boolean;
  35616. /**
  35617. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35618. * zoom (pinch) through multitouch.
  35619. */
  35620. multiTouchPanAndZoom: boolean;
  35621. /**
  35622. * Revers pinch action direction.
  35623. */
  35624. pinchInwards: boolean;
  35625. private _isPanClick;
  35626. private _twoFingerActivityCount;
  35627. private _isPinching;
  35628. /**
  35629. * Called on pointer POINTERMOVE event if only a single touch is active.
  35630. */
  35631. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35632. /**
  35633. * Called on pointer POINTERDOUBLETAP event.
  35634. */
  35635. protected onDoubleTap(type: string): void;
  35636. /**
  35637. * Called on pointer POINTERMOVE event if multiple touches are active.
  35638. */
  35639. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35640. /**
  35641. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35642. * press.
  35643. */
  35644. protected onButtonDown(evt: PointerEvent): void;
  35645. /**
  35646. * Called each time a new POINTERUP event occurs. Ie, for each button
  35647. * release.
  35648. */
  35649. protected onButtonUp(evt: PointerEvent): void;
  35650. /**
  35651. * Called when window becomes inactive.
  35652. */
  35653. protected onLostFocus(): void;
  35654. }
  35655. }
  35656. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35657. import { Nullable } from "babylonjs/types";
  35658. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35659. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35660. /**
  35661. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35663. */
  35664. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35665. /**
  35666. * Defines the camera the input is attached to.
  35667. */
  35668. camera: ArcRotateCamera;
  35669. /**
  35670. * Defines the list of key codes associated with the up action (increase alpha)
  35671. */
  35672. keysUp: number[];
  35673. /**
  35674. * Defines the list of key codes associated with the down action (decrease alpha)
  35675. */
  35676. keysDown: number[];
  35677. /**
  35678. * Defines the list of key codes associated with the left action (increase beta)
  35679. */
  35680. keysLeft: number[];
  35681. /**
  35682. * Defines the list of key codes associated with the right action (decrease beta)
  35683. */
  35684. keysRight: number[];
  35685. /**
  35686. * Defines the list of key codes associated with the reset action.
  35687. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35688. */
  35689. keysReset: number[];
  35690. /**
  35691. * Defines the panning sensibility of the inputs.
  35692. * (How fast is the camera paning)
  35693. */
  35694. panningSensibility: number;
  35695. /**
  35696. * Defines the zooming sensibility of the inputs.
  35697. * (How fast is the camera zooming)
  35698. */
  35699. zoomingSensibility: number;
  35700. /**
  35701. * Defines wether maintaining the alt key down switch the movement mode from
  35702. * orientation to zoom.
  35703. */
  35704. useAltToZoom: boolean;
  35705. /**
  35706. * Rotation speed of the camera
  35707. */
  35708. angularSpeed: number;
  35709. private _keys;
  35710. private _ctrlPressed;
  35711. private _altPressed;
  35712. private _onCanvasBlurObserver;
  35713. private _onKeyboardObserver;
  35714. private _engine;
  35715. private _scene;
  35716. /**
  35717. * Attach the input controls to a specific dom element to get the input from.
  35718. * @param element Defines the element the controls should be listened from
  35719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35720. */
  35721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35722. /**
  35723. * Detach the current controls from the specified dom element.
  35724. * @param element Defines the element to stop listening the inputs from
  35725. */
  35726. detachControl(element: Nullable<HTMLElement>): void;
  35727. /**
  35728. * Update the current camera state depending on the inputs that have been used this frame.
  35729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35730. */
  35731. checkInputs(): void;
  35732. /**
  35733. * Gets the class name of the current intput.
  35734. * @returns the class name
  35735. */
  35736. getClassName(): string;
  35737. /**
  35738. * Get the friendly name associated with the input class.
  35739. * @returns the input friendly name
  35740. */
  35741. getSimpleName(): string;
  35742. }
  35743. }
  35744. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35745. import { Nullable } from "babylonjs/types";
  35746. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35747. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35748. /**
  35749. * Manage the mouse wheel inputs to control an arc rotate camera.
  35750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35751. */
  35752. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35753. /**
  35754. * Defines the camera the input is attached to.
  35755. */
  35756. camera: ArcRotateCamera;
  35757. /**
  35758. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35759. */
  35760. wheelPrecision: number;
  35761. /**
  35762. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35763. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35764. */
  35765. wheelDeltaPercentage: number;
  35766. private _wheel;
  35767. private _observer;
  35768. /**
  35769. * Attach the input controls to a specific dom element to get the input from.
  35770. * @param element Defines the element the controls should be listened from
  35771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35772. */
  35773. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35774. /**
  35775. * Detach the current controls from the specified dom element.
  35776. * @param element Defines the element to stop listening the inputs from
  35777. */
  35778. detachControl(element: Nullable<HTMLElement>): void;
  35779. /**
  35780. * Gets the class name of the current intput.
  35781. * @returns the class name
  35782. */
  35783. getClassName(): string;
  35784. /**
  35785. * Get the friendly name associated with the input class.
  35786. * @returns the input friendly name
  35787. */
  35788. getSimpleName(): string;
  35789. }
  35790. }
  35791. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35792. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35793. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35794. /**
  35795. * Default Inputs manager for the ArcRotateCamera.
  35796. * It groups all the default supported inputs for ease of use.
  35797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35798. */
  35799. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35800. /**
  35801. * Instantiates a new ArcRotateCameraInputsManager.
  35802. * @param camera Defines the camera the inputs belong to
  35803. */
  35804. constructor(camera: ArcRotateCamera);
  35805. /**
  35806. * Add mouse wheel input support to the input manager.
  35807. * @returns the current input manager
  35808. */
  35809. addMouseWheel(): ArcRotateCameraInputsManager;
  35810. /**
  35811. * Add pointers input support to the input manager.
  35812. * @returns the current input manager
  35813. */
  35814. addPointers(): ArcRotateCameraInputsManager;
  35815. /**
  35816. * Add keyboard input support to the input manager.
  35817. * @returns the current input manager
  35818. */
  35819. addKeyboard(): ArcRotateCameraInputsManager;
  35820. }
  35821. }
  35822. declare module "babylonjs/Cameras/arcRotateCamera" {
  35823. import { Observable } from "babylonjs/Misc/observable";
  35824. import { Nullable } from "babylonjs/types";
  35825. import { Scene } from "babylonjs/scene";
  35826. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35828. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35829. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35830. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35831. import { Camera } from "babylonjs/Cameras/camera";
  35832. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35833. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35834. import { Collider } from "babylonjs/Collisions/collider";
  35835. /**
  35836. * This represents an orbital type of camera.
  35837. *
  35838. * 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.
  35839. * 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.
  35840. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35841. */
  35842. export class ArcRotateCamera extends TargetCamera {
  35843. /**
  35844. * Defines the rotation angle of the camera along the longitudinal axis.
  35845. */
  35846. alpha: number;
  35847. /**
  35848. * Defines the rotation angle of the camera along the latitudinal axis.
  35849. */
  35850. beta: number;
  35851. /**
  35852. * Defines the radius of the camera from it s target point.
  35853. */
  35854. radius: number;
  35855. protected _target: Vector3;
  35856. protected _targetHost: Nullable<AbstractMesh>;
  35857. /**
  35858. * Defines the target point of the camera.
  35859. * The camera looks towards it form the radius distance.
  35860. */
  35861. target: Vector3;
  35862. /**
  35863. * Define the current local position of the camera in the scene
  35864. */
  35865. position: Vector3;
  35866. protected _upVector: Vector3;
  35867. protected _upToYMatrix: Matrix;
  35868. protected _YToUpMatrix: Matrix;
  35869. /**
  35870. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35871. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35872. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35873. */
  35874. upVector: Vector3;
  35875. /**
  35876. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35877. */
  35878. setMatUp(): void;
  35879. /**
  35880. * Current inertia value on the longitudinal axis.
  35881. * The bigger this number the longer it will take for the camera to stop.
  35882. */
  35883. inertialAlphaOffset: number;
  35884. /**
  35885. * Current inertia value on the latitudinal axis.
  35886. * The bigger this number the longer it will take for the camera to stop.
  35887. */
  35888. inertialBetaOffset: number;
  35889. /**
  35890. * Current inertia value on the radius axis.
  35891. * The bigger this number the longer it will take for the camera to stop.
  35892. */
  35893. inertialRadiusOffset: number;
  35894. /**
  35895. * Minimum allowed angle on the longitudinal axis.
  35896. * This can help limiting how the Camera is able to move in the scene.
  35897. */
  35898. lowerAlphaLimit: Nullable<number>;
  35899. /**
  35900. * Maximum allowed angle on the longitudinal axis.
  35901. * This can help limiting how the Camera is able to move in the scene.
  35902. */
  35903. upperAlphaLimit: Nullable<number>;
  35904. /**
  35905. * Minimum allowed angle on the latitudinal axis.
  35906. * This can help limiting how the Camera is able to move in the scene.
  35907. */
  35908. lowerBetaLimit: number;
  35909. /**
  35910. * Maximum allowed angle on the latitudinal axis.
  35911. * This can help limiting how the Camera is able to move in the scene.
  35912. */
  35913. upperBetaLimit: number;
  35914. /**
  35915. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35916. * This can help limiting how the Camera is able to move in the scene.
  35917. */
  35918. lowerRadiusLimit: Nullable<number>;
  35919. /**
  35920. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35921. * This can help limiting how the Camera is able to move in the scene.
  35922. */
  35923. upperRadiusLimit: Nullable<number>;
  35924. /**
  35925. * Defines the current inertia value used during panning of the camera along the X axis.
  35926. */
  35927. inertialPanningX: number;
  35928. /**
  35929. * Defines the current inertia value used during panning of the camera along the Y axis.
  35930. */
  35931. inertialPanningY: number;
  35932. /**
  35933. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35934. * Basically if your fingers moves away from more than this distance you will be considered
  35935. * in pinch mode.
  35936. */
  35937. pinchToPanMaxDistance: number;
  35938. /**
  35939. * Defines the maximum distance the camera can pan.
  35940. * This could help keeping the cammera always in your scene.
  35941. */
  35942. panningDistanceLimit: Nullable<number>;
  35943. /**
  35944. * Defines the target of the camera before paning.
  35945. */
  35946. panningOriginTarget: Vector3;
  35947. /**
  35948. * Defines the value of the inertia used during panning.
  35949. * 0 would mean stop inertia and one would mean no decelleration at all.
  35950. */
  35951. panningInertia: number;
  35952. /**
  35953. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35954. */
  35955. angularSensibilityX: number;
  35956. /**
  35957. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35958. */
  35959. angularSensibilityY: number;
  35960. /**
  35961. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35962. */
  35963. pinchPrecision: number;
  35964. /**
  35965. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35966. * It will be used instead of pinchDeltaPrecision if different from 0.
  35967. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35968. */
  35969. pinchDeltaPercentage: number;
  35970. /**
  35971. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35972. */
  35973. panningSensibility: number;
  35974. /**
  35975. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35976. */
  35977. keysUp: number[];
  35978. /**
  35979. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35980. */
  35981. keysDown: number[];
  35982. /**
  35983. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35984. */
  35985. keysLeft: number[];
  35986. /**
  35987. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35988. */
  35989. keysRight: number[];
  35990. /**
  35991. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35992. */
  35993. wheelPrecision: number;
  35994. /**
  35995. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35996. * It will be used instead of pinchDeltaPrecision if different from 0.
  35997. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35998. */
  35999. wheelDeltaPercentage: number;
  36000. /**
  36001. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36002. */
  36003. zoomOnFactor: number;
  36004. /**
  36005. * Defines a screen offset for the camera position.
  36006. */
  36007. targetScreenOffset: Vector2;
  36008. /**
  36009. * Allows the camera to be completely reversed.
  36010. * If false the camera can not arrive upside down.
  36011. */
  36012. allowUpsideDown: boolean;
  36013. /**
  36014. * Define if double tap/click is used to restore the previously saved state of the camera.
  36015. */
  36016. useInputToRestoreState: boolean;
  36017. /** @hidden */
  36018. _viewMatrix: Matrix;
  36019. /** @hidden */
  36020. _useCtrlForPanning: boolean;
  36021. /** @hidden */
  36022. _panningMouseButton: number;
  36023. /**
  36024. * Defines the input associated to the camera.
  36025. */
  36026. inputs: ArcRotateCameraInputsManager;
  36027. /** @hidden */
  36028. _reset: () => void;
  36029. /**
  36030. * Defines the allowed panning axis.
  36031. */
  36032. panningAxis: Vector3;
  36033. protected _localDirection: Vector3;
  36034. protected _transformedDirection: Vector3;
  36035. private _bouncingBehavior;
  36036. /**
  36037. * Gets the bouncing behavior of the camera if it has been enabled.
  36038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36039. */
  36040. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36041. /**
  36042. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36043. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36044. */
  36045. useBouncingBehavior: boolean;
  36046. private _framingBehavior;
  36047. /**
  36048. * Gets the framing behavior of the camera if it has been enabled.
  36049. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36050. */
  36051. readonly framingBehavior: Nullable<FramingBehavior>;
  36052. /**
  36053. * Defines if the framing behavior of the camera is enabled on the camera.
  36054. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36055. */
  36056. useFramingBehavior: boolean;
  36057. private _autoRotationBehavior;
  36058. /**
  36059. * Gets the auto rotation behavior of the camera if it has been enabled.
  36060. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36061. */
  36062. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36063. /**
  36064. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36065. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36066. */
  36067. useAutoRotationBehavior: boolean;
  36068. /**
  36069. * Observable triggered when the mesh target has been changed on the camera.
  36070. */
  36071. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36072. /**
  36073. * Event raised when the camera is colliding with a mesh.
  36074. */
  36075. onCollide: (collidedMesh: AbstractMesh) => void;
  36076. /**
  36077. * Defines whether the camera should check collision with the objects oh the scene.
  36078. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36079. */
  36080. checkCollisions: boolean;
  36081. /**
  36082. * Defines the collision radius of the camera.
  36083. * This simulates a sphere around the camera.
  36084. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36085. */
  36086. collisionRadius: Vector3;
  36087. protected _collider: Collider;
  36088. protected _previousPosition: Vector3;
  36089. protected _collisionVelocity: Vector3;
  36090. protected _newPosition: Vector3;
  36091. protected _previousAlpha: number;
  36092. protected _previousBeta: number;
  36093. protected _previousRadius: number;
  36094. protected _collisionTriggered: boolean;
  36095. protected _targetBoundingCenter: Nullable<Vector3>;
  36096. private _computationVector;
  36097. /**
  36098. * Instantiates a new ArcRotateCamera in a given scene
  36099. * @param name Defines the name of the camera
  36100. * @param alpha Defines the camera rotation along the logitudinal axis
  36101. * @param beta Defines the camera rotation along the latitudinal axis
  36102. * @param radius Defines the camera distance from its target
  36103. * @param target Defines the camera target
  36104. * @param scene Defines the scene the camera belongs to
  36105. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36106. */
  36107. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36108. /** @hidden */
  36109. _initCache(): void;
  36110. /** @hidden */
  36111. _updateCache(ignoreParentClass?: boolean): void;
  36112. protected _getTargetPosition(): Vector3;
  36113. private _storedAlpha;
  36114. private _storedBeta;
  36115. private _storedRadius;
  36116. private _storedTarget;
  36117. /**
  36118. * Stores the current state of the camera (alpha, beta, radius and target)
  36119. * @returns the camera itself
  36120. */
  36121. storeState(): Camera;
  36122. /**
  36123. * @hidden
  36124. * Restored camera state. You must call storeState() first
  36125. */
  36126. _restoreStateValues(): boolean;
  36127. /** @hidden */
  36128. _isSynchronizedViewMatrix(): boolean;
  36129. /**
  36130. * Attached controls to the current camera.
  36131. * @param element Defines the element the controls should be listened from
  36132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36133. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36134. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36135. */
  36136. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36137. /**
  36138. * Detach the current controls from the camera.
  36139. * The camera will stop reacting to inputs.
  36140. * @param element Defines the element to stop listening the inputs from
  36141. */
  36142. detachControl(element: HTMLElement): void;
  36143. /** @hidden */
  36144. _checkInputs(): void;
  36145. protected _checkLimits(): void;
  36146. /**
  36147. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36148. */
  36149. rebuildAnglesAndRadius(): void;
  36150. /**
  36151. * Use a position to define the current camera related information like aplha, beta and radius
  36152. * @param position Defines the position to set the camera at
  36153. */
  36154. setPosition(position: Vector3): void;
  36155. /**
  36156. * Defines the target the camera should look at.
  36157. * This will automatically adapt alpha beta and radius to fit within the new target.
  36158. * @param target Defines the new target as a Vector or a mesh
  36159. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36160. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36161. */
  36162. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36163. /** @hidden */
  36164. _getViewMatrix(): Matrix;
  36165. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36166. /**
  36167. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36168. * @param meshes Defines the mesh to zoom on
  36169. * @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)
  36170. */
  36171. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36172. /**
  36173. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36174. * The target will be changed but the radius
  36175. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36176. * @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)
  36177. */
  36178. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36179. min: Vector3;
  36180. max: Vector3;
  36181. distance: number;
  36182. }, doNotUpdateMaxZ?: boolean): void;
  36183. /**
  36184. * @override
  36185. * Override Camera.createRigCamera
  36186. */
  36187. createRigCamera(name: string, cameraIndex: number): Camera;
  36188. /**
  36189. * @hidden
  36190. * @override
  36191. * Override Camera._updateRigCameras
  36192. */
  36193. _updateRigCameras(): void;
  36194. /**
  36195. * Destroy the camera and release the current resources hold by it.
  36196. */
  36197. dispose(): void;
  36198. /**
  36199. * Gets the current object class name.
  36200. * @return the class name
  36201. */
  36202. getClassName(): string;
  36203. }
  36204. }
  36205. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36206. import { Behavior } from "babylonjs/Behaviors/behavior";
  36207. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36208. /**
  36209. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36210. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36211. */
  36212. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36213. /**
  36214. * Gets the name of the behavior.
  36215. */
  36216. readonly name: string;
  36217. private _zoomStopsAnimation;
  36218. private _idleRotationSpeed;
  36219. private _idleRotationWaitTime;
  36220. private _idleRotationSpinupTime;
  36221. /**
  36222. * Sets the flag that indicates if user zooming should stop animation.
  36223. */
  36224. /**
  36225. * Gets the flag that indicates if user zooming should stop animation.
  36226. */
  36227. zoomStopsAnimation: boolean;
  36228. /**
  36229. * Sets the default speed at which the camera rotates around the model.
  36230. */
  36231. /**
  36232. * Gets the default speed at which the camera rotates around the model.
  36233. */
  36234. idleRotationSpeed: number;
  36235. /**
  36236. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36237. */
  36238. /**
  36239. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36240. */
  36241. idleRotationWaitTime: number;
  36242. /**
  36243. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36244. */
  36245. /**
  36246. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36247. */
  36248. idleRotationSpinupTime: number;
  36249. /**
  36250. * Gets a value indicating if the camera is currently rotating because of this behavior
  36251. */
  36252. readonly rotationInProgress: boolean;
  36253. private _onPrePointerObservableObserver;
  36254. private _onAfterCheckInputsObserver;
  36255. private _attachedCamera;
  36256. private _isPointerDown;
  36257. private _lastFrameTime;
  36258. private _lastInteractionTime;
  36259. private _cameraRotationSpeed;
  36260. /**
  36261. * Initializes the behavior.
  36262. */
  36263. init(): void;
  36264. /**
  36265. * Attaches the behavior to its arc rotate camera.
  36266. * @param camera Defines the camera to attach the behavior to
  36267. */
  36268. attach(camera: ArcRotateCamera): void;
  36269. /**
  36270. * Detaches the behavior from its current arc rotate camera.
  36271. */
  36272. detach(): void;
  36273. /**
  36274. * Returns true if user is scrolling.
  36275. * @return true if user is scrolling.
  36276. */
  36277. private _userIsZooming;
  36278. private _lastFrameRadius;
  36279. private _shouldAnimationStopForInteraction;
  36280. /**
  36281. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36282. */
  36283. private _applyUserInteraction;
  36284. private _userIsMoving;
  36285. }
  36286. }
  36287. declare module "babylonjs/Behaviors/Cameras/index" {
  36288. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36289. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36290. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36291. }
  36292. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36293. import { Mesh } from "babylonjs/Meshes/mesh";
  36294. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36295. import { Behavior } from "babylonjs/Behaviors/behavior";
  36296. /**
  36297. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36298. */
  36299. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36300. private ui;
  36301. /**
  36302. * The name of the behavior
  36303. */
  36304. name: string;
  36305. /**
  36306. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36307. */
  36308. distanceAwayFromFace: number;
  36309. /**
  36310. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36311. */
  36312. distanceAwayFromBottomOfFace: number;
  36313. private _faceVectors;
  36314. private _target;
  36315. private _scene;
  36316. private _onRenderObserver;
  36317. private _tmpMatrix;
  36318. private _tmpVector;
  36319. /**
  36320. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36321. * @param ui The transform node that should be attched to the mesh
  36322. */
  36323. constructor(ui: TransformNode);
  36324. /**
  36325. * Initializes the behavior
  36326. */
  36327. init(): void;
  36328. private _closestFace;
  36329. private _zeroVector;
  36330. private _lookAtTmpMatrix;
  36331. private _lookAtToRef;
  36332. /**
  36333. * Attaches the AttachToBoxBehavior to the passed in mesh
  36334. * @param target The mesh that the specified node will be attached to
  36335. */
  36336. attach(target: Mesh): void;
  36337. /**
  36338. * Detaches the behavior from the mesh
  36339. */
  36340. detach(): void;
  36341. }
  36342. }
  36343. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36344. import { Behavior } from "babylonjs/Behaviors/behavior";
  36345. import { Mesh } from "babylonjs/Meshes/mesh";
  36346. /**
  36347. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36348. */
  36349. export class FadeInOutBehavior implements Behavior<Mesh> {
  36350. /**
  36351. * Time in milliseconds to delay before fading in (Default: 0)
  36352. */
  36353. delay: number;
  36354. /**
  36355. * Time in milliseconds for the mesh to fade in (Default: 300)
  36356. */
  36357. fadeInTime: number;
  36358. private _millisecondsPerFrame;
  36359. private _hovered;
  36360. private _hoverValue;
  36361. private _ownerNode;
  36362. /**
  36363. * Instatiates the FadeInOutBehavior
  36364. */
  36365. constructor();
  36366. /**
  36367. * The name of the behavior
  36368. */
  36369. readonly name: string;
  36370. /**
  36371. * Initializes the behavior
  36372. */
  36373. init(): void;
  36374. /**
  36375. * Attaches the fade behavior on the passed in mesh
  36376. * @param ownerNode The mesh that will be faded in/out once attached
  36377. */
  36378. attach(ownerNode: Mesh): void;
  36379. /**
  36380. * Detaches the behavior from the mesh
  36381. */
  36382. detach(): void;
  36383. /**
  36384. * Triggers the mesh to begin fading in or out
  36385. * @param value if the object should fade in or out (true to fade in)
  36386. */
  36387. fadeIn(value: boolean): void;
  36388. private _update;
  36389. private _setAllVisibility;
  36390. }
  36391. }
  36392. declare module "babylonjs/Misc/pivotTools" {
  36393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36394. /**
  36395. * Class containing a set of static utilities functions for managing Pivots
  36396. * @hidden
  36397. */
  36398. export class PivotTools {
  36399. private static _PivotCached;
  36400. private static _OldPivotPoint;
  36401. private static _PivotTranslation;
  36402. private static _PivotTmpVector;
  36403. /** @hidden */
  36404. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36405. /** @hidden */
  36406. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36407. }
  36408. }
  36409. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36410. import { Scene } from "babylonjs/scene";
  36411. import { Vector4, Plane } from "babylonjs/Maths/math";
  36412. import { Mesh } from "babylonjs/Meshes/mesh";
  36413. import { Nullable } from "babylonjs/types";
  36414. /**
  36415. * Class containing static functions to help procedurally build meshes
  36416. */
  36417. export class PlaneBuilder {
  36418. /**
  36419. * Creates a plane mesh
  36420. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36421. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36422. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36426. * @param name defines the name of the mesh
  36427. * @param options defines the options used to create the mesh
  36428. * @param scene defines the hosting scene
  36429. * @returns the plane mesh
  36430. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36431. */
  36432. static CreatePlane(name: string, options: {
  36433. size?: number;
  36434. width?: number;
  36435. height?: number;
  36436. sideOrientation?: number;
  36437. frontUVs?: Vector4;
  36438. backUVs?: Vector4;
  36439. updatable?: boolean;
  36440. sourcePlane?: Plane;
  36441. }, scene?: Nullable<Scene>): Mesh;
  36442. }
  36443. }
  36444. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36445. import { Behavior } from "babylonjs/Behaviors/behavior";
  36446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36447. import { Observable } from "babylonjs/Misc/observable";
  36448. import { Vector3 } from "babylonjs/Maths/math";
  36449. import { Ray } from "babylonjs/Culling/ray";
  36450. import "babylonjs/Meshes/Builders/planeBuilder";
  36451. /**
  36452. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36453. */
  36454. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36455. private static _AnyMouseID;
  36456. private _attachedNode;
  36457. private _dragPlane;
  36458. private _scene;
  36459. private _pointerObserver;
  36460. private _beforeRenderObserver;
  36461. private static _planeScene;
  36462. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36463. /**
  36464. * 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)
  36465. */
  36466. maxDragAngle: number;
  36467. /**
  36468. * @hidden
  36469. */
  36470. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36471. /**
  36472. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36473. */
  36474. currentDraggingPointerID: number;
  36475. /**
  36476. * The last position where the pointer hit the drag plane in world space
  36477. */
  36478. lastDragPosition: Vector3;
  36479. /**
  36480. * If the behavior is currently in a dragging state
  36481. */
  36482. dragging: boolean;
  36483. /**
  36484. * 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)
  36485. */
  36486. dragDeltaRatio: number;
  36487. /**
  36488. * If the drag plane orientation should be updated during the dragging (Default: true)
  36489. */
  36490. updateDragPlane: boolean;
  36491. private _debugMode;
  36492. private _moving;
  36493. /**
  36494. * Fires each time the attached mesh is dragged with the pointer
  36495. * * delta between last drag position and current drag position in world space
  36496. * * dragDistance along the drag axis
  36497. * * dragPlaneNormal normal of the current drag plane used during the drag
  36498. * * dragPlanePoint in world space where the drag intersects the drag plane
  36499. */
  36500. onDragObservable: Observable<{
  36501. delta: Vector3;
  36502. dragPlanePoint: Vector3;
  36503. dragPlaneNormal: Vector3;
  36504. dragDistance: number;
  36505. pointerId: number;
  36506. }>;
  36507. /**
  36508. * Fires each time a drag begins (eg. mouse down on mesh)
  36509. */
  36510. onDragStartObservable: Observable<{
  36511. dragPlanePoint: Vector3;
  36512. pointerId: number;
  36513. }>;
  36514. /**
  36515. * Fires each time a drag ends (eg. mouse release after drag)
  36516. */
  36517. onDragEndObservable: Observable<{
  36518. dragPlanePoint: Vector3;
  36519. pointerId: number;
  36520. }>;
  36521. /**
  36522. * If the attached mesh should be moved when dragged
  36523. */
  36524. moveAttached: boolean;
  36525. /**
  36526. * If the drag behavior will react to drag events (Default: true)
  36527. */
  36528. enabled: boolean;
  36529. /**
  36530. * If camera controls should be detached during the drag
  36531. */
  36532. detachCameraControls: boolean;
  36533. /**
  36534. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36535. */
  36536. useObjectOrienationForDragging: boolean;
  36537. private _options;
  36538. /**
  36539. * Creates a pointer drag behavior that can be attached to a mesh
  36540. * @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)
  36541. */
  36542. constructor(options?: {
  36543. dragAxis?: Vector3;
  36544. dragPlaneNormal?: Vector3;
  36545. });
  36546. /**
  36547. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36548. */
  36549. validateDrag: (targetPosition: Vector3) => boolean;
  36550. /**
  36551. * The name of the behavior
  36552. */
  36553. readonly name: string;
  36554. /**
  36555. * Initializes the behavior
  36556. */
  36557. init(): void;
  36558. private _tmpVector;
  36559. private _alternatePickedPoint;
  36560. private _worldDragAxis;
  36561. private _targetPosition;
  36562. private _attachedElement;
  36563. /**
  36564. * Attaches the drag behavior the passed in mesh
  36565. * @param ownerNode The mesh that will be dragged around once attached
  36566. */
  36567. attach(ownerNode: AbstractMesh): void;
  36568. /**
  36569. * Force relase the drag action by code.
  36570. */
  36571. releaseDrag(): void;
  36572. private _startDragRay;
  36573. private _lastPointerRay;
  36574. /**
  36575. * Simulates the start of a pointer drag event on the behavior
  36576. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36577. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36578. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36579. */
  36580. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36581. private _startDrag;
  36582. private _dragDelta;
  36583. private _moveDrag;
  36584. private _pickWithRayOnDragPlane;
  36585. private _pointA;
  36586. private _pointB;
  36587. private _pointC;
  36588. private _lineA;
  36589. private _lineB;
  36590. private _localAxis;
  36591. private _lookAt;
  36592. private _updateDragPlanePosition;
  36593. /**
  36594. * Detaches the behavior from the mesh
  36595. */
  36596. detach(): void;
  36597. }
  36598. }
  36599. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36600. import { Mesh } from "babylonjs/Meshes/mesh";
  36601. import { Behavior } from "babylonjs/Behaviors/behavior";
  36602. /**
  36603. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36604. */
  36605. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36606. private _dragBehaviorA;
  36607. private _dragBehaviorB;
  36608. private _startDistance;
  36609. private _initialScale;
  36610. private _targetScale;
  36611. private _ownerNode;
  36612. private _sceneRenderObserver;
  36613. /**
  36614. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36615. */
  36616. constructor();
  36617. /**
  36618. * The name of the behavior
  36619. */
  36620. readonly name: string;
  36621. /**
  36622. * Initializes the behavior
  36623. */
  36624. init(): void;
  36625. private _getCurrentDistance;
  36626. /**
  36627. * Attaches the scale behavior the passed in mesh
  36628. * @param ownerNode The mesh that will be scaled around once attached
  36629. */
  36630. attach(ownerNode: Mesh): void;
  36631. /**
  36632. * Detaches the behavior from the mesh
  36633. */
  36634. detach(): void;
  36635. }
  36636. }
  36637. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36638. import { Behavior } from "babylonjs/Behaviors/behavior";
  36639. import { Mesh } from "babylonjs/Meshes/mesh";
  36640. import { Observable } from "babylonjs/Misc/observable";
  36641. /**
  36642. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  36643. */
  36644. export class SixDofDragBehavior implements Behavior<Mesh> {
  36645. private static _virtualScene;
  36646. private _ownerNode;
  36647. private _sceneRenderObserver;
  36648. private _scene;
  36649. private _targetPosition;
  36650. private _virtualOriginMesh;
  36651. private _virtualDragMesh;
  36652. private _pointerObserver;
  36653. private _moving;
  36654. private _startingOrientation;
  36655. /**
  36656. * 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)
  36657. */
  36658. private zDragFactor;
  36659. /**
  36660. * If the object should rotate to face the drag origin
  36661. */
  36662. rotateDraggedObject: boolean;
  36663. /**
  36664. * If the behavior is currently in a dragging state
  36665. */
  36666. dragging: boolean;
  36667. /**
  36668. * 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)
  36669. */
  36670. dragDeltaRatio: number;
  36671. /**
  36672. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36673. */
  36674. currentDraggingPointerID: number;
  36675. /**
  36676. * If camera controls should be detached during the drag
  36677. */
  36678. detachCameraControls: boolean;
  36679. /**
  36680. * Fires each time a drag starts
  36681. */
  36682. onDragStartObservable: Observable<{}>;
  36683. /**
  36684. * Fires each time a drag ends (eg. mouse release after drag)
  36685. */
  36686. onDragEndObservable: Observable<{}>;
  36687. /**
  36688. * 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
  36689. */
  36690. constructor();
  36691. /**
  36692. * The name of the behavior
  36693. */
  36694. readonly name: string;
  36695. /**
  36696. * Initializes the behavior
  36697. */
  36698. init(): void;
  36699. /**
  36700. * Attaches the scale behavior the passed in mesh
  36701. * @param ownerNode The mesh that will be scaled around once attached
  36702. */
  36703. attach(ownerNode: Mesh): void;
  36704. /**
  36705. * Detaches the behavior from the mesh
  36706. */
  36707. detach(): void;
  36708. }
  36709. }
  36710. declare module "babylonjs/Behaviors/Meshes/index" {
  36711. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36712. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36713. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36714. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36715. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36716. }
  36717. declare module "babylonjs/Behaviors/index" {
  36718. export * from "babylonjs/Behaviors/behavior";
  36719. export * from "babylonjs/Behaviors/Cameras/index";
  36720. export * from "babylonjs/Behaviors/Meshes/index";
  36721. }
  36722. declare module "babylonjs/Bones/boneIKController" {
  36723. import { Bone } from "babylonjs/Bones/bone";
  36724. import { Vector3 } from "babylonjs/Maths/math";
  36725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36726. import { Nullable } from "babylonjs/types";
  36727. /**
  36728. * Class used to apply inverse kinematics to bones
  36729. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36730. */
  36731. export class BoneIKController {
  36732. private static _tmpVecs;
  36733. private static _tmpQuat;
  36734. private static _tmpMats;
  36735. /**
  36736. * Gets or sets the target mesh
  36737. */
  36738. targetMesh: AbstractMesh;
  36739. /** Gets or sets the mesh used as pole */
  36740. poleTargetMesh: AbstractMesh;
  36741. /**
  36742. * Gets or sets the bone used as pole
  36743. */
  36744. poleTargetBone: Nullable<Bone>;
  36745. /**
  36746. * Gets or sets the target position
  36747. */
  36748. targetPosition: Vector3;
  36749. /**
  36750. * Gets or sets the pole target position
  36751. */
  36752. poleTargetPosition: Vector3;
  36753. /**
  36754. * Gets or sets the pole target local offset
  36755. */
  36756. poleTargetLocalOffset: Vector3;
  36757. /**
  36758. * Gets or sets the pole angle
  36759. */
  36760. poleAngle: number;
  36761. /**
  36762. * Gets or sets the mesh associated with the controller
  36763. */
  36764. mesh: AbstractMesh;
  36765. /**
  36766. * 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)
  36767. */
  36768. slerpAmount: number;
  36769. private _bone1Quat;
  36770. private _bone1Mat;
  36771. private _bone2Ang;
  36772. private _bone1;
  36773. private _bone2;
  36774. private _bone1Length;
  36775. private _bone2Length;
  36776. private _maxAngle;
  36777. private _maxReach;
  36778. private _rightHandedSystem;
  36779. private _bendAxis;
  36780. private _slerping;
  36781. private _adjustRoll;
  36782. /**
  36783. * Gets or sets maximum allowed angle
  36784. */
  36785. maxAngle: number;
  36786. /**
  36787. * Creates a new BoneIKController
  36788. * @param mesh defines the mesh to control
  36789. * @param bone defines the bone to control
  36790. * @param options defines options to set up the controller
  36791. */
  36792. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36793. targetMesh?: AbstractMesh;
  36794. poleTargetMesh?: AbstractMesh;
  36795. poleTargetBone?: Bone;
  36796. poleTargetLocalOffset?: Vector3;
  36797. poleAngle?: number;
  36798. bendAxis?: Vector3;
  36799. maxAngle?: number;
  36800. slerpAmount?: number;
  36801. });
  36802. private _setMaxAngle;
  36803. /**
  36804. * Force the controller to update the bones
  36805. */
  36806. update(): void;
  36807. }
  36808. }
  36809. declare module "babylonjs/Bones/boneLookController" {
  36810. import { Vector3, Space } from "babylonjs/Maths/math";
  36811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36812. import { Bone } from "babylonjs/Bones/bone";
  36813. /**
  36814. * Class used to make a bone look toward a point in space
  36815. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36816. */
  36817. export class BoneLookController {
  36818. private static _tmpVecs;
  36819. private static _tmpQuat;
  36820. private static _tmpMats;
  36821. /**
  36822. * The target Vector3 that the bone will look at
  36823. */
  36824. target: Vector3;
  36825. /**
  36826. * The mesh that the bone is attached to
  36827. */
  36828. mesh: AbstractMesh;
  36829. /**
  36830. * The bone that will be looking to the target
  36831. */
  36832. bone: Bone;
  36833. /**
  36834. * The up axis of the coordinate system that is used when the bone is rotated
  36835. */
  36836. upAxis: Vector3;
  36837. /**
  36838. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36839. */
  36840. upAxisSpace: Space;
  36841. /**
  36842. * Used to make an adjustment to the yaw of the bone
  36843. */
  36844. adjustYaw: number;
  36845. /**
  36846. * Used to make an adjustment to the pitch of the bone
  36847. */
  36848. adjustPitch: number;
  36849. /**
  36850. * Used to make an adjustment to the roll of the bone
  36851. */
  36852. adjustRoll: number;
  36853. /**
  36854. * 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)
  36855. */
  36856. slerpAmount: number;
  36857. private _minYaw;
  36858. private _maxYaw;
  36859. private _minPitch;
  36860. private _maxPitch;
  36861. private _minYawSin;
  36862. private _minYawCos;
  36863. private _maxYawSin;
  36864. private _maxYawCos;
  36865. private _midYawConstraint;
  36866. private _minPitchTan;
  36867. private _maxPitchTan;
  36868. private _boneQuat;
  36869. private _slerping;
  36870. private _transformYawPitch;
  36871. private _transformYawPitchInv;
  36872. private _firstFrameSkipped;
  36873. private _yawRange;
  36874. private _fowardAxis;
  36875. /**
  36876. * Gets or sets the minimum yaw angle that the bone can look to
  36877. */
  36878. minYaw: number;
  36879. /**
  36880. * Gets or sets the maximum yaw angle that the bone can look to
  36881. */
  36882. maxYaw: number;
  36883. /**
  36884. * Gets or sets the minimum pitch angle that the bone can look to
  36885. */
  36886. minPitch: number;
  36887. /**
  36888. * Gets or sets the maximum pitch angle that the bone can look to
  36889. */
  36890. maxPitch: number;
  36891. /**
  36892. * Create a BoneLookController
  36893. * @param mesh the mesh that the bone belongs to
  36894. * @param bone the bone that will be looking to the target
  36895. * @param target the target Vector3 to look at
  36896. * @param options optional settings:
  36897. * * maxYaw: the maximum angle the bone will yaw to
  36898. * * minYaw: the minimum angle the bone will yaw to
  36899. * * maxPitch: the maximum angle the bone will pitch to
  36900. * * minPitch: the minimum angle the bone will yaw to
  36901. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36902. * * upAxis: the up axis of the coordinate system
  36903. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36904. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36905. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36906. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36907. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36908. * * adjustRoll: used to make an adjustment to the roll of the bone
  36909. **/
  36910. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36911. maxYaw?: number;
  36912. minYaw?: number;
  36913. maxPitch?: number;
  36914. minPitch?: number;
  36915. slerpAmount?: number;
  36916. upAxis?: Vector3;
  36917. upAxisSpace?: Space;
  36918. yawAxis?: Vector3;
  36919. pitchAxis?: Vector3;
  36920. adjustYaw?: number;
  36921. adjustPitch?: number;
  36922. adjustRoll?: number;
  36923. });
  36924. /**
  36925. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36926. */
  36927. update(): void;
  36928. private _getAngleDiff;
  36929. private _getAngleBetween;
  36930. private _isAngleBetween;
  36931. }
  36932. }
  36933. declare module "babylonjs/Bones/index" {
  36934. export * from "babylonjs/Bones/bone";
  36935. export * from "babylonjs/Bones/boneIKController";
  36936. export * from "babylonjs/Bones/boneLookController";
  36937. export * from "babylonjs/Bones/skeleton";
  36938. }
  36939. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36940. import { Nullable } from "babylonjs/types";
  36941. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36942. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36943. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36944. /**
  36945. * Manage the gamepad inputs to control an arc rotate camera.
  36946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36947. */
  36948. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36949. /**
  36950. * Defines the camera the input is attached to.
  36951. */
  36952. camera: ArcRotateCamera;
  36953. /**
  36954. * Defines the gamepad the input is gathering event from.
  36955. */
  36956. gamepad: Nullable<Gamepad>;
  36957. /**
  36958. * Defines the gamepad rotation sensiblity.
  36959. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36960. */
  36961. gamepadRotationSensibility: number;
  36962. /**
  36963. * Defines the gamepad move sensiblity.
  36964. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36965. */
  36966. gamepadMoveSensibility: number;
  36967. private _onGamepadConnectedObserver;
  36968. private _onGamepadDisconnectedObserver;
  36969. /**
  36970. * Attach the input controls to a specific dom element to get the input from.
  36971. * @param element Defines the element the controls should be listened from
  36972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36973. */
  36974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36975. /**
  36976. * Detach the current controls from the specified dom element.
  36977. * @param element Defines the element to stop listening the inputs from
  36978. */
  36979. detachControl(element: Nullable<HTMLElement>): void;
  36980. /**
  36981. * Update the current camera state depending on the inputs that have been used this frame.
  36982. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36983. */
  36984. checkInputs(): void;
  36985. /**
  36986. * Gets the class name of the current intput.
  36987. * @returns the class name
  36988. */
  36989. getClassName(): string;
  36990. /**
  36991. * Get the friendly name associated with the input class.
  36992. * @returns the input friendly name
  36993. */
  36994. getSimpleName(): string;
  36995. }
  36996. }
  36997. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36998. import { Nullable } from "babylonjs/types";
  36999. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37000. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37001. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37002. interface ArcRotateCameraInputsManager {
  37003. /**
  37004. * Add orientation input support to the input manager.
  37005. * @returns the current input manager
  37006. */
  37007. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37008. }
  37009. }
  37010. /**
  37011. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37013. */
  37014. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37015. /**
  37016. * Defines the camera the input is attached to.
  37017. */
  37018. camera: ArcRotateCamera;
  37019. /**
  37020. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37021. */
  37022. alphaCorrection: number;
  37023. /**
  37024. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37025. */
  37026. gammaCorrection: number;
  37027. private _alpha;
  37028. private _gamma;
  37029. private _dirty;
  37030. private _deviceOrientationHandler;
  37031. /**
  37032. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37033. */
  37034. constructor();
  37035. /**
  37036. * Attach the input controls to a specific dom element to get the input from.
  37037. * @param element Defines the element the controls should be listened from
  37038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37039. */
  37040. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37041. /** @hidden */
  37042. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37043. /**
  37044. * Update the current camera state depending on the inputs that have been used this frame.
  37045. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37046. */
  37047. checkInputs(): void;
  37048. /**
  37049. * Detach the current controls from the specified dom element.
  37050. * @param element Defines the element to stop listening the inputs from
  37051. */
  37052. detachControl(element: Nullable<HTMLElement>): void;
  37053. /**
  37054. * Gets the class name of the current intput.
  37055. * @returns the class name
  37056. */
  37057. getClassName(): string;
  37058. /**
  37059. * Get the friendly name associated with the input class.
  37060. * @returns the input friendly name
  37061. */
  37062. getSimpleName(): string;
  37063. }
  37064. }
  37065. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37066. import { Nullable } from "babylonjs/types";
  37067. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37068. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37069. /**
  37070. * Listen to mouse events to control the camera.
  37071. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37072. */
  37073. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37074. /**
  37075. * Defines the camera the input is attached to.
  37076. */
  37077. camera: FlyCamera;
  37078. /**
  37079. * Defines if touch is enabled. (Default is true.)
  37080. */
  37081. touchEnabled: boolean;
  37082. /**
  37083. * Defines the buttons associated with the input to handle camera rotation.
  37084. */
  37085. buttons: number[];
  37086. /**
  37087. * Assign buttons for Yaw control.
  37088. */
  37089. buttonsYaw: number[];
  37090. /**
  37091. * Assign buttons for Pitch control.
  37092. */
  37093. buttonsPitch: number[];
  37094. /**
  37095. * Assign buttons for Roll control.
  37096. */
  37097. buttonsRoll: number[];
  37098. /**
  37099. * Detect if any button is being pressed while mouse is moved.
  37100. * -1 = Mouse locked.
  37101. * 0 = Left button.
  37102. * 1 = Middle Button.
  37103. * 2 = Right Button.
  37104. */
  37105. activeButton: number;
  37106. /**
  37107. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37108. * Higher values reduce its sensitivity.
  37109. */
  37110. angularSensibility: number;
  37111. private _mousemoveCallback;
  37112. private _observer;
  37113. private _rollObserver;
  37114. private previousPosition;
  37115. private noPreventDefault;
  37116. private element;
  37117. /**
  37118. * Listen to mouse events to control the camera.
  37119. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37121. */
  37122. constructor(touchEnabled?: boolean);
  37123. /**
  37124. * Attach the mouse control to the HTML DOM element.
  37125. * @param element Defines the element that listens to the input events.
  37126. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37127. */
  37128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37129. /**
  37130. * Detach the current controls from the specified dom element.
  37131. * @param element Defines the element to stop listening the inputs from
  37132. */
  37133. detachControl(element: Nullable<HTMLElement>): void;
  37134. /**
  37135. * Gets the class name of the current input.
  37136. * @returns the class name.
  37137. */
  37138. getClassName(): string;
  37139. /**
  37140. * Get the friendly name associated with the input class.
  37141. * @returns the input's friendly name.
  37142. */
  37143. getSimpleName(): string;
  37144. private _pointerInput;
  37145. private _onMouseMove;
  37146. /**
  37147. * Rotate camera by mouse offset.
  37148. */
  37149. private rotateCamera;
  37150. }
  37151. }
  37152. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37153. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37154. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37155. /**
  37156. * Default Inputs manager for the FlyCamera.
  37157. * It groups all the default supported inputs for ease of use.
  37158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37159. */
  37160. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37161. /**
  37162. * Instantiates a new FlyCameraInputsManager.
  37163. * @param camera Defines the camera the inputs belong to.
  37164. */
  37165. constructor(camera: FlyCamera);
  37166. /**
  37167. * Add keyboard input support to the input manager.
  37168. * @returns the new FlyCameraKeyboardMoveInput().
  37169. */
  37170. addKeyboard(): FlyCameraInputsManager;
  37171. /**
  37172. * Add mouse input support to the input manager.
  37173. * @param touchEnabled Enable touch screen support.
  37174. * @returns the new FlyCameraMouseInput().
  37175. */
  37176. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37177. }
  37178. }
  37179. declare module "babylonjs/Cameras/flyCamera" {
  37180. import { Scene } from "babylonjs/scene";
  37181. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37183. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37184. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37185. /**
  37186. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37187. * such as in a 3D Space Shooter or a Flight Simulator.
  37188. */
  37189. export class FlyCamera extends TargetCamera {
  37190. /**
  37191. * Define the collision ellipsoid of the camera.
  37192. * This is helpful for simulating a camera body, like a player's body.
  37193. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37194. */
  37195. ellipsoid: Vector3;
  37196. /**
  37197. * Define an offset for the position of the ellipsoid around the camera.
  37198. * This can be helpful if the camera is attached away from the player's body center,
  37199. * such as at its head.
  37200. */
  37201. ellipsoidOffset: Vector3;
  37202. /**
  37203. * Enable or disable collisions of the camera with the rest of the scene objects.
  37204. */
  37205. checkCollisions: boolean;
  37206. /**
  37207. * Enable or disable gravity on the camera.
  37208. */
  37209. applyGravity: boolean;
  37210. /**
  37211. * Define the current direction the camera is moving to.
  37212. */
  37213. cameraDirection: Vector3;
  37214. /**
  37215. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37216. * This overrides and empties cameraRotation.
  37217. */
  37218. rotationQuaternion: Quaternion;
  37219. /**
  37220. * Track Roll to maintain the wanted Rolling when looking around.
  37221. */
  37222. _trackRoll: number;
  37223. /**
  37224. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37225. */
  37226. rollCorrect: number;
  37227. /**
  37228. * Mimic a banked turn, Rolling the camera when Yawing.
  37229. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37230. */
  37231. bankedTurn: boolean;
  37232. /**
  37233. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37234. */
  37235. bankedTurnLimit: number;
  37236. /**
  37237. * Value of 0 disables the banked Roll.
  37238. * Value of 1 is equal to the Yaw angle in radians.
  37239. */
  37240. bankedTurnMultiplier: number;
  37241. /**
  37242. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37243. */
  37244. inputs: FlyCameraInputsManager;
  37245. /**
  37246. * Gets the input sensibility for mouse input.
  37247. * Higher values reduce sensitivity.
  37248. */
  37249. /**
  37250. * Sets the input sensibility for a mouse input.
  37251. * Higher values reduce sensitivity.
  37252. */
  37253. angularSensibility: number;
  37254. /**
  37255. * Get the keys for camera movement forward.
  37256. */
  37257. /**
  37258. * Set the keys for camera movement forward.
  37259. */
  37260. keysForward: number[];
  37261. /**
  37262. * Get the keys for camera movement backward.
  37263. */
  37264. keysBackward: number[];
  37265. /**
  37266. * Get the keys for camera movement up.
  37267. */
  37268. /**
  37269. * Set the keys for camera movement up.
  37270. */
  37271. keysUp: number[];
  37272. /**
  37273. * Get the keys for camera movement down.
  37274. */
  37275. /**
  37276. * Set the keys for camera movement down.
  37277. */
  37278. keysDown: number[];
  37279. /**
  37280. * Get the keys for camera movement left.
  37281. */
  37282. /**
  37283. * Set the keys for camera movement left.
  37284. */
  37285. keysLeft: number[];
  37286. /**
  37287. * Set the keys for camera movement right.
  37288. */
  37289. /**
  37290. * Set the keys for camera movement right.
  37291. */
  37292. keysRight: number[];
  37293. /**
  37294. * Event raised when the camera collides with a mesh in the scene.
  37295. */
  37296. onCollide: (collidedMesh: AbstractMesh) => void;
  37297. private _collider;
  37298. private _needMoveForGravity;
  37299. private _oldPosition;
  37300. private _diffPosition;
  37301. private _newPosition;
  37302. /** @hidden */
  37303. _localDirection: Vector3;
  37304. /** @hidden */
  37305. _transformedDirection: Vector3;
  37306. /**
  37307. * Instantiates a FlyCamera.
  37308. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37309. * such as in a 3D Space Shooter or a Flight Simulator.
  37310. * @param name Define the name of the camera in the scene.
  37311. * @param position Define the starting position of the camera in the scene.
  37312. * @param scene Define the scene the camera belongs to.
  37313. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37314. */
  37315. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37316. /**
  37317. * Attach a control to the HTML DOM element.
  37318. * @param element Defines the element that listens to the input events.
  37319. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37320. */
  37321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37322. /**
  37323. * Detach a control from the HTML DOM element.
  37324. * The camera will stop reacting to that input.
  37325. * @param element Defines the element that listens to the input events.
  37326. */
  37327. detachControl(element: HTMLElement): void;
  37328. private _collisionMask;
  37329. /**
  37330. * Get the mask that the camera ignores in collision events.
  37331. */
  37332. /**
  37333. * Set the mask that the camera ignores in collision events.
  37334. */
  37335. collisionMask: number;
  37336. /** @hidden */
  37337. _collideWithWorld(displacement: Vector3): void;
  37338. /** @hidden */
  37339. private _onCollisionPositionChange;
  37340. /** @hidden */
  37341. _checkInputs(): void;
  37342. /** @hidden */
  37343. _decideIfNeedsToMove(): boolean;
  37344. /** @hidden */
  37345. _updatePosition(): void;
  37346. /**
  37347. * Restore the Roll to its target value at the rate specified.
  37348. * @param rate - Higher means slower restoring.
  37349. * @hidden
  37350. */
  37351. restoreRoll(rate: number): void;
  37352. /**
  37353. * Destroy the camera and release the current resources held by it.
  37354. */
  37355. dispose(): void;
  37356. /**
  37357. * Get the current object class name.
  37358. * @returns the class name.
  37359. */
  37360. getClassName(): string;
  37361. }
  37362. }
  37363. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37364. import { Nullable } from "babylonjs/types";
  37365. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37366. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37367. /**
  37368. * Listen to keyboard events to control the camera.
  37369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37370. */
  37371. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37372. /**
  37373. * Defines the camera the input is attached to.
  37374. */
  37375. camera: FlyCamera;
  37376. /**
  37377. * The list of keyboard keys used to control the forward move of the camera.
  37378. */
  37379. keysForward: number[];
  37380. /**
  37381. * The list of keyboard keys used to control the backward move of the camera.
  37382. */
  37383. keysBackward: number[];
  37384. /**
  37385. * The list of keyboard keys used to control the forward move of the camera.
  37386. */
  37387. keysUp: number[];
  37388. /**
  37389. * The list of keyboard keys used to control the backward move of the camera.
  37390. */
  37391. keysDown: number[];
  37392. /**
  37393. * The list of keyboard keys used to control the right strafe move of the camera.
  37394. */
  37395. keysRight: number[];
  37396. /**
  37397. * The list of keyboard keys used to control the left strafe move of the camera.
  37398. */
  37399. keysLeft: number[];
  37400. private _keys;
  37401. private _onCanvasBlurObserver;
  37402. private _onKeyboardObserver;
  37403. private _engine;
  37404. private _scene;
  37405. /**
  37406. * Attach the input controls to a specific dom element to get the input from.
  37407. * @param element Defines the element the controls should be listened from
  37408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37409. */
  37410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37411. /**
  37412. * Detach the current controls from the specified dom element.
  37413. * @param element Defines the element to stop listening the inputs from
  37414. */
  37415. detachControl(element: Nullable<HTMLElement>): void;
  37416. /**
  37417. * Gets the class name of the current intput.
  37418. * @returns the class name
  37419. */
  37420. getClassName(): string;
  37421. /** @hidden */
  37422. _onLostFocus(e: FocusEvent): void;
  37423. /**
  37424. * Get the friendly name associated with the input class.
  37425. * @returns the input friendly name
  37426. */
  37427. getSimpleName(): string;
  37428. /**
  37429. * Update the current camera state depending on the inputs that have been used this frame.
  37430. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37431. */
  37432. checkInputs(): void;
  37433. }
  37434. }
  37435. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37436. import { Nullable } from "babylonjs/types";
  37437. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37438. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37439. /**
  37440. * Manage the mouse wheel inputs to control a follow camera.
  37441. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37442. */
  37443. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37444. /**
  37445. * Defines the camera the input is attached to.
  37446. */
  37447. camera: FollowCamera;
  37448. /**
  37449. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37450. */
  37451. axisControlRadius: boolean;
  37452. /**
  37453. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37454. */
  37455. axisControlHeight: boolean;
  37456. /**
  37457. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37458. */
  37459. axisControlRotation: boolean;
  37460. /**
  37461. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37462. * relation to mouseWheel events.
  37463. */
  37464. wheelPrecision: number;
  37465. /**
  37466. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37467. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37468. */
  37469. wheelDeltaPercentage: number;
  37470. private _wheel;
  37471. private _observer;
  37472. /**
  37473. * Attach the input controls to a specific dom element to get the input from.
  37474. * @param element Defines the element the controls should be listened from
  37475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37476. */
  37477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37478. /**
  37479. * Detach the current controls from the specified dom element.
  37480. * @param element Defines the element to stop listening the inputs from
  37481. */
  37482. detachControl(element: Nullable<HTMLElement>): void;
  37483. /**
  37484. * Gets the class name of the current intput.
  37485. * @returns the class name
  37486. */
  37487. getClassName(): string;
  37488. /**
  37489. * Get the friendly name associated with the input class.
  37490. * @returns the input friendly name
  37491. */
  37492. getSimpleName(): string;
  37493. }
  37494. }
  37495. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37496. import { Nullable } from "babylonjs/types";
  37497. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37498. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37499. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37500. /**
  37501. * Manage the pointers inputs to control an follow camera.
  37502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37503. */
  37504. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37505. /**
  37506. * Defines the camera the input is attached to.
  37507. */
  37508. camera: FollowCamera;
  37509. /**
  37510. * Gets the class name of the current input.
  37511. * @returns the class name
  37512. */
  37513. getClassName(): string;
  37514. /**
  37515. * Defines the pointer angular sensibility along the X axis or how fast is
  37516. * the camera rotating.
  37517. * A negative number will reverse the axis direction.
  37518. */
  37519. angularSensibilityX: number;
  37520. /**
  37521. * Defines the pointer angular sensibility along the Y axis or how fast is
  37522. * the camera rotating.
  37523. * A negative number will reverse the axis direction.
  37524. */
  37525. angularSensibilityY: number;
  37526. /**
  37527. * Defines the pointer pinch precision or how fast is the camera zooming.
  37528. * A negative number will reverse the axis direction.
  37529. */
  37530. pinchPrecision: number;
  37531. /**
  37532. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37533. * from 0.
  37534. * It defines the percentage of current camera.radius to use as delta when
  37535. * pinch zoom is used.
  37536. */
  37537. pinchDeltaPercentage: number;
  37538. /**
  37539. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37540. */
  37541. axisXControlRadius: boolean;
  37542. /**
  37543. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37544. */
  37545. axisXControlHeight: boolean;
  37546. /**
  37547. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37548. */
  37549. axisXControlRotation: boolean;
  37550. /**
  37551. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37552. */
  37553. axisYControlRadius: boolean;
  37554. /**
  37555. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37556. */
  37557. axisYControlHeight: boolean;
  37558. /**
  37559. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37560. */
  37561. axisYControlRotation: boolean;
  37562. /**
  37563. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37564. */
  37565. axisPinchControlRadius: boolean;
  37566. /**
  37567. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37568. */
  37569. axisPinchControlHeight: boolean;
  37570. /**
  37571. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37572. */
  37573. axisPinchControlRotation: boolean;
  37574. /**
  37575. * Log error messages if basic misconfiguration has occurred.
  37576. */
  37577. warningEnable: boolean;
  37578. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37579. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37580. private _warningCounter;
  37581. private _warning;
  37582. }
  37583. }
  37584. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37585. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37586. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37587. /**
  37588. * Default Inputs manager for the FollowCamera.
  37589. * It groups all the default supported inputs for ease of use.
  37590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37591. */
  37592. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37593. /**
  37594. * Instantiates a new FollowCameraInputsManager.
  37595. * @param camera Defines the camera the inputs belong to
  37596. */
  37597. constructor(camera: FollowCamera);
  37598. /**
  37599. * Add keyboard input support to the input manager.
  37600. * @returns the current input manager
  37601. */
  37602. addKeyboard(): FollowCameraInputsManager;
  37603. /**
  37604. * Add mouse wheel input support to the input manager.
  37605. * @returns the current input manager
  37606. */
  37607. addMouseWheel(): FollowCameraInputsManager;
  37608. /**
  37609. * Add pointers input support to the input manager.
  37610. * @returns the current input manager
  37611. */
  37612. addPointers(): FollowCameraInputsManager;
  37613. /**
  37614. * Add orientation input support to the input manager.
  37615. * @returns the current input manager
  37616. */
  37617. addVRDeviceOrientation(): FollowCameraInputsManager;
  37618. }
  37619. }
  37620. declare module "babylonjs/Cameras/followCamera" {
  37621. import { Nullable } from "babylonjs/types";
  37622. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37623. import { Scene } from "babylonjs/scene";
  37624. import { Vector3 } from "babylonjs/Maths/math";
  37625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37626. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37627. /**
  37628. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37629. * an arc rotate version arcFollowCamera are available.
  37630. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37631. */
  37632. export class FollowCamera extends TargetCamera {
  37633. /**
  37634. * Distance the follow camera should follow an object at
  37635. */
  37636. radius: number;
  37637. /**
  37638. * Minimum allowed distance of the camera to the axis of rotation
  37639. * (The camera can not get closer).
  37640. * This can help limiting how the Camera is able to move in the scene.
  37641. */
  37642. lowerRadiusLimit: Nullable<number>;
  37643. /**
  37644. * Maximum allowed distance of the camera to the axis of rotation
  37645. * (The camera can not get further).
  37646. * This can help limiting how the Camera is able to move in the scene.
  37647. */
  37648. upperRadiusLimit: Nullable<number>;
  37649. /**
  37650. * Define a rotation offset between the camera and the object it follows
  37651. */
  37652. rotationOffset: number;
  37653. /**
  37654. * Minimum allowed angle to camera position relative to target object.
  37655. * This can help limiting how the Camera is able to move in the scene.
  37656. */
  37657. lowerRotationOffsetLimit: Nullable<number>;
  37658. /**
  37659. * Maximum allowed angle to camera position relative to target object.
  37660. * This can help limiting how the Camera is able to move in the scene.
  37661. */
  37662. upperRotationOffsetLimit: Nullable<number>;
  37663. /**
  37664. * Define a height offset between the camera and the object it follows.
  37665. * It can help following an object from the top (like a car chaing a plane)
  37666. */
  37667. heightOffset: number;
  37668. /**
  37669. * Minimum allowed height of camera position relative to target object.
  37670. * This can help limiting how the Camera is able to move in the scene.
  37671. */
  37672. lowerHeightOffsetLimit: Nullable<number>;
  37673. /**
  37674. * Maximum allowed height of camera position relative to target object.
  37675. * This can help limiting how the Camera is able to move in the scene.
  37676. */
  37677. upperHeightOffsetLimit: Nullable<number>;
  37678. /**
  37679. * Define how fast the camera can accelerate to follow it s target.
  37680. */
  37681. cameraAcceleration: number;
  37682. /**
  37683. * Define the speed limit of the camera following an object.
  37684. */
  37685. maxCameraSpeed: number;
  37686. /**
  37687. * Define the target of the camera.
  37688. */
  37689. lockedTarget: Nullable<AbstractMesh>;
  37690. /**
  37691. * Defines the input associated with the camera.
  37692. */
  37693. inputs: FollowCameraInputsManager;
  37694. /**
  37695. * Instantiates the follow camera.
  37696. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37697. * @param name Define the name of the camera in the scene
  37698. * @param position Define the position of the camera
  37699. * @param scene Define the scene the camera belong to
  37700. * @param lockedTarget Define the target of the camera
  37701. */
  37702. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37703. private _follow;
  37704. /**
  37705. * Attached controls to the current camera.
  37706. * @param element Defines the element the controls should be listened from
  37707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37708. */
  37709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37710. /**
  37711. * Detach the current controls from the camera.
  37712. * The camera will stop reacting to inputs.
  37713. * @param element Defines the element to stop listening the inputs from
  37714. */
  37715. detachControl(element: HTMLElement): void;
  37716. /** @hidden */
  37717. _checkInputs(): void;
  37718. private _checkLimits;
  37719. /**
  37720. * Gets the camera class name.
  37721. * @returns the class name
  37722. */
  37723. getClassName(): string;
  37724. }
  37725. /**
  37726. * Arc Rotate version of the follow camera.
  37727. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37728. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37729. */
  37730. export class ArcFollowCamera extends TargetCamera {
  37731. /** The longitudinal angle of the camera */
  37732. alpha: number;
  37733. /** The latitudinal angle of the camera */
  37734. beta: number;
  37735. /** The radius of the camera from its target */
  37736. radius: number;
  37737. /** Define the camera target (the messh it should follow) */
  37738. target: Nullable<AbstractMesh>;
  37739. private _cartesianCoordinates;
  37740. /**
  37741. * Instantiates a new ArcFollowCamera
  37742. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37743. * @param name Define the name of the camera
  37744. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37745. * @param beta Define the rotation angle of the camera around the elevation axis
  37746. * @param radius Define the radius of the camera from its target point
  37747. * @param target Define the target of the camera
  37748. * @param scene Define the scene the camera belongs to
  37749. */
  37750. constructor(name: string,
  37751. /** The longitudinal angle of the camera */
  37752. alpha: number,
  37753. /** The latitudinal angle of the camera */
  37754. beta: number,
  37755. /** The radius of the camera from its target */
  37756. radius: number,
  37757. /** Define the camera target (the messh it should follow) */
  37758. target: Nullable<AbstractMesh>, scene: Scene);
  37759. private _follow;
  37760. /** @hidden */
  37761. _checkInputs(): void;
  37762. /**
  37763. * Returns the class name of the object.
  37764. * It is mostly used internally for serialization purposes.
  37765. */
  37766. getClassName(): string;
  37767. }
  37768. }
  37769. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37770. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37771. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37772. import { Nullable } from "babylonjs/types";
  37773. /**
  37774. * Manage the keyboard inputs to control the movement of a follow camera.
  37775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37776. */
  37777. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37778. /**
  37779. * Defines the camera the input is attached to.
  37780. */
  37781. camera: FollowCamera;
  37782. /**
  37783. * Defines the list of key codes associated with the up action (increase heightOffset)
  37784. */
  37785. keysHeightOffsetIncr: number[];
  37786. /**
  37787. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37788. */
  37789. keysHeightOffsetDecr: number[];
  37790. /**
  37791. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37792. */
  37793. keysHeightOffsetModifierAlt: boolean;
  37794. /**
  37795. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37796. */
  37797. keysHeightOffsetModifierCtrl: boolean;
  37798. /**
  37799. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37800. */
  37801. keysHeightOffsetModifierShift: boolean;
  37802. /**
  37803. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37804. */
  37805. keysRotationOffsetIncr: number[];
  37806. /**
  37807. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37808. */
  37809. keysRotationOffsetDecr: number[];
  37810. /**
  37811. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37812. */
  37813. keysRotationOffsetModifierAlt: boolean;
  37814. /**
  37815. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37816. */
  37817. keysRotationOffsetModifierCtrl: boolean;
  37818. /**
  37819. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37820. */
  37821. keysRotationOffsetModifierShift: boolean;
  37822. /**
  37823. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37824. */
  37825. keysRadiusIncr: number[];
  37826. /**
  37827. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37828. */
  37829. keysRadiusDecr: number[];
  37830. /**
  37831. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37832. */
  37833. keysRadiusModifierAlt: boolean;
  37834. /**
  37835. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37836. */
  37837. keysRadiusModifierCtrl: boolean;
  37838. /**
  37839. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37840. */
  37841. keysRadiusModifierShift: boolean;
  37842. /**
  37843. * Defines the rate of change of heightOffset.
  37844. */
  37845. heightSensibility: number;
  37846. /**
  37847. * Defines the rate of change of rotationOffset.
  37848. */
  37849. rotationSensibility: number;
  37850. /**
  37851. * Defines the rate of change of radius.
  37852. */
  37853. radiusSensibility: number;
  37854. private _keys;
  37855. private _ctrlPressed;
  37856. private _altPressed;
  37857. private _shiftPressed;
  37858. private _onCanvasBlurObserver;
  37859. private _onKeyboardObserver;
  37860. private _engine;
  37861. private _scene;
  37862. /**
  37863. * Attach the input controls to a specific dom element to get the input from.
  37864. * @param element Defines the element the controls should be listened from
  37865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37866. */
  37867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37868. /**
  37869. * Detach the current controls from the specified dom element.
  37870. * @param element Defines the element to stop listening the inputs from
  37871. */
  37872. detachControl(element: Nullable<HTMLElement>): void;
  37873. /**
  37874. * Update the current camera state depending on the inputs that have been used this frame.
  37875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37876. */
  37877. checkInputs(): void;
  37878. /**
  37879. * Gets the class name of the current input.
  37880. * @returns the class name
  37881. */
  37882. getClassName(): string;
  37883. /**
  37884. * Get the friendly name associated with the input class.
  37885. * @returns the input friendly name
  37886. */
  37887. getSimpleName(): string;
  37888. /**
  37889. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37890. * allow modification of the heightOffset value.
  37891. */
  37892. private _modifierHeightOffset;
  37893. /**
  37894. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37895. * allow modification of the rotationOffset value.
  37896. */
  37897. private _modifierRotationOffset;
  37898. /**
  37899. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37900. * allow modification of the radius value.
  37901. */
  37902. private _modifierRadius;
  37903. }
  37904. }
  37905. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37906. import { Nullable } from "babylonjs/types";
  37907. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37908. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37909. import { Observable } from "babylonjs/Misc/observable";
  37910. module "babylonjs/Cameras/freeCameraInputsManager" {
  37911. interface FreeCameraInputsManager {
  37912. /**
  37913. * @hidden
  37914. */
  37915. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37916. /**
  37917. * Add orientation input support to the input manager.
  37918. * @returns the current input manager
  37919. */
  37920. addDeviceOrientation(): FreeCameraInputsManager;
  37921. }
  37922. }
  37923. /**
  37924. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37925. * Screen rotation is taken into account.
  37926. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37927. */
  37928. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37929. private _camera;
  37930. private _screenOrientationAngle;
  37931. private _constantTranform;
  37932. private _screenQuaternion;
  37933. private _alpha;
  37934. private _beta;
  37935. private _gamma;
  37936. /**
  37937. * @hidden
  37938. */
  37939. _onDeviceOrientationChangedObservable: Observable<void>;
  37940. /**
  37941. * Instantiates a new input
  37942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37943. */
  37944. constructor();
  37945. /**
  37946. * Define the camera controlled by the input.
  37947. */
  37948. camera: FreeCamera;
  37949. /**
  37950. * Attach the input controls to a specific dom element to get the input from.
  37951. * @param element Defines the element the controls should be listened from
  37952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37953. */
  37954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37955. private _orientationChanged;
  37956. private _deviceOrientation;
  37957. /**
  37958. * Detach the current controls from the specified dom element.
  37959. * @param element Defines the element to stop listening the inputs from
  37960. */
  37961. detachControl(element: Nullable<HTMLElement>): void;
  37962. /**
  37963. * Update the current camera state depending on the inputs that have been used this frame.
  37964. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37965. */
  37966. checkInputs(): void;
  37967. /**
  37968. * Gets the class name of the current intput.
  37969. * @returns the class name
  37970. */
  37971. getClassName(): string;
  37972. /**
  37973. * Get the friendly name associated with the input class.
  37974. * @returns the input friendly name
  37975. */
  37976. getSimpleName(): string;
  37977. }
  37978. }
  37979. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37980. import { Nullable } from "babylonjs/types";
  37981. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37982. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37983. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37984. /**
  37985. * Manage the gamepad inputs to control a free camera.
  37986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37987. */
  37988. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37989. /**
  37990. * Define the camera the input is attached to.
  37991. */
  37992. camera: FreeCamera;
  37993. /**
  37994. * Define the Gamepad controlling the input
  37995. */
  37996. gamepad: Nullable<Gamepad>;
  37997. /**
  37998. * Defines the gamepad rotation sensiblity.
  37999. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38000. */
  38001. gamepadAngularSensibility: number;
  38002. /**
  38003. * Defines the gamepad move sensiblity.
  38004. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38005. */
  38006. gamepadMoveSensibility: number;
  38007. private _onGamepadConnectedObserver;
  38008. private _onGamepadDisconnectedObserver;
  38009. private _cameraTransform;
  38010. private _deltaTransform;
  38011. private _vector3;
  38012. private _vector2;
  38013. /**
  38014. * Attach the input controls to a specific dom element to get the input from.
  38015. * @param element Defines the element the controls should be listened from
  38016. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38017. */
  38018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38019. /**
  38020. * Detach the current controls from the specified dom element.
  38021. * @param element Defines the element to stop listening the inputs from
  38022. */
  38023. detachControl(element: Nullable<HTMLElement>): void;
  38024. /**
  38025. * Update the current camera state depending on the inputs that have been used this frame.
  38026. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38027. */
  38028. checkInputs(): void;
  38029. /**
  38030. * Gets the class name of the current intput.
  38031. * @returns the class name
  38032. */
  38033. getClassName(): string;
  38034. /**
  38035. * Get the friendly name associated with the input class.
  38036. * @returns the input friendly name
  38037. */
  38038. getSimpleName(): string;
  38039. }
  38040. }
  38041. declare module "babylonjs/Misc/virtualJoystick" {
  38042. import { Nullable } from "babylonjs/types";
  38043. import { Vector3 } from "babylonjs/Maths/math";
  38044. /**
  38045. * Defines the potential axis of a Joystick
  38046. */
  38047. export enum JoystickAxis {
  38048. /** X axis */
  38049. X = 0,
  38050. /** Y axis */
  38051. Y = 1,
  38052. /** Z axis */
  38053. Z = 2
  38054. }
  38055. /**
  38056. * Class used to define virtual joystick (used in touch mode)
  38057. */
  38058. export class VirtualJoystick {
  38059. /**
  38060. * Gets or sets a boolean indicating that left and right values must be inverted
  38061. */
  38062. reverseLeftRight: boolean;
  38063. /**
  38064. * Gets or sets a boolean indicating that up and down values must be inverted
  38065. */
  38066. reverseUpDown: boolean;
  38067. /**
  38068. * Gets the offset value for the position (ie. the change of the position value)
  38069. */
  38070. deltaPosition: Vector3;
  38071. /**
  38072. * Gets a boolean indicating if the virtual joystick was pressed
  38073. */
  38074. pressed: boolean;
  38075. /**
  38076. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38077. */
  38078. static Canvas: Nullable<HTMLCanvasElement>;
  38079. private static _globalJoystickIndex;
  38080. private static vjCanvasContext;
  38081. private static vjCanvasWidth;
  38082. private static vjCanvasHeight;
  38083. private static halfWidth;
  38084. private _action;
  38085. private _axisTargetedByLeftAndRight;
  38086. private _axisTargetedByUpAndDown;
  38087. private _joystickSensibility;
  38088. private _inversedSensibility;
  38089. private _joystickPointerID;
  38090. private _joystickColor;
  38091. private _joystickPointerPos;
  38092. private _joystickPreviousPointerPos;
  38093. private _joystickPointerStartPos;
  38094. private _deltaJoystickVector;
  38095. private _leftJoystick;
  38096. private _touches;
  38097. private _onPointerDownHandlerRef;
  38098. private _onPointerMoveHandlerRef;
  38099. private _onPointerUpHandlerRef;
  38100. private _onResize;
  38101. /**
  38102. * Creates a new virtual joystick
  38103. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38104. */
  38105. constructor(leftJoystick?: boolean);
  38106. /**
  38107. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38108. * @param newJoystickSensibility defines the new sensibility
  38109. */
  38110. setJoystickSensibility(newJoystickSensibility: number): void;
  38111. private _onPointerDown;
  38112. private _onPointerMove;
  38113. private _onPointerUp;
  38114. /**
  38115. * Change the color of the virtual joystick
  38116. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38117. */
  38118. setJoystickColor(newColor: string): void;
  38119. /**
  38120. * Defines a callback to call when the joystick is touched
  38121. * @param action defines the callback
  38122. */
  38123. setActionOnTouch(action: () => any): void;
  38124. /**
  38125. * Defines which axis you'd like to control for left & right
  38126. * @param axis defines the axis to use
  38127. */
  38128. setAxisForLeftRight(axis: JoystickAxis): void;
  38129. /**
  38130. * Defines which axis you'd like to control for up & down
  38131. * @param axis defines the axis to use
  38132. */
  38133. setAxisForUpDown(axis: JoystickAxis): void;
  38134. private _drawVirtualJoystick;
  38135. /**
  38136. * Release internal HTML canvas
  38137. */
  38138. releaseCanvas(): void;
  38139. }
  38140. }
  38141. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38142. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38143. import { Nullable } from "babylonjs/types";
  38144. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38145. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38146. module "babylonjs/Cameras/freeCameraInputsManager" {
  38147. interface FreeCameraInputsManager {
  38148. /**
  38149. * Add virtual joystick input support to the input manager.
  38150. * @returns the current input manager
  38151. */
  38152. addVirtualJoystick(): FreeCameraInputsManager;
  38153. }
  38154. }
  38155. /**
  38156. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38158. */
  38159. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38160. /**
  38161. * Defines the camera the input is attached to.
  38162. */
  38163. camera: FreeCamera;
  38164. private _leftjoystick;
  38165. private _rightjoystick;
  38166. /**
  38167. * Gets the left stick of the virtual joystick.
  38168. * @returns The virtual Joystick
  38169. */
  38170. getLeftJoystick(): VirtualJoystick;
  38171. /**
  38172. * Gets the right stick of the virtual joystick.
  38173. * @returns The virtual Joystick
  38174. */
  38175. getRightJoystick(): VirtualJoystick;
  38176. /**
  38177. * Update the current camera state depending on the inputs that have been used this frame.
  38178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38179. */
  38180. checkInputs(): void;
  38181. /**
  38182. * Attach the input controls to a specific dom element to get the input from.
  38183. * @param element Defines the element the controls should be listened from
  38184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38185. */
  38186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38187. /**
  38188. * Detach the current controls from the specified dom element.
  38189. * @param element Defines the element to stop listening the inputs from
  38190. */
  38191. detachControl(element: Nullable<HTMLElement>): void;
  38192. /**
  38193. * Gets the class name of the current intput.
  38194. * @returns the class name
  38195. */
  38196. getClassName(): string;
  38197. /**
  38198. * Get the friendly name associated with the input class.
  38199. * @returns the input friendly name
  38200. */
  38201. getSimpleName(): string;
  38202. }
  38203. }
  38204. declare module "babylonjs/Cameras/Inputs/index" {
  38205. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38206. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38207. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38208. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38209. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38210. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38211. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38212. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38213. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38214. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38215. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38216. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38217. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38218. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38219. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38220. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38221. }
  38222. declare module "babylonjs/Cameras/touchCamera" {
  38223. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38224. import { Scene } from "babylonjs/scene";
  38225. import { Vector3 } from "babylonjs/Maths/math";
  38226. /**
  38227. * This represents a FPS type of camera controlled by touch.
  38228. * This is like a universal camera minus the Gamepad controls.
  38229. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38230. */
  38231. export class TouchCamera extends FreeCamera {
  38232. /**
  38233. * Defines the touch sensibility for rotation.
  38234. * The higher the faster.
  38235. */
  38236. touchAngularSensibility: number;
  38237. /**
  38238. * Defines the touch sensibility for move.
  38239. * The higher the faster.
  38240. */
  38241. touchMoveSensibility: number;
  38242. /**
  38243. * Instantiates a new touch camera.
  38244. * This represents a FPS type of camera controlled by touch.
  38245. * This is like a universal camera minus the Gamepad controls.
  38246. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38247. * @param name Define the name of the camera in the scene
  38248. * @param position Define the start position of the camera in the scene
  38249. * @param scene Define the scene the camera belongs to
  38250. */
  38251. constructor(name: string, position: Vector3, scene: Scene);
  38252. /**
  38253. * Gets the current object class name.
  38254. * @return the class name
  38255. */
  38256. getClassName(): string;
  38257. /** @hidden */
  38258. _setupInputs(): void;
  38259. }
  38260. }
  38261. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38262. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38263. import { Scene } from "babylonjs/scene";
  38264. import { Vector3, Axis } from "babylonjs/Maths/math";
  38265. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38266. /**
  38267. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38268. * being tilted forward or back and left or right.
  38269. */
  38270. export class DeviceOrientationCamera extends FreeCamera {
  38271. private _initialQuaternion;
  38272. private _quaternionCache;
  38273. private _tmpDragQuaternion;
  38274. /**
  38275. * Creates a new device orientation camera
  38276. * @param name The name of the camera
  38277. * @param position The start position camera
  38278. * @param scene The scene the camera belongs to
  38279. */
  38280. constructor(name: string, position: Vector3, scene: Scene);
  38281. /**
  38282. * Disabled pointer input on first orientation sensor update (Default: true)
  38283. */
  38284. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38285. private _dragFactor;
  38286. /**
  38287. * Enabled turning on the y axis when the orientation sensor is active
  38288. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38289. */
  38290. enableHorizontalDragging(dragFactor?: number): void;
  38291. /**
  38292. * Gets the current instance class name ("DeviceOrientationCamera").
  38293. * This helps avoiding instanceof at run time.
  38294. * @returns the class name
  38295. */
  38296. getClassName(): string;
  38297. /**
  38298. * @hidden
  38299. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38300. */
  38301. _checkInputs(): void;
  38302. /**
  38303. * Reset the camera to its default orientation on the specified axis only.
  38304. * @param axis The axis to reset
  38305. */
  38306. resetToCurrentRotation(axis?: Axis): void;
  38307. }
  38308. }
  38309. declare module "babylonjs/Cameras/universalCamera" {
  38310. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38311. import { Scene } from "babylonjs/scene";
  38312. import { Vector3 } from "babylonjs/Maths/math";
  38313. /**
  38314. * 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,
  38315. * which still works and will still be found in many Playgrounds.
  38316. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38317. */
  38318. export class UniversalCamera extends TouchCamera {
  38319. /**
  38320. * Defines the gamepad rotation sensiblity.
  38321. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38322. */
  38323. gamepadAngularSensibility: number;
  38324. /**
  38325. * Defines the gamepad move sensiblity.
  38326. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38327. */
  38328. gamepadMoveSensibility: number;
  38329. /**
  38330. * 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,
  38331. * which still works and will still be found in many Playgrounds.
  38332. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38333. * @param name Define the name of the camera in the scene
  38334. * @param position Define the start position of the camera in the scene
  38335. * @param scene Define the scene the camera belongs to
  38336. */
  38337. constructor(name: string, position: Vector3, scene: Scene);
  38338. /**
  38339. * Gets the current object class name.
  38340. * @return the class name
  38341. */
  38342. getClassName(): string;
  38343. }
  38344. }
  38345. declare module "babylonjs/Cameras/gamepadCamera" {
  38346. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38347. import { Scene } from "babylonjs/scene";
  38348. import { Vector3 } from "babylonjs/Maths/math";
  38349. /**
  38350. * This represents a FPS type of camera. This is only here for back compat purpose.
  38351. * Please use the UniversalCamera instead as both are identical.
  38352. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38353. */
  38354. export class GamepadCamera extends UniversalCamera {
  38355. /**
  38356. * Instantiates a new Gamepad Camera
  38357. * This represents a FPS type of camera. This is only here for back compat purpose.
  38358. * Please use the UniversalCamera instead as both are identical.
  38359. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38360. * @param name Define the name of the camera in the scene
  38361. * @param position Define the start position of the camera in the scene
  38362. * @param scene Define the scene the camera belongs to
  38363. */
  38364. constructor(name: string, position: Vector3, scene: Scene);
  38365. /**
  38366. * Gets the current object class name.
  38367. * @return the class name
  38368. */
  38369. getClassName(): string;
  38370. }
  38371. }
  38372. declare module "babylonjs/Shaders/pass.fragment" {
  38373. /** @hidden */
  38374. export var passPixelShader: {
  38375. name: string;
  38376. shader: string;
  38377. };
  38378. }
  38379. declare module "babylonjs/Shaders/passCube.fragment" {
  38380. /** @hidden */
  38381. export var passCubePixelShader: {
  38382. name: string;
  38383. shader: string;
  38384. };
  38385. }
  38386. declare module "babylonjs/PostProcesses/passPostProcess" {
  38387. import { Nullable } from "babylonjs/types";
  38388. import { Camera } from "babylonjs/Cameras/camera";
  38389. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38390. import { Engine } from "babylonjs/Engines/engine";
  38391. import "babylonjs/Shaders/pass.fragment";
  38392. import "babylonjs/Shaders/passCube.fragment";
  38393. /**
  38394. * PassPostProcess which produces an output the same as it's input
  38395. */
  38396. export class PassPostProcess extends PostProcess {
  38397. /**
  38398. * Creates the PassPostProcess
  38399. * @param name The name of the effect.
  38400. * @param options The required width/height ratio to downsize to before computing the render pass.
  38401. * @param camera The camera to apply the render pass to.
  38402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38403. * @param engine The engine which the post process will be applied. (default: current engine)
  38404. * @param reusable If the post process can be reused on the same frame. (default: false)
  38405. * @param textureType The type of texture to be used when performing the post processing.
  38406. * @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)
  38407. */
  38408. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38409. }
  38410. /**
  38411. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38412. */
  38413. export class PassCubePostProcess extends PostProcess {
  38414. private _face;
  38415. /**
  38416. * Gets or sets the cube face to display.
  38417. * * 0 is +X
  38418. * * 1 is -X
  38419. * * 2 is +Y
  38420. * * 3 is -Y
  38421. * * 4 is +Z
  38422. * * 5 is -Z
  38423. */
  38424. face: number;
  38425. /**
  38426. * Creates the PassCubePostProcess
  38427. * @param name The name of the effect.
  38428. * @param options The required width/height ratio to downsize to before computing the render pass.
  38429. * @param camera The camera to apply the render pass to.
  38430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38431. * @param engine The engine which the post process will be applied. (default: current engine)
  38432. * @param reusable If the post process can be reused on the same frame. (default: false)
  38433. * @param textureType The type of texture to be used when performing the post processing.
  38434. * @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)
  38435. */
  38436. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38437. }
  38438. }
  38439. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38440. /** @hidden */
  38441. export var anaglyphPixelShader: {
  38442. name: string;
  38443. shader: string;
  38444. };
  38445. }
  38446. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38447. import { Engine } from "babylonjs/Engines/engine";
  38448. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38449. import { Camera } from "babylonjs/Cameras/camera";
  38450. import "babylonjs/Shaders/anaglyph.fragment";
  38451. /**
  38452. * Postprocess used to generate anaglyphic rendering
  38453. */
  38454. export class AnaglyphPostProcess extends PostProcess {
  38455. private _passedProcess;
  38456. /**
  38457. * Creates a new AnaglyphPostProcess
  38458. * @param name defines postprocess name
  38459. * @param options defines creation options or target ratio scale
  38460. * @param rigCameras defines cameras using this postprocess
  38461. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38462. * @param engine defines hosting engine
  38463. * @param reusable defines if the postprocess will be reused multiple times per frame
  38464. */
  38465. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38466. }
  38467. }
  38468. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38469. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38470. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38471. import { Scene } from "babylonjs/scene";
  38472. import { Vector3 } from "babylonjs/Maths/math";
  38473. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38474. /**
  38475. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38476. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38477. */
  38478. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38479. /**
  38480. * Creates a new AnaglyphArcRotateCamera
  38481. * @param name defines camera name
  38482. * @param alpha defines alpha angle (in radians)
  38483. * @param beta defines beta angle (in radians)
  38484. * @param radius defines radius
  38485. * @param target defines camera target
  38486. * @param interaxialDistance defines distance between each color axis
  38487. * @param scene defines the hosting scene
  38488. */
  38489. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38490. /**
  38491. * Gets camera class name
  38492. * @returns AnaglyphArcRotateCamera
  38493. */
  38494. getClassName(): string;
  38495. }
  38496. }
  38497. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38498. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38499. import { Scene } from "babylonjs/scene";
  38500. import { Vector3 } from "babylonjs/Maths/math";
  38501. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38502. /**
  38503. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38504. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38505. */
  38506. export class AnaglyphFreeCamera extends FreeCamera {
  38507. /**
  38508. * Creates a new AnaglyphFreeCamera
  38509. * @param name defines camera name
  38510. * @param position defines initial position
  38511. * @param interaxialDistance defines distance between each color axis
  38512. * @param scene defines the hosting scene
  38513. */
  38514. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38515. /**
  38516. * Gets camera class name
  38517. * @returns AnaglyphFreeCamera
  38518. */
  38519. getClassName(): string;
  38520. }
  38521. }
  38522. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38523. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38524. import { Scene } from "babylonjs/scene";
  38525. import { Vector3 } from "babylonjs/Maths/math";
  38526. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38527. /**
  38528. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38529. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38530. */
  38531. export class AnaglyphGamepadCamera extends GamepadCamera {
  38532. /**
  38533. * Creates a new AnaglyphGamepadCamera
  38534. * @param name defines camera name
  38535. * @param position defines initial position
  38536. * @param interaxialDistance defines distance between each color axis
  38537. * @param scene defines the hosting scene
  38538. */
  38539. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38540. /**
  38541. * Gets camera class name
  38542. * @returns AnaglyphGamepadCamera
  38543. */
  38544. getClassName(): string;
  38545. }
  38546. }
  38547. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38548. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38549. import { Scene } from "babylonjs/scene";
  38550. import { Vector3 } from "babylonjs/Maths/math";
  38551. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38552. /**
  38553. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38554. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38555. */
  38556. export class AnaglyphUniversalCamera extends UniversalCamera {
  38557. /**
  38558. * Creates a new AnaglyphUniversalCamera
  38559. * @param name defines camera name
  38560. * @param position defines initial position
  38561. * @param interaxialDistance defines distance between each color axis
  38562. * @param scene defines the hosting scene
  38563. */
  38564. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38565. /**
  38566. * Gets camera class name
  38567. * @returns AnaglyphUniversalCamera
  38568. */
  38569. getClassName(): string;
  38570. }
  38571. }
  38572. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38573. /** @hidden */
  38574. export var stereoscopicInterlacePixelShader: {
  38575. name: string;
  38576. shader: string;
  38577. };
  38578. }
  38579. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38580. import { Camera } from "babylonjs/Cameras/camera";
  38581. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38582. import { Engine } from "babylonjs/Engines/engine";
  38583. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38584. /**
  38585. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38586. */
  38587. export class StereoscopicInterlacePostProcess extends PostProcess {
  38588. private _stepSize;
  38589. private _passedProcess;
  38590. /**
  38591. * Initializes a StereoscopicInterlacePostProcess
  38592. * @param name The name of the effect.
  38593. * @param rigCameras The rig cameras to be appled to the post process
  38594. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38596. * @param engine The engine which the post process will be applied. (default: current engine)
  38597. * @param reusable If the post process can be reused on the same frame. (default: false)
  38598. */
  38599. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38600. }
  38601. }
  38602. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38603. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38604. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38605. import { Scene } from "babylonjs/scene";
  38606. import { Vector3 } from "babylonjs/Maths/math";
  38607. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38608. /**
  38609. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38610. * @see http://doc.babylonjs.com/features/cameras
  38611. */
  38612. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38613. /**
  38614. * Creates a new StereoscopicArcRotateCamera
  38615. * @param name defines camera name
  38616. * @param alpha defines alpha angle (in radians)
  38617. * @param beta defines beta angle (in radians)
  38618. * @param radius defines radius
  38619. * @param target defines camera target
  38620. * @param interaxialDistance defines distance between each color axis
  38621. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38622. * @param scene defines the hosting scene
  38623. */
  38624. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38625. /**
  38626. * Gets camera class name
  38627. * @returns StereoscopicArcRotateCamera
  38628. */
  38629. getClassName(): string;
  38630. }
  38631. }
  38632. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38633. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38634. import { Scene } from "babylonjs/scene";
  38635. import { Vector3 } from "babylonjs/Maths/math";
  38636. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38637. /**
  38638. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38639. * @see http://doc.babylonjs.com/features/cameras
  38640. */
  38641. export class StereoscopicFreeCamera extends FreeCamera {
  38642. /**
  38643. * Creates a new StereoscopicFreeCamera
  38644. * @param name defines camera name
  38645. * @param position defines initial position
  38646. * @param interaxialDistance defines distance between each color axis
  38647. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38648. * @param scene defines the hosting scene
  38649. */
  38650. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38651. /**
  38652. * Gets camera class name
  38653. * @returns StereoscopicFreeCamera
  38654. */
  38655. getClassName(): string;
  38656. }
  38657. }
  38658. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38659. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38660. import { Scene } from "babylonjs/scene";
  38661. import { Vector3 } from "babylonjs/Maths/math";
  38662. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38663. /**
  38664. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38665. * @see http://doc.babylonjs.com/features/cameras
  38666. */
  38667. export class StereoscopicGamepadCamera extends GamepadCamera {
  38668. /**
  38669. * Creates a new StereoscopicGamepadCamera
  38670. * @param name defines camera name
  38671. * @param position defines initial position
  38672. * @param interaxialDistance defines distance between each color axis
  38673. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38674. * @param scene defines the hosting scene
  38675. */
  38676. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38677. /**
  38678. * Gets camera class name
  38679. * @returns StereoscopicGamepadCamera
  38680. */
  38681. getClassName(): string;
  38682. }
  38683. }
  38684. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38685. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38686. import { Scene } from "babylonjs/scene";
  38687. import { Vector3 } from "babylonjs/Maths/math";
  38688. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38689. /**
  38690. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38691. * @see http://doc.babylonjs.com/features/cameras
  38692. */
  38693. export class StereoscopicUniversalCamera extends UniversalCamera {
  38694. /**
  38695. * Creates a new StereoscopicUniversalCamera
  38696. * @param name defines camera name
  38697. * @param position defines initial position
  38698. * @param interaxialDistance defines distance between each color axis
  38699. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38700. * @param scene defines the hosting scene
  38701. */
  38702. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38703. /**
  38704. * Gets camera class name
  38705. * @returns StereoscopicUniversalCamera
  38706. */
  38707. getClassName(): string;
  38708. }
  38709. }
  38710. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38711. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38712. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38713. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38714. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38715. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38716. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38717. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38718. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38719. }
  38720. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38721. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38722. import { Scene } from "babylonjs/scene";
  38723. import { Vector3 } from "babylonjs/Maths/math";
  38724. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38725. /**
  38726. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38727. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38728. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38729. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38730. */
  38731. export class VirtualJoysticksCamera extends FreeCamera {
  38732. /**
  38733. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38734. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38735. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38736. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38737. * @param name Define the name of the camera in the scene
  38738. * @param position Define the start position of the camera in the scene
  38739. * @param scene Define the scene the camera belongs to
  38740. */
  38741. constructor(name: string, position: Vector3, scene: Scene);
  38742. /**
  38743. * Gets the current object class name.
  38744. * @return the class name
  38745. */
  38746. getClassName(): string;
  38747. }
  38748. }
  38749. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38750. import { Matrix } from "babylonjs/Maths/math";
  38751. /**
  38752. * This represents all the required metrics to create a VR camera.
  38753. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38754. */
  38755. export class VRCameraMetrics {
  38756. /**
  38757. * Define the horizontal resolution off the screen.
  38758. */
  38759. hResolution: number;
  38760. /**
  38761. * Define the vertical resolution off the screen.
  38762. */
  38763. vResolution: number;
  38764. /**
  38765. * Define the horizontal screen size.
  38766. */
  38767. hScreenSize: number;
  38768. /**
  38769. * Define the vertical screen size.
  38770. */
  38771. vScreenSize: number;
  38772. /**
  38773. * Define the vertical screen center position.
  38774. */
  38775. vScreenCenter: number;
  38776. /**
  38777. * Define the distance of the eyes to the screen.
  38778. */
  38779. eyeToScreenDistance: number;
  38780. /**
  38781. * Define the distance between both lenses
  38782. */
  38783. lensSeparationDistance: number;
  38784. /**
  38785. * Define the distance between both viewer's eyes.
  38786. */
  38787. interpupillaryDistance: number;
  38788. /**
  38789. * Define the distortion factor of the VR postprocess.
  38790. * Please, touch with care.
  38791. */
  38792. distortionK: number[];
  38793. /**
  38794. * Define the chromatic aberration correction factors for the VR post process.
  38795. */
  38796. chromaAbCorrection: number[];
  38797. /**
  38798. * Define the scale factor of the post process.
  38799. * The smaller the better but the slower.
  38800. */
  38801. postProcessScaleFactor: number;
  38802. /**
  38803. * Define an offset for the lens center.
  38804. */
  38805. lensCenterOffset: number;
  38806. /**
  38807. * Define if the current vr camera should compensate the distortion of the lense or not.
  38808. */
  38809. compensateDistortion: boolean;
  38810. /**
  38811. * Defines if multiview should be enabled when rendering (Default: false)
  38812. */
  38813. multiviewEnabled: boolean;
  38814. /**
  38815. * Gets the rendering aspect ratio based on the provided resolutions.
  38816. */
  38817. readonly aspectRatio: number;
  38818. /**
  38819. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38820. */
  38821. readonly aspectRatioFov: number;
  38822. /**
  38823. * @hidden
  38824. */
  38825. readonly leftHMatrix: Matrix;
  38826. /**
  38827. * @hidden
  38828. */
  38829. readonly rightHMatrix: Matrix;
  38830. /**
  38831. * @hidden
  38832. */
  38833. readonly leftPreViewMatrix: Matrix;
  38834. /**
  38835. * @hidden
  38836. */
  38837. readonly rightPreViewMatrix: Matrix;
  38838. /**
  38839. * Get the default VRMetrics based on the most generic setup.
  38840. * @returns the default vr metrics
  38841. */
  38842. static GetDefault(): VRCameraMetrics;
  38843. }
  38844. }
  38845. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38846. /** @hidden */
  38847. export var vrDistortionCorrectionPixelShader: {
  38848. name: string;
  38849. shader: string;
  38850. };
  38851. }
  38852. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38853. import { Camera } from "babylonjs/Cameras/camera";
  38854. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38855. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38856. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38857. /**
  38858. * VRDistortionCorrectionPostProcess used for mobile VR
  38859. */
  38860. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38861. private _isRightEye;
  38862. private _distortionFactors;
  38863. private _postProcessScaleFactor;
  38864. private _lensCenterOffset;
  38865. private _scaleIn;
  38866. private _scaleFactor;
  38867. private _lensCenter;
  38868. /**
  38869. * Initializes the VRDistortionCorrectionPostProcess
  38870. * @param name The name of the effect.
  38871. * @param camera The camera to apply the render pass to.
  38872. * @param isRightEye If this is for the right eye distortion
  38873. * @param vrMetrics All the required metrics for the VR camera
  38874. */
  38875. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38876. }
  38877. }
  38878. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38879. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38880. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38881. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38882. import { Scene } from "babylonjs/scene";
  38883. import { Vector3 } from "babylonjs/Maths/math";
  38884. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38885. import "babylonjs/Cameras/RigModes/vrRigMode";
  38886. /**
  38887. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38888. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38889. */
  38890. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38891. /**
  38892. * Creates a new VRDeviceOrientationArcRotateCamera
  38893. * @param name defines camera name
  38894. * @param alpha defines the camera rotation along the logitudinal axis
  38895. * @param beta defines the camera rotation along the latitudinal axis
  38896. * @param radius defines the camera distance from its target
  38897. * @param target defines the camera target
  38898. * @param scene defines the scene the camera belongs to
  38899. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38900. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38901. */
  38902. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38903. /**
  38904. * Gets camera class name
  38905. * @returns VRDeviceOrientationArcRotateCamera
  38906. */
  38907. getClassName(): string;
  38908. }
  38909. }
  38910. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38911. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38912. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38913. import { Scene } from "babylonjs/scene";
  38914. import { Vector3 } from "babylonjs/Maths/math";
  38915. import "babylonjs/Cameras/RigModes/vrRigMode";
  38916. /**
  38917. * Camera used to simulate VR rendering (based on FreeCamera)
  38918. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38919. */
  38920. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38921. /**
  38922. * Creates a new VRDeviceOrientationFreeCamera
  38923. * @param name defines camera name
  38924. * @param position defines the start position of the camera
  38925. * @param scene defines the scene the camera belongs to
  38926. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38927. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38928. */
  38929. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38930. /**
  38931. * Gets camera class name
  38932. * @returns VRDeviceOrientationFreeCamera
  38933. */
  38934. getClassName(): string;
  38935. }
  38936. }
  38937. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38938. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38939. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38940. import { Scene } from "babylonjs/scene";
  38941. import { Vector3 } from "babylonjs/Maths/math";
  38942. /**
  38943. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38944. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38945. */
  38946. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38947. /**
  38948. * Creates a new VRDeviceOrientationGamepadCamera
  38949. * @param name defines camera name
  38950. * @param position defines the start position of the camera
  38951. * @param scene defines the scene the camera belongs to
  38952. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38953. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38954. */
  38955. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38956. /**
  38957. * Gets camera class name
  38958. * @returns VRDeviceOrientationGamepadCamera
  38959. */
  38960. getClassName(): string;
  38961. }
  38962. }
  38963. declare module "babylonjs/Gamepads/xboxGamepad" {
  38964. import { Observable } from "babylonjs/Misc/observable";
  38965. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38966. /**
  38967. * Defines supported buttons for XBox360 compatible gamepads
  38968. */
  38969. export enum Xbox360Button {
  38970. /** A */
  38971. A = 0,
  38972. /** B */
  38973. B = 1,
  38974. /** X */
  38975. X = 2,
  38976. /** Y */
  38977. Y = 3,
  38978. /** Start */
  38979. Start = 4,
  38980. /** Back */
  38981. Back = 5,
  38982. /** Left button */
  38983. LB = 6,
  38984. /** Right button */
  38985. RB = 7,
  38986. /** Left stick */
  38987. LeftStick = 8,
  38988. /** Right stick */
  38989. RightStick = 9
  38990. }
  38991. /** Defines values for XBox360 DPad */
  38992. export enum Xbox360Dpad {
  38993. /** Up */
  38994. Up = 0,
  38995. /** Down */
  38996. Down = 1,
  38997. /** Left */
  38998. Left = 2,
  38999. /** Right */
  39000. Right = 3
  39001. }
  39002. /**
  39003. * Defines a XBox360 gamepad
  39004. */
  39005. export class Xbox360Pad extends Gamepad {
  39006. private _leftTrigger;
  39007. private _rightTrigger;
  39008. private _onlefttriggerchanged;
  39009. private _onrighttriggerchanged;
  39010. private _onbuttondown;
  39011. private _onbuttonup;
  39012. private _ondpaddown;
  39013. private _ondpadup;
  39014. /** Observable raised when a button is pressed */
  39015. onButtonDownObservable: Observable<Xbox360Button>;
  39016. /** Observable raised when a button is released */
  39017. onButtonUpObservable: Observable<Xbox360Button>;
  39018. /** Observable raised when a pad is pressed */
  39019. onPadDownObservable: Observable<Xbox360Dpad>;
  39020. /** Observable raised when a pad is released */
  39021. onPadUpObservable: Observable<Xbox360Dpad>;
  39022. private _buttonA;
  39023. private _buttonB;
  39024. private _buttonX;
  39025. private _buttonY;
  39026. private _buttonBack;
  39027. private _buttonStart;
  39028. private _buttonLB;
  39029. private _buttonRB;
  39030. private _buttonLeftStick;
  39031. private _buttonRightStick;
  39032. private _dPadUp;
  39033. private _dPadDown;
  39034. private _dPadLeft;
  39035. private _dPadRight;
  39036. private _isXboxOnePad;
  39037. /**
  39038. * Creates a new XBox360 gamepad object
  39039. * @param id defines the id of this gamepad
  39040. * @param index defines its index
  39041. * @param gamepad defines the internal HTML gamepad object
  39042. * @param xboxOne defines if it is a XBox One gamepad
  39043. */
  39044. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39045. /**
  39046. * Defines the callback to call when left trigger is pressed
  39047. * @param callback defines the callback to use
  39048. */
  39049. onlefttriggerchanged(callback: (value: number) => void): void;
  39050. /**
  39051. * Defines the callback to call when right trigger is pressed
  39052. * @param callback defines the callback to use
  39053. */
  39054. onrighttriggerchanged(callback: (value: number) => void): void;
  39055. /**
  39056. * Gets the left trigger value
  39057. */
  39058. /**
  39059. * Sets the left trigger value
  39060. */
  39061. leftTrigger: number;
  39062. /**
  39063. * Gets the right trigger value
  39064. */
  39065. /**
  39066. * Sets the right trigger value
  39067. */
  39068. rightTrigger: number;
  39069. /**
  39070. * Defines the callback to call when a button is pressed
  39071. * @param callback defines the callback to use
  39072. */
  39073. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39074. /**
  39075. * Defines the callback to call when a button is released
  39076. * @param callback defines the callback to use
  39077. */
  39078. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39079. /**
  39080. * Defines the callback to call when a pad is pressed
  39081. * @param callback defines the callback to use
  39082. */
  39083. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39084. /**
  39085. * Defines the callback to call when a pad is released
  39086. * @param callback defines the callback to use
  39087. */
  39088. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39089. private _setButtonValue;
  39090. private _setDPadValue;
  39091. /**
  39092. * Gets the value of the `A` button
  39093. */
  39094. /**
  39095. * Sets the value of the `A` button
  39096. */
  39097. buttonA: number;
  39098. /**
  39099. * Gets the value of the `B` button
  39100. */
  39101. /**
  39102. * Sets the value of the `B` button
  39103. */
  39104. buttonB: number;
  39105. /**
  39106. * Gets the value of the `X` button
  39107. */
  39108. /**
  39109. * Sets the value of the `X` button
  39110. */
  39111. buttonX: number;
  39112. /**
  39113. * Gets the value of the `Y` button
  39114. */
  39115. /**
  39116. * Sets the value of the `Y` button
  39117. */
  39118. buttonY: number;
  39119. /**
  39120. * Gets the value of the `Start` button
  39121. */
  39122. /**
  39123. * Sets the value of the `Start` button
  39124. */
  39125. buttonStart: number;
  39126. /**
  39127. * Gets the value of the `Back` button
  39128. */
  39129. /**
  39130. * Sets the value of the `Back` button
  39131. */
  39132. buttonBack: number;
  39133. /**
  39134. * Gets the value of the `Left` button
  39135. */
  39136. /**
  39137. * Sets the value of the `Left` button
  39138. */
  39139. buttonLB: number;
  39140. /**
  39141. * Gets the value of the `Right` button
  39142. */
  39143. /**
  39144. * Sets the value of the `Right` button
  39145. */
  39146. buttonRB: number;
  39147. /**
  39148. * Gets the value of the Left joystick
  39149. */
  39150. /**
  39151. * Sets the value of the Left joystick
  39152. */
  39153. buttonLeftStick: number;
  39154. /**
  39155. * Gets the value of the Right joystick
  39156. */
  39157. /**
  39158. * Sets the value of the Right joystick
  39159. */
  39160. buttonRightStick: number;
  39161. /**
  39162. * Gets the value of D-pad up
  39163. */
  39164. /**
  39165. * Sets the value of D-pad up
  39166. */
  39167. dPadUp: number;
  39168. /**
  39169. * Gets the value of D-pad down
  39170. */
  39171. /**
  39172. * Sets the value of D-pad down
  39173. */
  39174. dPadDown: number;
  39175. /**
  39176. * Gets the value of D-pad left
  39177. */
  39178. /**
  39179. * Sets the value of D-pad left
  39180. */
  39181. dPadLeft: number;
  39182. /**
  39183. * Gets the value of D-pad right
  39184. */
  39185. /**
  39186. * Sets the value of D-pad right
  39187. */
  39188. dPadRight: number;
  39189. /**
  39190. * Force the gamepad to synchronize with device values
  39191. */
  39192. update(): void;
  39193. /**
  39194. * Disposes the gamepad
  39195. */
  39196. dispose(): void;
  39197. }
  39198. }
  39199. declare module "babylonjs/Materials/pushMaterial" {
  39200. import { Nullable } from "babylonjs/types";
  39201. import { Scene } from "babylonjs/scene";
  39202. import { Matrix } from "babylonjs/Maths/math";
  39203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39204. import { Mesh } from "babylonjs/Meshes/mesh";
  39205. import { Material } from "babylonjs/Materials/material";
  39206. import { Effect } from "babylonjs/Materials/effect";
  39207. /**
  39208. * Base class of materials working in push mode in babylon JS
  39209. * @hidden
  39210. */
  39211. export class PushMaterial extends Material {
  39212. protected _activeEffect: Effect;
  39213. protected _normalMatrix: Matrix;
  39214. /**
  39215. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39216. * This means that the material can keep using a previous shader while a new one is being compiled.
  39217. * This is mostly used when shader parallel compilation is supported (true by default)
  39218. */
  39219. allowShaderHotSwapping: boolean;
  39220. constructor(name: string, scene: Scene);
  39221. getEffect(): Effect;
  39222. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39223. /**
  39224. * Binds the given world matrix to the active effect
  39225. *
  39226. * @param world the matrix to bind
  39227. */
  39228. bindOnlyWorldMatrix(world: Matrix): void;
  39229. /**
  39230. * Binds the given normal matrix to the active effect
  39231. *
  39232. * @param normalMatrix the matrix to bind
  39233. */
  39234. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39235. bind(world: Matrix, mesh?: Mesh): void;
  39236. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39237. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39238. }
  39239. }
  39240. declare module "babylonjs/Materials/materialFlags" {
  39241. /**
  39242. * This groups all the flags used to control the materials channel.
  39243. */
  39244. export class MaterialFlags {
  39245. private static _DiffuseTextureEnabled;
  39246. /**
  39247. * Are diffuse textures enabled in the application.
  39248. */
  39249. static DiffuseTextureEnabled: boolean;
  39250. private static _AmbientTextureEnabled;
  39251. /**
  39252. * Are ambient textures enabled in the application.
  39253. */
  39254. static AmbientTextureEnabled: boolean;
  39255. private static _OpacityTextureEnabled;
  39256. /**
  39257. * Are opacity textures enabled in the application.
  39258. */
  39259. static OpacityTextureEnabled: boolean;
  39260. private static _ReflectionTextureEnabled;
  39261. /**
  39262. * Are reflection textures enabled in the application.
  39263. */
  39264. static ReflectionTextureEnabled: boolean;
  39265. private static _EmissiveTextureEnabled;
  39266. /**
  39267. * Are emissive textures enabled in the application.
  39268. */
  39269. static EmissiveTextureEnabled: boolean;
  39270. private static _SpecularTextureEnabled;
  39271. /**
  39272. * Are specular textures enabled in the application.
  39273. */
  39274. static SpecularTextureEnabled: boolean;
  39275. private static _BumpTextureEnabled;
  39276. /**
  39277. * Are bump textures enabled in the application.
  39278. */
  39279. static BumpTextureEnabled: boolean;
  39280. private static _LightmapTextureEnabled;
  39281. /**
  39282. * Are lightmap textures enabled in the application.
  39283. */
  39284. static LightmapTextureEnabled: boolean;
  39285. private static _RefractionTextureEnabled;
  39286. /**
  39287. * Are refraction textures enabled in the application.
  39288. */
  39289. static RefractionTextureEnabled: boolean;
  39290. private static _ColorGradingTextureEnabled;
  39291. /**
  39292. * Are color grading textures enabled in the application.
  39293. */
  39294. static ColorGradingTextureEnabled: boolean;
  39295. private static _FresnelEnabled;
  39296. /**
  39297. * Are fresnels enabled in the application.
  39298. */
  39299. static FresnelEnabled: boolean;
  39300. private static _ClearCoatTextureEnabled;
  39301. /**
  39302. * Are clear coat textures enabled in the application.
  39303. */
  39304. static ClearCoatTextureEnabled: boolean;
  39305. private static _ClearCoatBumpTextureEnabled;
  39306. /**
  39307. * Are clear coat bump textures enabled in the application.
  39308. */
  39309. static ClearCoatBumpTextureEnabled: boolean;
  39310. private static _ClearCoatTintTextureEnabled;
  39311. /**
  39312. * Are clear coat tint textures enabled in the application.
  39313. */
  39314. static ClearCoatTintTextureEnabled: boolean;
  39315. private static _SheenTextureEnabled;
  39316. /**
  39317. * Are sheen textures enabled in the application.
  39318. */
  39319. static SheenTextureEnabled: boolean;
  39320. private static _AnisotropicTextureEnabled;
  39321. /**
  39322. * Are anisotropic textures enabled in the application.
  39323. */
  39324. static AnisotropicTextureEnabled: boolean;
  39325. private static _ThicknessTextureEnabled;
  39326. /**
  39327. * Are thickness textures enabled in the application.
  39328. */
  39329. static ThicknessTextureEnabled: boolean;
  39330. }
  39331. }
  39332. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39333. /** @hidden */
  39334. export var defaultFragmentDeclaration: {
  39335. name: string;
  39336. shader: string;
  39337. };
  39338. }
  39339. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39340. /** @hidden */
  39341. export var defaultUboDeclaration: {
  39342. name: string;
  39343. shader: string;
  39344. };
  39345. }
  39346. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39347. /** @hidden */
  39348. export var lightFragmentDeclaration: {
  39349. name: string;
  39350. shader: string;
  39351. };
  39352. }
  39353. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39354. /** @hidden */
  39355. export var lightUboDeclaration: {
  39356. name: string;
  39357. shader: string;
  39358. };
  39359. }
  39360. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39361. /** @hidden */
  39362. export var lightsFragmentFunctions: {
  39363. name: string;
  39364. shader: string;
  39365. };
  39366. }
  39367. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39368. /** @hidden */
  39369. export var shadowsFragmentFunctions: {
  39370. name: string;
  39371. shader: string;
  39372. };
  39373. }
  39374. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39375. /** @hidden */
  39376. export var fresnelFunction: {
  39377. name: string;
  39378. shader: string;
  39379. };
  39380. }
  39381. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39382. /** @hidden */
  39383. export var reflectionFunction: {
  39384. name: string;
  39385. shader: string;
  39386. };
  39387. }
  39388. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39389. /** @hidden */
  39390. export var bumpFragmentFunctions: {
  39391. name: string;
  39392. shader: string;
  39393. };
  39394. }
  39395. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39396. /** @hidden */
  39397. export var logDepthDeclaration: {
  39398. name: string;
  39399. shader: string;
  39400. };
  39401. }
  39402. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39403. /** @hidden */
  39404. export var bumpFragment: {
  39405. name: string;
  39406. shader: string;
  39407. };
  39408. }
  39409. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39410. /** @hidden */
  39411. export var depthPrePass: {
  39412. name: string;
  39413. shader: string;
  39414. };
  39415. }
  39416. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39417. /** @hidden */
  39418. export var lightFragment: {
  39419. name: string;
  39420. shader: string;
  39421. };
  39422. }
  39423. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39424. /** @hidden */
  39425. export var logDepthFragment: {
  39426. name: string;
  39427. shader: string;
  39428. };
  39429. }
  39430. declare module "babylonjs/Shaders/default.fragment" {
  39431. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39432. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39433. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39434. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39435. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39436. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39437. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39438. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39439. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39440. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39441. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39442. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39443. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39444. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39445. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39446. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39447. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39448. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39449. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39450. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39451. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39452. /** @hidden */
  39453. export var defaultPixelShader: {
  39454. name: string;
  39455. shader: string;
  39456. };
  39457. }
  39458. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39459. /** @hidden */
  39460. export var defaultVertexDeclaration: {
  39461. name: string;
  39462. shader: string;
  39463. };
  39464. }
  39465. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39466. /** @hidden */
  39467. export var bumpVertexDeclaration: {
  39468. name: string;
  39469. shader: string;
  39470. };
  39471. }
  39472. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39473. /** @hidden */
  39474. export var bumpVertex: {
  39475. name: string;
  39476. shader: string;
  39477. };
  39478. }
  39479. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39480. /** @hidden */
  39481. export var fogVertex: {
  39482. name: string;
  39483. shader: string;
  39484. };
  39485. }
  39486. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39487. /** @hidden */
  39488. export var shadowsVertex: {
  39489. name: string;
  39490. shader: string;
  39491. };
  39492. }
  39493. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39494. /** @hidden */
  39495. export var pointCloudVertex: {
  39496. name: string;
  39497. shader: string;
  39498. };
  39499. }
  39500. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39501. /** @hidden */
  39502. export var logDepthVertex: {
  39503. name: string;
  39504. shader: string;
  39505. };
  39506. }
  39507. declare module "babylonjs/Shaders/default.vertex" {
  39508. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39509. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39510. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39511. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39512. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39513. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39514. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39515. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39516. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39517. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39518. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39519. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39520. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39521. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39522. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39523. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39524. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39525. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39526. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39527. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39528. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39529. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39530. /** @hidden */
  39531. export var defaultVertexShader: {
  39532. name: string;
  39533. shader: string;
  39534. };
  39535. }
  39536. declare module "babylonjs/Materials/standardMaterial" {
  39537. import { SmartArray } from "babylonjs/Misc/smartArray";
  39538. import { IAnimatable } from "babylonjs/Misc/tools";
  39539. import { Nullable } from "babylonjs/types";
  39540. import { Scene } from "babylonjs/scene";
  39541. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39542. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39544. import { Mesh } from "babylonjs/Meshes/mesh";
  39545. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39546. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39547. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39548. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39549. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39551. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39552. import "babylonjs/Shaders/default.fragment";
  39553. import "babylonjs/Shaders/default.vertex";
  39554. /** @hidden */
  39555. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39556. MAINUV1: boolean;
  39557. MAINUV2: boolean;
  39558. DIFFUSE: boolean;
  39559. DIFFUSEDIRECTUV: number;
  39560. AMBIENT: boolean;
  39561. AMBIENTDIRECTUV: number;
  39562. OPACITY: boolean;
  39563. OPACITYDIRECTUV: number;
  39564. OPACITYRGB: boolean;
  39565. REFLECTION: boolean;
  39566. EMISSIVE: boolean;
  39567. EMISSIVEDIRECTUV: number;
  39568. SPECULAR: boolean;
  39569. SPECULARDIRECTUV: number;
  39570. BUMP: boolean;
  39571. BUMPDIRECTUV: number;
  39572. PARALLAX: boolean;
  39573. PARALLAXOCCLUSION: boolean;
  39574. SPECULAROVERALPHA: boolean;
  39575. CLIPPLANE: boolean;
  39576. CLIPPLANE2: boolean;
  39577. CLIPPLANE3: boolean;
  39578. CLIPPLANE4: boolean;
  39579. ALPHATEST: boolean;
  39580. DEPTHPREPASS: boolean;
  39581. ALPHAFROMDIFFUSE: boolean;
  39582. POINTSIZE: boolean;
  39583. FOG: boolean;
  39584. SPECULARTERM: boolean;
  39585. DIFFUSEFRESNEL: boolean;
  39586. OPACITYFRESNEL: boolean;
  39587. REFLECTIONFRESNEL: boolean;
  39588. REFRACTIONFRESNEL: boolean;
  39589. EMISSIVEFRESNEL: boolean;
  39590. FRESNEL: boolean;
  39591. NORMAL: boolean;
  39592. UV1: boolean;
  39593. UV2: boolean;
  39594. VERTEXCOLOR: boolean;
  39595. VERTEXALPHA: boolean;
  39596. NUM_BONE_INFLUENCERS: number;
  39597. BonesPerMesh: number;
  39598. BONETEXTURE: boolean;
  39599. INSTANCES: boolean;
  39600. GLOSSINESS: boolean;
  39601. ROUGHNESS: boolean;
  39602. EMISSIVEASILLUMINATION: boolean;
  39603. LINKEMISSIVEWITHDIFFUSE: boolean;
  39604. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39605. LIGHTMAP: boolean;
  39606. LIGHTMAPDIRECTUV: number;
  39607. OBJECTSPACE_NORMALMAP: boolean;
  39608. USELIGHTMAPASSHADOWMAP: boolean;
  39609. REFLECTIONMAP_3D: boolean;
  39610. REFLECTIONMAP_SPHERICAL: boolean;
  39611. REFLECTIONMAP_PLANAR: boolean;
  39612. REFLECTIONMAP_CUBIC: boolean;
  39613. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39614. REFLECTIONMAP_PROJECTION: boolean;
  39615. REFLECTIONMAP_SKYBOX: boolean;
  39616. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39617. REFLECTIONMAP_EXPLICIT: boolean;
  39618. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39619. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39620. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39621. INVERTCUBICMAP: boolean;
  39622. LOGARITHMICDEPTH: boolean;
  39623. REFRACTION: boolean;
  39624. REFRACTIONMAP_3D: boolean;
  39625. REFLECTIONOVERALPHA: boolean;
  39626. TWOSIDEDLIGHTING: boolean;
  39627. SHADOWFLOAT: boolean;
  39628. MORPHTARGETS: boolean;
  39629. MORPHTARGETS_NORMAL: boolean;
  39630. MORPHTARGETS_TANGENT: boolean;
  39631. NUM_MORPH_INFLUENCERS: number;
  39632. NONUNIFORMSCALING: boolean;
  39633. PREMULTIPLYALPHA: boolean;
  39634. IMAGEPROCESSING: boolean;
  39635. VIGNETTE: boolean;
  39636. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39637. VIGNETTEBLENDMODEOPAQUE: boolean;
  39638. TONEMAPPING: boolean;
  39639. TONEMAPPING_ACES: boolean;
  39640. CONTRAST: boolean;
  39641. COLORCURVES: boolean;
  39642. COLORGRADING: boolean;
  39643. COLORGRADING3D: boolean;
  39644. SAMPLER3DGREENDEPTH: boolean;
  39645. SAMPLER3DBGRMAP: boolean;
  39646. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39647. MULTIVIEW: boolean;
  39648. /**
  39649. * If the reflection texture on this material is in linear color space
  39650. * @hidden
  39651. */
  39652. IS_REFLECTION_LINEAR: boolean;
  39653. /**
  39654. * If the refraction texture on this material is in linear color space
  39655. * @hidden
  39656. */
  39657. IS_REFRACTION_LINEAR: boolean;
  39658. EXPOSURE: boolean;
  39659. constructor();
  39660. setReflectionMode(modeToEnable: string): void;
  39661. }
  39662. /**
  39663. * This is the default material used in Babylon. It is the best trade off between quality
  39664. * and performances.
  39665. * @see http://doc.babylonjs.com/babylon101/materials
  39666. */
  39667. export class StandardMaterial extends PushMaterial {
  39668. private _diffuseTexture;
  39669. /**
  39670. * The basic texture of the material as viewed under a light.
  39671. */
  39672. diffuseTexture: Nullable<BaseTexture>;
  39673. private _ambientTexture;
  39674. /**
  39675. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39676. */
  39677. ambientTexture: Nullable<BaseTexture>;
  39678. private _opacityTexture;
  39679. /**
  39680. * Define the transparency of the material from a texture.
  39681. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39682. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39683. */
  39684. opacityTexture: Nullable<BaseTexture>;
  39685. private _reflectionTexture;
  39686. /**
  39687. * Define the texture used to display the reflection.
  39688. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39689. */
  39690. reflectionTexture: Nullable<BaseTexture>;
  39691. private _emissiveTexture;
  39692. /**
  39693. * Define texture of the material as if self lit.
  39694. * This will be mixed in the final result even in the absence of light.
  39695. */
  39696. emissiveTexture: Nullable<BaseTexture>;
  39697. private _specularTexture;
  39698. /**
  39699. * Define how the color and intensity of the highlight given by the light in the material.
  39700. */
  39701. specularTexture: Nullable<BaseTexture>;
  39702. private _bumpTexture;
  39703. /**
  39704. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39705. * 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.
  39706. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39707. */
  39708. bumpTexture: Nullable<BaseTexture>;
  39709. private _lightmapTexture;
  39710. /**
  39711. * Complex lighting can be computationally expensive to compute at runtime.
  39712. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39713. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39714. */
  39715. lightmapTexture: Nullable<BaseTexture>;
  39716. private _refractionTexture;
  39717. /**
  39718. * Define the texture used to display the refraction.
  39719. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39720. */
  39721. refractionTexture: Nullable<BaseTexture>;
  39722. /**
  39723. * The color of the material lit by the environmental background lighting.
  39724. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39725. */
  39726. ambientColor: Color3;
  39727. /**
  39728. * The basic color of the material as viewed under a light.
  39729. */
  39730. diffuseColor: Color3;
  39731. /**
  39732. * Define how the color and intensity of the highlight given by the light in the material.
  39733. */
  39734. specularColor: Color3;
  39735. /**
  39736. * Define the color of the material as if self lit.
  39737. * This will be mixed in the final result even in the absence of light.
  39738. */
  39739. emissiveColor: Color3;
  39740. /**
  39741. * Defines how sharp are the highlights in the material.
  39742. * The bigger the value the sharper giving a more glossy feeling to the result.
  39743. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39744. */
  39745. specularPower: number;
  39746. private _useAlphaFromDiffuseTexture;
  39747. /**
  39748. * Does the transparency come from the diffuse texture alpha channel.
  39749. */
  39750. useAlphaFromDiffuseTexture: boolean;
  39751. private _useEmissiveAsIllumination;
  39752. /**
  39753. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39754. */
  39755. useEmissiveAsIllumination: boolean;
  39756. private _linkEmissiveWithDiffuse;
  39757. /**
  39758. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39759. * the emissive level when the final color is close to one.
  39760. */
  39761. linkEmissiveWithDiffuse: boolean;
  39762. private _useSpecularOverAlpha;
  39763. /**
  39764. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39765. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39766. */
  39767. useSpecularOverAlpha: boolean;
  39768. private _useReflectionOverAlpha;
  39769. /**
  39770. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39771. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39772. */
  39773. useReflectionOverAlpha: boolean;
  39774. private _disableLighting;
  39775. /**
  39776. * Does lights from the scene impacts this material.
  39777. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39778. */
  39779. disableLighting: boolean;
  39780. private _useObjectSpaceNormalMap;
  39781. /**
  39782. * Allows using an object space normal map (instead of tangent space).
  39783. */
  39784. useObjectSpaceNormalMap: boolean;
  39785. private _useParallax;
  39786. /**
  39787. * Is parallax enabled or not.
  39788. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39789. */
  39790. useParallax: boolean;
  39791. private _useParallaxOcclusion;
  39792. /**
  39793. * Is parallax occlusion enabled or not.
  39794. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39795. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39796. */
  39797. useParallaxOcclusion: boolean;
  39798. /**
  39799. * 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.
  39800. */
  39801. parallaxScaleBias: number;
  39802. private _roughness;
  39803. /**
  39804. * Helps to define how blurry the reflections should appears in the material.
  39805. */
  39806. roughness: number;
  39807. /**
  39808. * In case of refraction, define the value of the indice of refraction.
  39809. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39810. */
  39811. indexOfRefraction: number;
  39812. /**
  39813. * Invert the refraction texture alongside the y axis.
  39814. * It can be useful with procedural textures or probe for instance.
  39815. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39816. */
  39817. invertRefractionY: boolean;
  39818. /**
  39819. * Defines the alpha limits in alpha test mode.
  39820. */
  39821. alphaCutOff: number;
  39822. private _useLightmapAsShadowmap;
  39823. /**
  39824. * In case of light mapping, define whether the map contains light or shadow informations.
  39825. */
  39826. useLightmapAsShadowmap: boolean;
  39827. private _diffuseFresnelParameters;
  39828. /**
  39829. * Define the diffuse fresnel parameters of the material.
  39830. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39831. */
  39832. diffuseFresnelParameters: FresnelParameters;
  39833. private _opacityFresnelParameters;
  39834. /**
  39835. * Define the opacity fresnel parameters of the material.
  39836. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39837. */
  39838. opacityFresnelParameters: FresnelParameters;
  39839. private _reflectionFresnelParameters;
  39840. /**
  39841. * Define the reflection fresnel parameters of the material.
  39842. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39843. */
  39844. reflectionFresnelParameters: FresnelParameters;
  39845. private _refractionFresnelParameters;
  39846. /**
  39847. * Define the refraction fresnel parameters of the material.
  39848. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39849. */
  39850. refractionFresnelParameters: FresnelParameters;
  39851. private _emissiveFresnelParameters;
  39852. /**
  39853. * Define the emissive fresnel parameters of the material.
  39854. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39855. */
  39856. emissiveFresnelParameters: FresnelParameters;
  39857. private _useReflectionFresnelFromSpecular;
  39858. /**
  39859. * If true automatically deducts the fresnels values from the material specularity.
  39860. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39861. */
  39862. useReflectionFresnelFromSpecular: boolean;
  39863. private _useGlossinessFromSpecularMapAlpha;
  39864. /**
  39865. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39866. */
  39867. useGlossinessFromSpecularMapAlpha: boolean;
  39868. private _maxSimultaneousLights;
  39869. /**
  39870. * Defines the maximum number of lights that can be used in the material
  39871. */
  39872. maxSimultaneousLights: number;
  39873. private _invertNormalMapX;
  39874. /**
  39875. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39876. */
  39877. invertNormalMapX: boolean;
  39878. private _invertNormalMapY;
  39879. /**
  39880. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39881. */
  39882. invertNormalMapY: boolean;
  39883. private _twoSidedLighting;
  39884. /**
  39885. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39886. */
  39887. twoSidedLighting: boolean;
  39888. /**
  39889. * Default configuration related to image processing available in the standard Material.
  39890. */
  39891. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39892. /**
  39893. * Gets the image processing configuration used either in this material.
  39894. */
  39895. /**
  39896. * Sets the Default image processing configuration used either in the this material.
  39897. *
  39898. * If sets to null, the scene one is in use.
  39899. */
  39900. imageProcessingConfiguration: ImageProcessingConfiguration;
  39901. /**
  39902. * Keep track of the image processing observer to allow dispose and replace.
  39903. */
  39904. private _imageProcessingObserver;
  39905. /**
  39906. * Attaches a new image processing configuration to the Standard Material.
  39907. * @param configuration
  39908. */
  39909. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39910. /**
  39911. * Gets wether the color curves effect is enabled.
  39912. */
  39913. /**
  39914. * Sets wether the color curves effect is enabled.
  39915. */
  39916. cameraColorCurvesEnabled: boolean;
  39917. /**
  39918. * Gets wether the color grading effect is enabled.
  39919. */
  39920. /**
  39921. * Gets wether the color grading effect is enabled.
  39922. */
  39923. cameraColorGradingEnabled: boolean;
  39924. /**
  39925. * Gets wether tonemapping is enabled or not.
  39926. */
  39927. /**
  39928. * Sets wether tonemapping is enabled or not
  39929. */
  39930. cameraToneMappingEnabled: boolean;
  39931. /**
  39932. * The camera exposure used on this material.
  39933. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39934. * This corresponds to a photographic exposure.
  39935. */
  39936. /**
  39937. * The camera exposure used on this material.
  39938. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39939. * This corresponds to a photographic exposure.
  39940. */
  39941. cameraExposure: number;
  39942. /**
  39943. * Gets The camera contrast used on this material.
  39944. */
  39945. /**
  39946. * Sets The camera contrast used on this material.
  39947. */
  39948. cameraContrast: number;
  39949. /**
  39950. * Gets the Color Grading 2D Lookup Texture.
  39951. */
  39952. /**
  39953. * Sets the Color Grading 2D Lookup Texture.
  39954. */
  39955. cameraColorGradingTexture: Nullable<BaseTexture>;
  39956. /**
  39957. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39958. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39959. * 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;
  39960. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39961. */
  39962. /**
  39963. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39964. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39965. * 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;
  39966. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39967. */
  39968. cameraColorCurves: Nullable<ColorCurves>;
  39969. /**
  39970. * Custom callback helping to override the default shader used in the material.
  39971. */
  39972. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39973. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39974. protected _worldViewProjectionMatrix: Matrix;
  39975. protected _globalAmbientColor: Color3;
  39976. protected _useLogarithmicDepth: boolean;
  39977. /**
  39978. * Instantiates a new standard material.
  39979. * This is the default material used in Babylon. It is the best trade off between quality
  39980. * and performances.
  39981. * @see http://doc.babylonjs.com/babylon101/materials
  39982. * @param name Define the name of the material in the scene
  39983. * @param scene Define the scene the material belong to
  39984. */
  39985. constructor(name: string, scene: Scene);
  39986. /**
  39987. * Gets a boolean indicating that current material needs to register RTT
  39988. */
  39989. readonly hasRenderTargetTextures: boolean;
  39990. /**
  39991. * Gets the current class name of the material e.g. "StandardMaterial"
  39992. * Mainly use in serialization.
  39993. * @returns the class name
  39994. */
  39995. getClassName(): string;
  39996. /**
  39997. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39998. * You can try switching to logarithmic depth.
  39999. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40000. */
  40001. useLogarithmicDepth: boolean;
  40002. /**
  40003. * Specifies if the material will require alpha blending
  40004. * @returns a boolean specifying if alpha blending is needed
  40005. */
  40006. needAlphaBlending(): boolean;
  40007. /**
  40008. * Specifies if this material should be rendered in alpha test mode
  40009. * @returns a boolean specifying if an alpha test is needed.
  40010. */
  40011. needAlphaTesting(): boolean;
  40012. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40013. /**
  40014. * Get the texture used for alpha test purpose.
  40015. * @returns the diffuse texture in case of the standard material.
  40016. */
  40017. getAlphaTestTexture(): Nullable<BaseTexture>;
  40018. /**
  40019. * Get if the submesh is ready to be used and all its information available.
  40020. * Child classes can use it to update shaders
  40021. * @param mesh defines the mesh to check
  40022. * @param subMesh defines which submesh to check
  40023. * @param useInstances specifies that instances should be used
  40024. * @returns a boolean indicating that the submesh is ready or not
  40025. */
  40026. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40027. /**
  40028. * Builds the material UBO layouts.
  40029. * Used internally during the effect preparation.
  40030. */
  40031. buildUniformLayout(): void;
  40032. /**
  40033. * Unbinds the material from the mesh
  40034. */
  40035. unbind(): void;
  40036. /**
  40037. * Binds the submesh to this material by preparing the effect and shader to draw
  40038. * @param world defines the world transformation matrix
  40039. * @param mesh defines the mesh containing the submesh
  40040. * @param subMesh defines the submesh to bind the material to
  40041. */
  40042. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40043. /**
  40044. * Get the list of animatables in the material.
  40045. * @returns the list of animatables object used in the material
  40046. */
  40047. getAnimatables(): IAnimatable[];
  40048. /**
  40049. * Gets the active textures from the material
  40050. * @returns an array of textures
  40051. */
  40052. getActiveTextures(): BaseTexture[];
  40053. /**
  40054. * Specifies if the material uses a texture
  40055. * @param texture defines the texture to check against the material
  40056. * @returns a boolean specifying if the material uses the texture
  40057. */
  40058. hasTexture(texture: BaseTexture): boolean;
  40059. /**
  40060. * Disposes the material
  40061. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40062. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40063. */
  40064. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40065. /**
  40066. * Makes a duplicate of the material, and gives it a new name
  40067. * @param name defines the new name for the duplicated material
  40068. * @returns the cloned material
  40069. */
  40070. clone(name: string): StandardMaterial;
  40071. /**
  40072. * Serializes this material in a JSON representation
  40073. * @returns the serialized material object
  40074. */
  40075. serialize(): any;
  40076. /**
  40077. * Creates a standard material from parsed material data
  40078. * @param source defines the JSON representation of the material
  40079. * @param scene defines the hosting scene
  40080. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40081. * @returns a new standard material
  40082. */
  40083. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40084. /**
  40085. * Are diffuse textures enabled in the application.
  40086. */
  40087. static DiffuseTextureEnabled: boolean;
  40088. /**
  40089. * Are ambient textures enabled in the application.
  40090. */
  40091. static AmbientTextureEnabled: boolean;
  40092. /**
  40093. * Are opacity textures enabled in the application.
  40094. */
  40095. static OpacityTextureEnabled: boolean;
  40096. /**
  40097. * Are reflection textures enabled in the application.
  40098. */
  40099. static ReflectionTextureEnabled: boolean;
  40100. /**
  40101. * Are emissive textures enabled in the application.
  40102. */
  40103. static EmissiveTextureEnabled: boolean;
  40104. /**
  40105. * Are specular textures enabled in the application.
  40106. */
  40107. static SpecularTextureEnabled: boolean;
  40108. /**
  40109. * Are bump textures enabled in the application.
  40110. */
  40111. static BumpTextureEnabled: boolean;
  40112. /**
  40113. * Are lightmap textures enabled in the application.
  40114. */
  40115. static LightmapTextureEnabled: boolean;
  40116. /**
  40117. * Are refraction textures enabled in the application.
  40118. */
  40119. static RefractionTextureEnabled: boolean;
  40120. /**
  40121. * Are color grading textures enabled in the application.
  40122. */
  40123. static ColorGradingTextureEnabled: boolean;
  40124. /**
  40125. * Are fresnels enabled in the application.
  40126. */
  40127. static FresnelEnabled: boolean;
  40128. }
  40129. }
  40130. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40131. import { Scene } from "babylonjs/scene";
  40132. import { Texture } from "babylonjs/Materials/Textures/texture";
  40133. /**
  40134. * A class extending Texture allowing drawing on a texture
  40135. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40136. */
  40137. export class DynamicTexture extends Texture {
  40138. private _generateMipMaps;
  40139. private _canvas;
  40140. private _context;
  40141. private _engine;
  40142. /**
  40143. * Creates a DynamicTexture
  40144. * @param name defines the name of the texture
  40145. * @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
  40146. * @param scene defines the scene where you want the texture
  40147. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40148. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40149. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40150. */
  40151. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40152. /**
  40153. * Get the current class name of the texture useful for serialization or dynamic coding.
  40154. * @returns "DynamicTexture"
  40155. */
  40156. getClassName(): string;
  40157. /**
  40158. * Gets the current state of canRescale
  40159. */
  40160. readonly canRescale: boolean;
  40161. private _recreate;
  40162. /**
  40163. * Scales the texture
  40164. * @param ratio the scale factor to apply to both width and height
  40165. */
  40166. scale(ratio: number): void;
  40167. /**
  40168. * Resizes the texture
  40169. * @param width the new width
  40170. * @param height the new height
  40171. */
  40172. scaleTo(width: number, height: number): void;
  40173. /**
  40174. * Gets the context of the canvas used by the texture
  40175. * @returns the canvas context of the dynamic texture
  40176. */
  40177. getContext(): CanvasRenderingContext2D;
  40178. /**
  40179. * Clears the texture
  40180. */
  40181. clear(): void;
  40182. /**
  40183. * Updates the texture
  40184. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40185. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40186. */
  40187. update(invertY?: boolean, premulAlpha?: boolean): void;
  40188. /**
  40189. * Draws text onto the texture
  40190. * @param text defines the text to be drawn
  40191. * @param x defines the placement of the text from the left
  40192. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40193. * @param font defines the font to be used with font-style, font-size, font-name
  40194. * @param color defines the color used for the text
  40195. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40196. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40197. * @param update defines whether texture is immediately update (default is true)
  40198. */
  40199. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40200. /**
  40201. * Clones the texture
  40202. * @returns the clone of the texture.
  40203. */
  40204. clone(): DynamicTexture;
  40205. /**
  40206. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40207. * @returns a serialized dynamic texture object
  40208. */
  40209. serialize(): any;
  40210. /** @hidden */
  40211. _rebuild(): void;
  40212. }
  40213. }
  40214. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40215. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40216. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40217. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40218. /** @hidden */
  40219. export var imageProcessingPixelShader: {
  40220. name: string;
  40221. shader: string;
  40222. };
  40223. }
  40224. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40225. import { Nullable } from "babylonjs/types";
  40226. import { Color4 } from "babylonjs/Maths/math";
  40227. import { Camera } from "babylonjs/Cameras/camera";
  40228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40229. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40230. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40231. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40232. import { Engine } from "babylonjs/Engines/engine";
  40233. import "babylonjs/Shaders/imageProcessing.fragment";
  40234. import "babylonjs/Shaders/postprocess.vertex";
  40235. /**
  40236. * ImageProcessingPostProcess
  40237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40238. */
  40239. export class ImageProcessingPostProcess extends PostProcess {
  40240. /**
  40241. * Default configuration related to image processing available in the PBR Material.
  40242. */
  40243. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40244. /**
  40245. * Gets the image processing configuration used either in this material.
  40246. */
  40247. /**
  40248. * Sets the Default image processing configuration used either in the this material.
  40249. *
  40250. * If sets to null, the scene one is in use.
  40251. */
  40252. imageProcessingConfiguration: ImageProcessingConfiguration;
  40253. /**
  40254. * Keep track of the image processing observer to allow dispose and replace.
  40255. */
  40256. private _imageProcessingObserver;
  40257. /**
  40258. * Attaches a new image processing configuration to the PBR Material.
  40259. * @param configuration
  40260. */
  40261. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40262. /**
  40263. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40264. */
  40265. /**
  40266. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40267. */
  40268. colorCurves: Nullable<ColorCurves>;
  40269. /**
  40270. * Gets wether the color curves effect is enabled.
  40271. */
  40272. /**
  40273. * Sets wether the color curves effect is enabled.
  40274. */
  40275. colorCurvesEnabled: boolean;
  40276. /**
  40277. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40278. */
  40279. /**
  40280. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40281. */
  40282. colorGradingTexture: Nullable<BaseTexture>;
  40283. /**
  40284. * Gets wether the color grading effect is enabled.
  40285. */
  40286. /**
  40287. * Gets wether the color grading effect is enabled.
  40288. */
  40289. colorGradingEnabled: boolean;
  40290. /**
  40291. * Gets exposure used in the effect.
  40292. */
  40293. /**
  40294. * Sets exposure used in the effect.
  40295. */
  40296. exposure: number;
  40297. /**
  40298. * Gets wether tonemapping is enabled or not.
  40299. */
  40300. /**
  40301. * Sets wether tonemapping is enabled or not
  40302. */
  40303. toneMappingEnabled: boolean;
  40304. /**
  40305. * Gets the type of tone mapping effect.
  40306. */
  40307. /**
  40308. * Sets the type of tone mapping effect.
  40309. */
  40310. toneMappingType: number;
  40311. /**
  40312. * Gets contrast used in the effect.
  40313. */
  40314. /**
  40315. * Sets contrast used in the effect.
  40316. */
  40317. contrast: number;
  40318. /**
  40319. * Gets Vignette stretch size.
  40320. */
  40321. /**
  40322. * Sets Vignette stretch size.
  40323. */
  40324. vignetteStretch: number;
  40325. /**
  40326. * Gets Vignette centre X Offset.
  40327. */
  40328. /**
  40329. * Sets Vignette centre X Offset.
  40330. */
  40331. vignetteCentreX: number;
  40332. /**
  40333. * Gets Vignette centre Y Offset.
  40334. */
  40335. /**
  40336. * Sets Vignette centre Y Offset.
  40337. */
  40338. vignetteCentreY: number;
  40339. /**
  40340. * Gets Vignette weight or intensity of the vignette effect.
  40341. */
  40342. /**
  40343. * Sets Vignette weight or intensity of the vignette effect.
  40344. */
  40345. vignetteWeight: number;
  40346. /**
  40347. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40348. * if vignetteEnabled is set to true.
  40349. */
  40350. /**
  40351. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40352. * if vignetteEnabled is set to true.
  40353. */
  40354. vignetteColor: Color4;
  40355. /**
  40356. * Gets Camera field of view used by the Vignette effect.
  40357. */
  40358. /**
  40359. * Sets Camera field of view used by the Vignette effect.
  40360. */
  40361. vignetteCameraFov: number;
  40362. /**
  40363. * Gets the vignette blend mode allowing different kind of effect.
  40364. */
  40365. /**
  40366. * Sets the vignette blend mode allowing different kind of effect.
  40367. */
  40368. vignetteBlendMode: number;
  40369. /**
  40370. * Gets wether the vignette effect is enabled.
  40371. */
  40372. /**
  40373. * Sets wether the vignette effect is enabled.
  40374. */
  40375. vignetteEnabled: boolean;
  40376. private _fromLinearSpace;
  40377. /**
  40378. * Gets wether the input of the processing is in Gamma or Linear Space.
  40379. */
  40380. /**
  40381. * Sets wether the input of the processing is in Gamma or Linear Space.
  40382. */
  40383. fromLinearSpace: boolean;
  40384. /**
  40385. * Defines cache preventing GC.
  40386. */
  40387. private _defines;
  40388. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40389. /**
  40390. * "ImageProcessingPostProcess"
  40391. * @returns "ImageProcessingPostProcess"
  40392. */
  40393. getClassName(): string;
  40394. protected _updateParameters(): void;
  40395. dispose(camera?: Camera): void;
  40396. }
  40397. }
  40398. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40399. import { Scene } from "babylonjs/scene";
  40400. import { Color3 } from "babylonjs/Maths/math";
  40401. import { Mesh } from "babylonjs/Meshes/mesh";
  40402. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40403. import { Nullable } from "babylonjs/types";
  40404. /**
  40405. * Class containing static functions to help procedurally build meshes
  40406. */
  40407. export class GroundBuilder {
  40408. /**
  40409. * Creates a ground mesh
  40410. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40411. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40413. * @param name defines the name of the mesh
  40414. * @param options defines the options used to create the mesh
  40415. * @param scene defines the hosting scene
  40416. * @returns the ground mesh
  40417. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40418. */
  40419. static CreateGround(name: string, options: {
  40420. width?: number;
  40421. height?: number;
  40422. subdivisions?: number;
  40423. subdivisionsX?: number;
  40424. subdivisionsY?: number;
  40425. updatable?: boolean;
  40426. }, scene: any): Mesh;
  40427. /**
  40428. * Creates a tiled ground mesh
  40429. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40430. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40431. * * 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
  40432. * * 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
  40433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40434. * @param name defines the name of the mesh
  40435. * @param options defines the options used to create the mesh
  40436. * @param scene defines the hosting scene
  40437. * @returns the tiled ground mesh
  40438. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40439. */
  40440. static CreateTiledGround(name: string, options: {
  40441. xmin: number;
  40442. zmin: number;
  40443. xmax: number;
  40444. zmax: number;
  40445. subdivisions?: {
  40446. w: number;
  40447. h: number;
  40448. };
  40449. precision?: {
  40450. w: number;
  40451. h: number;
  40452. };
  40453. updatable?: boolean;
  40454. }, scene?: Nullable<Scene>): Mesh;
  40455. /**
  40456. * Creates a ground mesh from a height map
  40457. * * The parameter `url` sets the URL of the height map image resource.
  40458. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40459. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40460. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40461. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40462. * * 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.
  40463. * * 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).
  40464. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40466. * @param name defines the name of the mesh
  40467. * @param url defines the url to the height map
  40468. * @param options defines the options used to create the mesh
  40469. * @param scene defines the hosting scene
  40470. * @returns the ground mesh
  40471. * @see https://doc.babylonjs.com/babylon101/height_map
  40472. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40473. */
  40474. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40475. width?: number;
  40476. height?: number;
  40477. subdivisions?: number;
  40478. minHeight?: number;
  40479. maxHeight?: number;
  40480. colorFilter?: Color3;
  40481. alphaFilter?: number;
  40482. updatable?: boolean;
  40483. onReady?: (mesh: GroundMesh) => void;
  40484. }, scene?: Nullable<Scene>): GroundMesh;
  40485. }
  40486. }
  40487. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40488. import { Vector4 } from "babylonjs/Maths/math";
  40489. import { Mesh } from "babylonjs/Meshes/mesh";
  40490. /**
  40491. * Class containing static functions to help procedurally build meshes
  40492. */
  40493. export class TorusBuilder {
  40494. /**
  40495. * Creates a torus mesh
  40496. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40497. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40498. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40502. * @param name defines the name of the mesh
  40503. * @param options defines the options used to create the mesh
  40504. * @param scene defines the hosting scene
  40505. * @returns the torus mesh
  40506. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40507. */
  40508. static CreateTorus(name: string, options: {
  40509. diameter?: number;
  40510. thickness?: number;
  40511. tessellation?: number;
  40512. updatable?: boolean;
  40513. sideOrientation?: number;
  40514. frontUVs?: Vector4;
  40515. backUVs?: Vector4;
  40516. }, scene: any): Mesh;
  40517. }
  40518. }
  40519. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40520. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40521. import { Mesh } from "babylonjs/Meshes/mesh";
  40522. /**
  40523. * Class containing static functions to help procedurally build meshes
  40524. */
  40525. export class CylinderBuilder {
  40526. /**
  40527. * Creates a cylinder or a cone mesh
  40528. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40529. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40530. * * 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.
  40531. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40532. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40533. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40534. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40535. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40536. * * 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).
  40537. * * 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
  40538. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40539. * * 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
  40540. * * 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.
  40541. * * If `enclose` is false, a ring surface is one element.
  40542. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40543. * * 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
  40544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40547. * @param name defines the name of the mesh
  40548. * @param options defines the options used to create the mesh
  40549. * @param scene defines the hosting scene
  40550. * @returns the cylinder mesh
  40551. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40552. */
  40553. static CreateCylinder(name: string, options: {
  40554. height?: number;
  40555. diameterTop?: number;
  40556. diameterBottom?: number;
  40557. diameter?: number;
  40558. tessellation?: number;
  40559. subdivisions?: number;
  40560. arc?: number;
  40561. faceColors?: Color4[];
  40562. faceUV?: Vector4[];
  40563. updatable?: boolean;
  40564. hasRings?: boolean;
  40565. enclose?: boolean;
  40566. sideOrientation?: number;
  40567. frontUVs?: Vector4;
  40568. backUVs?: Vector4;
  40569. }, scene: any): Mesh;
  40570. }
  40571. }
  40572. declare module "babylonjs/Gamepads/gamepadManager" {
  40573. import { Observable } from "babylonjs/Misc/observable";
  40574. import { Nullable } from "babylonjs/types";
  40575. import { Scene } from "babylonjs/scene";
  40576. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40577. /**
  40578. * Manager for handling gamepads
  40579. */
  40580. export class GamepadManager {
  40581. private _scene?;
  40582. private _babylonGamepads;
  40583. private _oneGamepadConnected;
  40584. /** @hidden */
  40585. _isMonitoring: boolean;
  40586. private _gamepadEventSupported;
  40587. private _gamepadSupport;
  40588. /**
  40589. * observable to be triggered when the gamepad controller has been connected
  40590. */
  40591. onGamepadConnectedObservable: Observable<Gamepad>;
  40592. /**
  40593. * observable to be triggered when the gamepad controller has been disconnected
  40594. */
  40595. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40596. private _onGamepadConnectedEvent;
  40597. private _onGamepadDisconnectedEvent;
  40598. /**
  40599. * Initializes the gamepad manager
  40600. * @param _scene BabylonJS scene
  40601. */
  40602. constructor(_scene?: Scene | undefined);
  40603. /**
  40604. * The gamepads in the game pad manager
  40605. */
  40606. readonly gamepads: Gamepad[];
  40607. /**
  40608. * Get the gamepad controllers based on type
  40609. * @param type The type of gamepad controller
  40610. * @returns Nullable gamepad
  40611. */
  40612. getGamepadByType(type?: number): Nullable<Gamepad>;
  40613. /**
  40614. * Disposes the gamepad manager
  40615. */
  40616. dispose(): void;
  40617. private _addNewGamepad;
  40618. private _startMonitoringGamepads;
  40619. private _stopMonitoringGamepads;
  40620. /** @hidden */
  40621. _checkGamepadsStatus(): void;
  40622. private _updateGamepadObjects;
  40623. }
  40624. }
  40625. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40626. import { Nullable } from "babylonjs/types";
  40627. import { Scene } from "babylonjs/scene";
  40628. import { ISceneComponent } from "babylonjs/sceneComponent";
  40629. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40630. module "babylonjs/scene" {
  40631. interface Scene {
  40632. /** @hidden */
  40633. _gamepadManager: Nullable<GamepadManager>;
  40634. /**
  40635. * Gets the gamepad manager associated with the scene
  40636. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40637. */
  40638. gamepadManager: GamepadManager;
  40639. }
  40640. }
  40641. module "babylonjs/Cameras/freeCameraInputsManager" {
  40642. /**
  40643. * Interface representing a free camera inputs manager
  40644. */
  40645. interface FreeCameraInputsManager {
  40646. /**
  40647. * Adds gamepad input support to the FreeCameraInputsManager.
  40648. * @returns the FreeCameraInputsManager
  40649. */
  40650. addGamepad(): FreeCameraInputsManager;
  40651. }
  40652. }
  40653. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40654. /**
  40655. * Interface representing an arc rotate camera inputs manager
  40656. */
  40657. interface ArcRotateCameraInputsManager {
  40658. /**
  40659. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40660. * @returns the camera inputs manager
  40661. */
  40662. addGamepad(): ArcRotateCameraInputsManager;
  40663. }
  40664. }
  40665. /**
  40666. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40667. */
  40668. export class GamepadSystemSceneComponent implements ISceneComponent {
  40669. /**
  40670. * The component name helpfull to identify the component in the list of scene components.
  40671. */
  40672. readonly name: string;
  40673. /**
  40674. * The scene the component belongs to.
  40675. */
  40676. scene: Scene;
  40677. /**
  40678. * Creates a new instance of the component for the given scene
  40679. * @param scene Defines the scene to register the component in
  40680. */
  40681. constructor(scene: Scene);
  40682. /**
  40683. * Registers the component in a given scene
  40684. */
  40685. register(): void;
  40686. /**
  40687. * Rebuilds the elements related to this component in case of
  40688. * context lost for instance.
  40689. */
  40690. rebuild(): void;
  40691. /**
  40692. * Disposes the component and the associated ressources
  40693. */
  40694. dispose(): void;
  40695. private _beforeCameraUpdate;
  40696. }
  40697. }
  40698. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40699. import { Observable } from "babylonjs/Misc/observable";
  40700. import { Nullable } from "babylonjs/types";
  40701. import { Camera } from "babylonjs/Cameras/camera";
  40702. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40703. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40704. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40705. import { Scene } from "babylonjs/scene";
  40706. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40707. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40709. import { Mesh } from "babylonjs/Meshes/mesh";
  40710. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40711. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40712. import "babylonjs/Meshes/Builders/groundBuilder";
  40713. import "babylonjs/Meshes/Builders/torusBuilder";
  40714. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40715. import "babylonjs/Gamepads/gamepadSceneComponent";
  40716. import "babylonjs/Animations/animatable";
  40717. /**
  40718. * Options to modify the vr teleportation behavior.
  40719. */
  40720. export interface VRTeleportationOptions {
  40721. /**
  40722. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40723. */
  40724. floorMeshName?: string;
  40725. /**
  40726. * A list of meshes to be used as the teleportation floor. (default: empty)
  40727. */
  40728. floorMeshes?: Mesh[];
  40729. }
  40730. /**
  40731. * Options to modify the vr experience helper's behavior.
  40732. */
  40733. export interface VRExperienceHelperOptions extends WebVROptions {
  40734. /**
  40735. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40736. */
  40737. createDeviceOrientationCamera?: boolean;
  40738. /**
  40739. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40740. */
  40741. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40742. /**
  40743. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40744. */
  40745. laserToggle?: boolean;
  40746. /**
  40747. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40748. */
  40749. floorMeshes?: Mesh[];
  40750. /**
  40751. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40752. */
  40753. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40754. }
  40755. /**
  40756. * Event containing information after VR has been entered
  40757. */
  40758. export class OnAfterEnteringVRObservableEvent {
  40759. /**
  40760. * If entering vr was successful
  40761. */
  40762. success: boolean;
  40763. }
  40764. /**
  40765. * Helps to quickly add VR support to an existing scene.
  40766. * See http://doc.babylonjs.com/how_to/webvr_helper
  40767. */
  40768. export class VRExperienceHelper {
  40769. /** Options to modify the vr experience helper's behavior. */
  40770. webVROptions: VRExperienceHelperOptions;
  40771. private _scene;
  40772. private _position;
  40773. private _btnVR;
  40774. private _btnVRDisplayed;
  40775. private _webVRsupported;
  40776. private _webVRready;
  40777. private _webVRrequesting;
  40778. private _webVRpresenting;
  40779. private _hasEnteredVR;
  40780. private _fullscreenVRpresenting;
  40781. private _canvas;
  40782. private _webVRCamera;
  40783. private _vrDeviceOrientationCamera;
  40784. private _deviceOrientationCamera;
  40785. private _existingCamera;
  40786. private _onKeyDown;
  40787. private _onVrDisplayPresentChange;
  40788. private _onVRDisplayChanged;
  40789. private _onVRRequestPresentStart;
  40790. private _onVRRequestPresentComplete;
  40791. /**
  40792. * Observable raised right before entering VR.
  40793. */
  40794. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40795. /**
  40796. * Observable raised when entering VR has completed.
  40797. */
  40798. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40799. /**
  40800. * Observable raised when exiting VR.
  40801. */
  40802. onExitingVRObservable: Observable<VRExperienceHelper>;
  40803. /**
  40804. * Observable raised when controller mesh is loaded.
  40805. */
  40806. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40807. /** Return this.onEnteringVRObservable
  40808. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40809. */
  40810. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40811. /** Return this.onExitingVRObservable
  40812. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40813. */
  40814. readonly onExitingVR: Observable<VRExperienceHelper>;
  40815. /** Return this.onControllerMeshLoadedObservable
  40816. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40817. */
  40818. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40819. private _rayLength;
  40820. private _useCustomVRButton;
  40821. private _teleportationRequested;
  40822. private _teleportActive;
  40823. private _floorMeshName;
  40824. private _floorMeshesCollection;
  40825. private _rotationAllowed;
  40826. private _teleportBackwardsVector;
  40827. private _teleportationTarget;
  40828. private _isDefaultTeleportationTarget;
  40829. private _postProcessMove;
  40830. private _teleportationFillColor;
  40831. private _teleportationBorderColor;
  40832. private _rotationAngle;
  40833. private _haloCenter;
  40834. private _cameraGazer;
  40835. private _padSensibilityUp;
  40836. private _padSensibilityDown;
  40837. private _leftController;
  40838. private _rightController;
  40839. /**
  40840. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40841. */
  40842. onNewMeshSelected: Observable<AbstractMesh>;
  40843. /**
  40844. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40845. */
  40846. onNewMeshPicked: Observable<PickingInfo>;
  40847. private _circleEase;
  40848. /**
  40849. * Observable raised before camera teleportation
  40850. */
  40851. onBeforeCameraTeleport: Observable<Vector3>;
  40852. /**
  40853. * Observable raised after camera teleportation
  40854. */
  40855. onAfterCameraTeleport: Observable<Vector3>;
  40856. /**
  40857. * Observable raised when current selected mesh gets unselected
  40858. */
  40859. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40860. private _raySelectionPredicate;
  40861. /**
  40862. * To be optionaly changed by user to define custom ray selection
  40863. */
  40864. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40865. /**
  40866. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40867. */
  40868. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40869. /**
  40870. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40871. */
  40872. teleportationEnabled: boolean;
  40873. private _defaultHeight;
  40874. private _teleportationInitialized;
  40875. private _interactionsEnabled;
  40876. private _interactionsRequested;
  40877. private _displayGaze;
  40878. private _displayLaserPointer;
  40879. /**
  40880. * The mesh used to display where the user is going to teleport.
  40881. */
  40882. /**
  40883. * Sets the mesh to be used to display where the user is going to teleport.
  40884. */
  40885. teleportationTarget: Mesh;
  40886. /**
  40887. * 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
  40888. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40889. * See http://doc.babylonjs.com/resources/baking_transformations
  40890. */
  40891. gazeTrackerMesh: Mesh;
  40892. /**
  40893. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40894. */
  40895. updateGazeTrackerScale: boolean;
  40896. /**
  40897. * If the gaze trackers color should be updated when selecting meshes
  40898. */
  40899. updateGazeTrackerColor: boolean;
  40900. /**
  40901. * The gaze tracking mesh corresponding to the left controller
  40902. */
  40903. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40904. /**
  40905. * The gaze tracking mesh corresponding to the right controller
  40906. */
  40907. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40908. /**
  40909. * If the ray of the gaze should be displayed.
  40910. */
  40911. /**
  40912. * Sets if the ray of the gaze should be displayed.
  40913. */
  40914. displayGaze: boolean;
  40915. /**
  40916. * If the ray of the LaserPointer should be displayed.
  40917. */
  40918. /**
  40919. * Sets if the ray of the LaserPointer should be displayed.
  40920. */
  40921. displayLaserPointer: boolean;
  40922. /**
  40923. * The deviceOrientationCamera used as the camera when not in VR.
  40924. */
  40925. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40926. /**
  40927. * Based on the current WebVR support, returns the current VR camera used.
  40928. */
  40929. readonly currentVRCamera: Nullable<Camera>;
  40930. /**
  40931. * The webVRCamera which is used when in VR.
  40932. */
  40933. readonly webVRCamera: WebVRFreeCamera;
  40934. /**
  40935. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40936. */
  40937. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40938. private readonly _teleportationRequestInitiated;
  40939. /**
  40940. * Defines wether or not Pointer lock should be requested when switching to
  40941. * full screen.
  40942. */
  40943. requestPointerLockOnFullScreen: boolean;
  40944. /**
  40945. * Instantiates a VRExperienceHelper.
  40946. * Helps to quickly add VR support to an existing scene.
  40947. * @param scene The scene the VRExperienceHelper belongs to.
  40948. * @param webVROptions Options to modify the vr experience helper's behavior.
  40949. */
  40950. constructor(scene: Scene,
  40951. /** Options to modify the vr experience helper's behavior. */
  40952. webVROptions?: VRExperienceHelperOptions);
  40953. private _onDefaultMeshLoaded;
  40954. private _onResize;
  40955. private _onFullscreenChange;
  40956. /**
  40957. * Gets a value indicating if we are currently in VR mode.
  40958. */
  40959. readonly isInVRMode: boolean;
  40960. private onVrDisplayPresentChange;
  40961. private onVRDisplayChanged;
  40962. private moveButtonToBottomRight;
  40963. private displayVRButton;
  40964. private updateButtonVisibility;
  40965. private _cachedAngularSensibility;
  40966. /**
  40967. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40968. * Otherwise, will use the fullscreen API.
  40969. */
  40970. enterVR(): void;
  40971. /**
  40972. * Attempt to exit VR, or fullscreen.
  40973. */
  40974. exitVR(): void;
  40975. /**
  40976. * The position of the vr experience helper.
  40977. */
  40978. /**
  40979. * Sets the position of the vr experience helper.
  40980. */
  40981. position: Vector3;
  40982. /**
  40983. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40984. */
  40985. enableInteractions(): void;
  40986. private readonly _noControllerIsActive;
  40987. private beforeRender;
  40988. private _isTeleportationFloor;
  40989. /**
  40990. * Adds a floor mesh to be used for teleportation.
  40991. * @param floorMesh the mesh to be used for teleportation.
  40992. */
  40993. addFloorMesh(floorMesh: Mesh): void;
  40994. /**
  40995. * Removes a floor mesh from being used for teleportation.
  40996. * @param floorMesh the mesh to be removed.
  40997. */
  40998. removeFloorMesh(floorMesh: Mesh): void;
  40999. /**
  41000. * Enables interactions and teleportation using the VR controllers and gaze.
  41001. * @param vrTeleportationOptions options to modify teleportation behavior.
  41002. */
  41003. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41004. private _onNewGamepadConnected;
  41005. private _tryEnableInteractionOnController;
  41006. private _onNewGamepadDisconnected;
  41007. private _enableInteractionOnController;
  41008. private _checkTeleportWithRay;
  41009. private _checkRotate;
  41010. private _checkTeleportBackwards;
  41011. private _enableTeleportationOnController;
  41012. private _createTeleportationCircles;
  41013. private _displayTeleportationTarget;
  41014. private _hideTeleportationTarget;
  41015. private _rotateCamera;
  41016. private _moveTeleportationSelectorTo;
  41017. private _workingVector;
  41018. private _workingQuaternion;
  41019. private _workingMatrix;
  41020. /**
  41021. * Teleports the users feet to the desired location
  41022. * @param location The location where the user's feet should be placed
  41023. */
  41024. teleportCamera(location: Vector3): void;
  41025. private _convertNormalToDirectionOfRay;
  41026. private _castRayAndSelectObject;
  41027. private _notifySelectedMeshUnselected;
  41028. /**
  41029. * Sets the color of the laser ray from the vr controllers.
  41030. * @param color new color for the ray.
  41031. */
  41032. changeLaserColor(color: Color3): void;
  41033. /**
  41034. * Sets the color of the ray from the vr headsets gaze.
  41035. * @param color new color for the ray.
  41036. */
  41037. changeGazeColor(color: Color3): void;
  41038. /**
  41039. * Exits VR and disposes of the vr experience helper
  41040. */
  41041. dispose(): void;
  41042. /**
  41043. * Gets the name of the VRExperienceHelper class
  41044. * @returns "VRExperienceHelper"
  41045. */
  41046. getClassName(): string;
  41047. }
  41048. }
  41049. declare module "babylonjs/Cameras/VR/index" {
  41050. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41051. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41052. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41053. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41054. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41055. export * from "babylonjs/Cameras/VR/webVRCamera";
  41056. }
  41057. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41058. import { Observable } from "babylonjs/Misc/observable";
  41059. import { Nullable } from "babylonjs/types";
  41060. import { IDisposable, Scene } from "babylonjs/scene";
  41061. import { Vector3 } from "babylonjs/Maths/math";
  41062. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41063. import { Ray } from "babylonjs/Culling/ray";
  41064. /**
  41065. * Manages an XRSession
  41066. * @see https://doc.babylonjs.com/how_to/webxr
  41067. */
  41068. export class WebXRSessionManager implements IDisposable {
  41069. private scene;
  41070. /**
  41071. * Fires every time a new xrFrame arrives which can be used to update the camera
  41072. */
  41073. onXRFrameObservable: Observable<any>;
  41074. /**
  41075. * Fires when the xr session is ended either by the device or manually done
  41076. */
  41077. onXRSessionEnded: Observable<any>;
  41078. /** @hidden */
  41079. _xrSession: XRSession;
  41080. /** @hidden */
  41081. _frameOfReference: XRFrameOfReference;
  41082. /** @hidden */
  41083. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41084. /** @hidden */
  41085. _currentXRFrame: Nullable<XRFrame>;
  41086. private _xrNavigator;
  41087. private _xrDevice;
  41088. private _tmpMatrix;
  41089. /**
  41090. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41091. * @param scene The scene which the session should be created for
  41092. */
  41093. constructor(scene: Scene);
  41094. /**
  41095. * Initializes the manager
  41096. * After initialization enterXR can be called to start an XR session
  41097. * @returns Promise which resolves after it is initialized
  41098. */
  41099. initializeAsync(): Promise<void>;
  41100. /**
  41101. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41102. * @param sessionCreationOptions xr options to create the session with
  41103. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41104. * @returns Promise which resolves after it enters XR
  41105. */
  41106. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41107. /**
  41108. * Stops the xrSession and restores the renderloop
  41109. * @returns Promise which resolves after it exits XR
  41110. */
  41111. exitXRAsync(): Promise<void>;
  41112. /**
  41113. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41114. * @param ray ray to cast into the environment
  41115. * @returns Promise which resolves with a collision point in the environment if it exists
  41116. */
  41117. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41118. /**
  41119. * Checks if a session would be supported for the creation options specified
  41120. * @param options creation options to check if they are supported
  41121. * @returns true if supported
  41122. */
  41123. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41124. /**
  41125. * @hidden
  41126. * Converts the render layer of xrSession to a render target
  41127. * @param session session to create render target for
  41128. * @param scene scene the new render target should be created for
  41129. */
  41130. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41131. /**
  41132. * Disposes of the session manager
  41133. */
  41134. dispose(): void;
  41135. }
  41136. }
  41137. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41138. import { Scene } from "babylonjs/scene";
  41139. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41140. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41141. /**
  41142. * WebXR Camera which holds the views for the xrSession
  41143. * @see https://doc.babylonjs.com/how_to/webxr
  41144. */
  41145. export class WebXRCamera extends FreeCamera {
  41146. private static _TmpMatrix;
  41147. /**
  41148. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41149. * @param name the name of the camera
  41150. * @param scene the scene to add the camera to
  41151. */
  41152. constructor(name: string, scene: Scene);
  41153. private _updateNumberOfRigCameras;
  41154. /** @hidden */
  41155. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41156. /**
  41157. * Updates the cameras position from the current pose information of the XR session
  41158. * @param xrSessionManager the session containing pose information
  41159. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41160. */
  41161. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41162. }
  41163. }
  41164. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41165. import { Nullable } from "babylonjs/types";
  41166. import { Observable } from "babylonjs/Misc/observable";
  41167. import { IDisposable, Scene } from "babylonjs/scene";
  41168. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41170. import { Ray } from "babylonjs/Culling/ray";
  41171. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41172. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41173. /**
  41174. * States of the webXR experience
  41175. */
  41176. export enum WebXRState {
  41177. /**
  41178. * Transitioning to being in XR mode
  41179. */
  41180. ENTERING_XR = 0,
  41181. /**
  41182. * Transitioning to non XR mode
  41183. */
  41184. EXITING_XR = 1,
  41185. /**
  41186. * In XR mode and presenting
  41187. */
  41188. IN_XR = 2,
  41189. /**
  41190. * Not entered XR mode
  41191. */
  41192. NOT_IN_XR = 3
  41193. }
  41194. /**
  41195. * Helper class used to enable XR
  41196. * @see https://doc.babylonjs.com/how_to/webxr
  41197. */
  41198. export class WebXRExperienceHelper implements IDisposable {
  41199. private scene;
  41200. /**
  41201. * 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
  41202. */
  41203. container: AbstractMesh;
  41204. /**
  41205. * Camera used to render xr content
  41206. */
  41207. camera: WebXRCamera;
  41208. /**
  41209. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41210. */
  41211. state: WebXRState;
  41212. private _setState;
  41213. private static _TmpVector;
  41214. /**
  41215. * Fires when the state of the experience helper has changed
  41216. */
  41217. onStateChangedObservable: Observable<WebXRState>;
  41218. /** @hidden */
  41219. _sessionManager: WebXRSessionManager;
  41220. private _nonVRCamera;
  41221. private _originalSceneAutoClear;
  41222. private _supported;
  41223. /**
  41224. * Creates the experience helper
  41225. * @param scene the scene to attach the experience helper to
  41226. * @returns a promise for the experience helper
  41227. */
  41228. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41229. /**
  41230. * Creates a WebXRExperienceHelper
  41231. * @param scene The scene the helper should be created in
  41232. */
  41233. private constructor();
  41234. /**
  41235. * Exits XR mode and returns the scene to its original state
  41236. * @returns promise that resolves after xr mode has exited
  41237. */
  41238. exitXRAsync(): Promise<void>;
  41239. /**
  41240. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41241. * @param sessionCreationOptions options for the XR session
  41242. * @param frameOfReference frame of reference of the XR session
  41243. * @returns promise that resolves after xr mode has entered
  41244. */
  41245. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41246. /**
  41247. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41248. * @param ray ray to cast into the environment
  41249. * @returns Promise which resolves with a collision point in the environment if it exists
  41250. */
  41251. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41252. /**
  41253. * Updates the global position of the camera by moving the camera's container
  41254. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41255. * @param position The desired global position of the camera
  41256. */
  41257. setPositionOfCameraUsingContainer(position: Vector3): void;
  41258. /**
  41259. * Rotates the xr camera by rotating the camera's container around the camera's position
  41260. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41261. * @param rotation the desired quaternion rotation to apply to the camera
  41262. */
  41263. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41264. /**
  41265. * Checks if the creation options are supported by the xr session
  41266. * @param options creation options
  41267. * @returns true if supported
  41268. */
  41269. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41270. /**
  41271. * Disposes of the experience helper
  41272. */
  41273. dispose(): void;
  41274. }
  41275. }
  41276. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41277. import { Nullable } from "babylonjs/types";
  41278. import { Observable } from "babylonjs/Misc/observable";
  41279. import { IDisposable, Scene } from "babylonjs/scene";
  41280. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41281. /**
  41282. * Button which can be used to enter a different mode of XR
  41283. */
  41284. export class WebXREnterExitUIButton {
  41285. /** button element */
  41286. element: HTMLElement;
  41287. /** XR initialization options for the button */
  41288. initializationOptions: XRSessionCreationOptions;
  41289. /**
  41290. * Creates a WebXREnterExitUIButton
  41291. * @param element button element
  41292. * @param initializationOptions XR initialization options for the button
  41293. */
  41294. constructor(
  41295. /** button element */
  41296. element: HTMLElement,
  41297. /** XR initialization options for the button */
  41298. initializationOptions: XRSessionCreationOptions);
  41299. /**
  41300. * Overwritable function which can be used to update the button's visuals when the state changes
  41301. * @param activeButton the current active button in the UI
  41302. */
  41303. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41304. }
  41305. /**
  41306. * Options to create the webXR UI
  41307. */
  41308. export class WebXREnterExitUIOptions {
  41309. /**
  41310. * Context to enter xr with
  41311. */
  41312. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41313. /**
  41314. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41315. */
  41316. customButtons?: Array<WebXREnterExitUIButton>;
  41317. }
  41318. /**
  41319. * UI to allow the user to enter/exit XR mode
  41320. */
  41321. export class WebXREnterExitUI implements IDisposable {
  41322. private scene;
  41323. private _overlay;
  41324. private _buttons;
  41325. private _activeButton;
  41326. /**
  41327. * Fired every time the active button is changed.
  41328. *
  41329. * When xr is entered via a button that launches xr that button will be the callback parameter
  41330. *
  41331. * When exiting xr the callback parameter will be null)
  41332. */
  41333. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41334. /**
  41335. * Creates UI to allow the user to enter/exit XR mode
  41336. * @param scene the scene to add the ui to
  41337. * @param helper the xr experience helper to enter/exit xr with
  41338. * @param options options to configure the UI
  41339. * @returns the created ui
  41340. */
  41341. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41342. private constructor();
  41343. private _updateButtons;
  41344. /**
  41345. * Disposes of the object
  41346. */
  41347. dispose(): void;
  41348. }
  41349. }
  41350. declare module "babylonjs/Cameras/XR/webXRInput" {
  41351. import { IDisposable, Scene } from "babylonjs/scene";
  41352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41353. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41354. /**
  41355. * Represents an XR input
  41356. */
  41357. export class WebXRController {
  41358. /**
  41359. * 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
  41360. */
  41361. grip?: AbstractMesh;
  41362. /**
  41363. * Pointer which can be used to select objects or attach a visible laser to
  41364. */
  41365. pointer: AbstractMesh;
  41366. /**
  41367. * Creates the controller
  41368. * @see https://doc.babylonjs.com/how_to/webxr
  41369. * @param scene the scene which the controller should be associated to
  41370. */
  41371. constructor(scene: Scene);
  41372. /**
  41373. * Disposes of the object
  41374. */
  41375. dispose(): void;
  41376. }
  41377. /**
  41378. * XR input used to track XR inputs such as controllers/rays
  41379. */
  41380. export class WebXRInput implements IDisposable {
  41381. private helper;
  41382. /**
  41383. * XR controllers being tracked
  41384. */
  41385. controllers: Array<WebXRController>;
  41386. private _tmpMatrix;
  41387. private _frameObserver;
  41388. /**
  41389. * Initializes the WebXRInput
  41390. * @param helper experience helper which the input should be created for
  41391. */
  41392. constructor(helper: WebXRExperienceHelper);
  41393. /**
  41394. * Disposes of the object
  41395. */
  41396. dispose(): void;
  41397. }
  41398. }
  41399. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41400. import { Nullable } from "babylonjs/types";
  41401. import { IDisposable } from "babylonjs/scene";
  41402. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41403. /**
  41404. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41405. */
  41406. export class WebXRManagedOutputCanvas implements IDisposable {
  41407. private _canvas;
  41408. /**
  41409. * xrpresent context of the canvas which can be used to display/mirror xr content
  41410. */
  41411. canvasContext: Nullable<WebGLRenderingContext>;
  41412. /**
  41413. * Initializes the canvas to be added/removed upon entering/exiting xr
  41414. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41415. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41416. */
  41417. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41418. /**
  41419. * Disposes of the object
  41420. */
  41421. dispose(): void;
  41422. private _setManagedOutputCanvas;
  41423. private _addCanvas;
  41424. private _removeCanvas;
  41425. }
  41426. }
  41427. declare module "babylonjs/Cameras/XR/index" {
  41428. export * from "babylonjs/Cameras/XR/webXRCamera";
  41429. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41430. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41431. export * from "babylonjs/Cameras/XR/webXRInput";
  41432. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41433. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41434. }
  41435. declare module "babylonjs/Cameras/RigModes/index" {
  41436. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41437. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41438. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41439. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41440. }
  41441. declare module "babylonjs/Cameras/index" {
  41442. export * from "babylonjs/Cameras/Inputs/index";
  41443. export * from "babylonjs/Cameras/cameraInputsManager";
  41444. export * from "babylonjs/Cameras/camera";
  41445. export * from "babylonjs/Cameras/targetCamera";
  41446. export * from "babylonjs/Cameras/freeCamera";
  41447. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41448. export * from "babylonjs/Cameras/touchCamera";
  41449. export * from "babylonjs/Cameras/arcRotateCamera";
  41450. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41451. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41452. export * from "babylonjs/Cameras/flyCamera";
  41453. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41454. export * from "babylonjs/Cameras/followCamera";
  41455. export * from "babylonjs/Cameras/gamepadCamera";
  41456. export * from "babylonjs/Cameras/Stereoscopic/index";
  41457. export * from "babylonjs/Cameras/universalCamera";
  41458. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41459. export * from "babylonjs/Cameras/VR/index";
  41460. export * from "babylonjs/Cameras/XR/index";
  41461. export * from "babylonjs/Cameras/RigModes/index";
  41462. }
  41463. declare module "babylonjs/Collisions/index" {
  41464. export * from "babylonjs/Collisions/collider";
  41465. export * from "babylonjs/Collisions/collisionCoordinator";
  41466. export * from "babylonjs/Collisions/pickingInfo";
  41467. export * from "babylonjs/Collisions/intersectionInfo";
  41468. }
  41469. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41470. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41471. import { Vector3, Plane } from "babylonjs/Maths/math";
  41472. import { Ray } from "babylonjs/Culling/ray";
  41473. /**
  41474. * Contains an array of blocks representing the octree
  41475. */
  41476. export interface IOctreeContainer<T> {
  41477. /**
  41478. * Blocks within the octree
  41479. */
  41480. blocks: Array<OctreeBlock<T>>;
  41481. }
  41482. /**
  41483. * Class used to store a cell in an octree
  41484. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41485. */
  41486. export class OctreeBlock<T> {
  41487. /**
  41488. * Gets the content of the current block
  41489. */
  41490. entries: T[];
  41491. /**
  41492. * Gets the list of block children
  41493. */
  41494. blocks: Array<OctreeBlock<T>>;
  41495. private _depth;
  41496. private _maxDepth;
  41497. private _capacity;
  41498. private _minPoint;
  41499. private _maxPoint;
  41500. private _boundingVectors;
  41501. private _creationFunc;
  41502. /**
  41503. * Creates a new block
  41504. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41505. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41506. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41507. * @param depth defines the current depth of this block in the octree
  41508. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41509. * @param creationFunc defines a callback to call when an element is added to the block
  41510. */
  41511. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41512. /**
  41513. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41514. */
  41515. readonly capacity: number;
  41516. /**
  41517. * Gets the minimum vector (in world space) of the block's bounding box
  41518. */
  41519. readonly minPoint: Vector3;
  41520. /**
  41521. * Gets the maximum vector (in world space) of the block's bounding box
  41522. */
  41523. readonly maxPoint: Vector3;
  41524. /**
  41525. * Add a new element to this block
  41526. * @param entry defines the element to add
  41527. */
  41528. addEntry(entry: T): void;
  41529. /**
  41530. * Remove an element from this block
  41531. * @param entry defines the element to remove
  41532. */
  41533. removeEntry(entry: T): void;
  41534. /**
  41535. * Add an array of elements to this block
  41536. * @param entries defines the array of elements to add
  41537. */
  41538. addEntries(entries: T[]): void;
  41539. /**
  41540. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41541. * @param frustumPlanes defines the frustum planes to test
  41542. * @param selection defines the array to store current content if selection is positive
  41543. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41544. */
  41545. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41546. /**
  41547. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41548. * @param sphereCenter defines the bounding sphere center
  41549. * @param sphereRadius defines the bounding sphere radius
  41550. * @param selection defines the array to store current content if selection is positive
  41551. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41552. */
  41553. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41554. /**
  41555. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41556. * @param ray defines the ray to test with
  41557. * @param selection defines the array to store current content if selection is positive
  41558. */
  41559. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41560. /**
  41561. * Subdivide the content into child blocks (this block will then be empty)
  41562. */
  41563. createInnerBlocks(): void;
  41564. /**
  41565. * @hidden
  41566. */
  41567. 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;
  41568. }
  41569. }
  41570. declare module "babylonjs/Culling/Octrees/octree" {
  41571. import { SmartArray } from "babylonjs/Misc/smartArray";
  41572. import { Vector3, Plane } from "babylonjs/Maths/math";
  41573. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41575. import { Ray } from "babylonjs/Culling/ray";
  41576. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41577. /**
  41578. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41579. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41580. */
  41581. export class Octree<T> {
  41582. /** 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.) */
  41583. maxDepth: number;
  41584. /**
  41585. * Blocks within the octree containing objects
  41586. */
  41587. blocks: Array<OctreeBlock<T>>;
  41588. /**
  41589. * Content stored in the octree
  41590. */
  41591. dynamicContent: T[];
  41592. private _maxBlockCapacity;
  41593. private _selectionContent;
  41594. private _creationFunc;
  41595. /**
  41596. * Creates a octree
  41597. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41598. * @param creationFunc function to be used to instatiate the octree
  41599. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41600. * @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.)
  41601. */
  41602. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41603. /** 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.) */
  41604. maxDepth?: number);
  41605. /**
  41606. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41607. * @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);
  41608. * @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);
  41609. * @param entries meshes to be added to the octree blocks
  41610. */
  41611. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41612. /**
  41613. * Adds a mesh to the octree
  41614. * @param entry Mesh to add to the octree
  41615. */
  41616. addMesh(entry: T): void;
  41617. /**
  41618. * Remove an element from the octree
  41619. * @param entry defines the element to remove
  41620. */
  41621. removeMesh(entry: T): void;
  41622. /**
  41623. * Selects an array of meshes within the frustum
  41624. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41625. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41626. * @returns array of meshes within the frustum
  41627. */
  41628. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41629. /**
  41630. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41631. * @param sphereCenter defines the bounding sphere center
  41632. * @param sphereRadius defines the bounding sphere radius
  41633. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41634. * @returns an array of objects that intersect the sphere
  41635. */
  41636. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41637. /**
  41638. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41639. * @param ray defines the ray to test with
  41640. * @returns array of intersected objects
  41641. */
  41642. intersectsRay(ray: Ray): SmartArray<T>;
  41643. /**
  41644. * Adds a mesh into the octree block if it intersects the block
  41645. */
  41646. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41647. /**
  41648. * Adds a submesh into the octree block if it intersects the block
  41649. */
  41650. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41651. }
  41652. }
  41653. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41654. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41655. import { Scene } from "babylonjs/scene";
  41656. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41658. import { Ray } from "babylonjs/Culling/ray";
  41659. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41660. import { Collider } from "babylonjs/Collisions/collider";
  41661. module "babylonjs/scene" {
  41662. interface Scene {
  41663. /**
  41664. * @hidden
  41665. * Backing Filed
  41666. */
  41667. _selectionOctree: Octree<AbstractMesh>;
  41668. /**
  41669. * Gets the octree used to boost mesh selection (picking)
  41670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41671. */
  41672. selectionOctree: Octree<AbstractMesh>;
  41673. /**
  41674. * Creates or updates the octree used to boost selection (picking)
  41675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41676. * @param maxCapacity defines the maximum capacity per leaf
  41677. * @param maxDepth defines the maximum depth of the octree
  41678. * @returns an octree of AbstractMesh
  41679. */
  41680. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41681. }
  41682. }
  41683. module "babylonjs/Meshes/abstractMesh" {
  41684. interface AbstractMesh {
  41685. /**
  41686. * @hidden
  41687. * Backing Field
  41688. */
  41689. _submeshesOctree: Octree<SubMesh>;
  41690. /**
  41691. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41692. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41693. * @param maxCapacity defines the maximum size of each block (64 by default)
  41694. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41695. * @returns the new octree
  41696. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41697. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41698. */
  41699. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41700. }
  41701. }
  41702. /**
  41703. * Defines the octree scene component responsible to manage any octrees
  41704. * in a given scene.
  41705. */
  41706. export class OctreeSceneComponent {
  41707. /**
  41708. * The component name helpfull to identify the component in the list of scene components.
  41709. */
  41710. readonly name: string;
  41711. /**
  41712. * The scene the component belongs to.
  41713. */
  41714. scene: Scene;
  41715. /**
  41716. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41717. */
  41718. readonly checksIsEnabled: boolean;
  41719. /**
  41720. * Creates a new instance of the component for the given scene
  41721. * @param scene Defines the scene to register the component in
  41722. */
  41723. constructor(scene: Scene);
  41724. /**
  41725. * Registers the component in a given scene
  41726. */
  41727. register(): void;
  41728. /**
  41729. * Return the list of active meshes
  41730. * @returns the list of active meshes
  41731. */
  41732. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41733. /**
  41734. * Return the list of active sub meshes
  41735. * @param mesh The mesh to get the candidates sub meshes from
  41736. * @returns the list of active sub meshes
  41737. */
  41738. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41739. private _tempRay;
  41740. /**
  41741. * Return the list of sub meshes intersecting with a given local ray
  41742. * @param mesh defines the mesh to find the submesh for
  41743. * @param localRay defines the ray in local space
  41744. * @returns the list of intersecting sub meshes
  41745. */
  41746. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41747. /**
  41748. * Return the list of sub meshes colliding with a collider
  41749. * @param mesh defines the mesh to find the submesh for
  41750. * @param collider defines the collider to evaluate the collision against
  41751. * @returns the list of colliding sub meshes
  41752. */
  41753. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41754. /**
  41755. * Rebuilds the elements related to this component in case of
  41756. * context lost for instance.
  41757. */
  41758. rebuild(): void;
  41759. /**
  41760. * Disposes the component and the associated ressources.
  41761. */
  41762. dispose(): void;
  41763. }
  41764. }
  41765. declare module "babylonjs/Culling/Octrees/index" {
  41766. export * from "babylonjs/Culling/Octrees/octree";
  41767. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41768. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41769. }
  41770. declare module "babylonjs/Culling/index" {
  41771. export * from "babylonjs/Culling/boundingBox";
  41772. export * from "babylonjs/Culling/boundingInfo";
  41773. export * from "babylonjs/Culling/boundingSphere";
  41774. export * from "babylonjs/Culling/Octrees/index";
  41775. export * from "babylonjs/Culling/ray";
  41776. }
  41777. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41778. import { IDisposable, Scene } from "babylonjs/scene";
  41779. import { Nullable } from "babylonjs/types";
  41780. import { Observable } from "babylonjs/Misc/observable";
  41781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41782. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  41783. /**
  41784. * Renders a layer on top of an existing scene
  41785. */
  41786. export class UtilityLayerRenderer implements IDisposable {
  41787. /** the original scene that will be rendered on top of */
  41788. originalScene: Scene;
  41789. private _pointerCaptures;
  41790. private _lastPointerEvents;
  41791. private static _DefaultUtilityLayer;
  41792. private static _DefaultKeepDepthUtilityLayer;
  41793. private _sharedGizmoLight;
  41794. /**
  41795. * @hidden
  41796. * Light which used by gizmos to get light shading
  41797. */
  41798. _getSharedGizmoLight(): HemisphericLight;
  41799. /**
  41800. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41801. */
  41802. pickUtilitySceneFirst: boolean;
  41803. /**
  41804. * 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)
  41805. */
  41806. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41807. /**
  41808. * 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)
  41809. */
  41810. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41811. /**
  41812. * The scene that is rendered on top of the original scene
  41813. */
  41814. utilityLayerScene: Scene;
  41815. /**
  41816. * If the utility layer should automatically be rendered on top of existing scene
  41817. */
  41818. shouldRender: boolean;
  41819. /**
  41820. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41821. */
  41822. onlyCheckPointerDownEvents: boolean;
  41823. /**
  41824. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41825. */
  41826. processAllEvents: boolean;
  41827. /**
  41828. * Observable raised when the pointer move from the utility layer scene to the main scene
  41829. */
  41830. onPointerOutObservable: Observable<number>;
  41831. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41832. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41833. private _afterRenderObserver;
  41834. private _sceneDisposeObserver;
  41835. private _originalPointerObserver;
  41836. /**
  41837. * Instantiates a UtilityLayerRenderer
  41838. * @param originalScene the original scene that will be rendered on top of
  41839. * @param handleEvents boolean indicating if the utility layer should handle events
  41840. */
  41841. constructor(
  41842. /** the original scene that will be rendered on top of */
  41843. originalScene: Scene, handleEvents?: boolean);
  41844. private _notifyObservers;
  41845. /**
  41846. * Renders the utility layers scene on top of the original scene
  41847. */
  41848. render(): void;
  41849. /**
  41850. * Disposes of the renderer
  41851. */
  41852. dispose(): void;
  41853. private _updateCamera;
  41854. }
  41855. }
  41856. declare module "babylonjs/Gizmos/gizmo" {
  41857. import { Nullable } from "babylonjs/types";
  41858. import { IDisposable } from "babylonjs/scene";
  41859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41860. import { Mesh } from "babylonjs/Meshes/mesh";
  41861. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41862. /**
  41863. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41864. */
  41865. export class Gizmo implements IDisposable {
  41866. /** The utility layer the gizmo will be added to */
  41867. gizmoLayer: UtilityLayerRenderer;
  41868. /**
  41869. * The root mesh of the gizmo
  41870. */
  41871. _rootMesh: Mesh;
  41872. private _attachedMesh;
  41873. /**
  41874. * Ratio for the scale of the gizmo (Default: 1)
  41875. */
  41876. scaleRatio: number;
  41877. private _tmpMatrix;
  41878. /**
  41879. * If a custom mesh has been set (Default: false)
  41880. */
  41881. protected _customMeshSet: boolean;
  41882. /**
  41883. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41884. * * When set, interactions will be enabled
  41885. */
  41886. attachedMesh: Nullable<AbstractMesh>;
  41887. /**
  41888. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41889. * @param mesh The mesh to replace the default mesh of the gizmo
  41890. */
  41891. setCustomMesh(mesh: Mesh): void;
  41892. /**
  41893. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41894. */
  41895. updateGizmoRotationToMatchAttachedMesh: boolean;
  41896. /**
  41897. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41898. */
  41899. updateGizmoPositionToMatchAttachedMesh: boolean;
  41900. /**
  41901. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41902. */
  41903. protected _updateScale: boolean;
  41904. protected _interactionsEnabled: boolean;
  41905. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41906. private _beforeRenderObserver;
  41907. /**
  41908. * Creates a gizmo
  41909. * @param gizmoLayer The utility layer the gizmo will be added to
  41910. */
  41911. constructor(
  41912. /** The utility layer the gizmo will be added to */
  41913. gizmoLayer?: UtilityLayerRenderer);
  41914. private _tempVector;
  41915. /**
  41916. * @hidden
  41917. * Updates the gizmo to match the attached mesh's position/rotation
  41918. */
  41919. protected _update(): void;
  41920. /**
  41921. * Disposes of the gizmo
  41922. */
  41923. dispose(): void;
  41924. }
  41925. }
  41926. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41927. import { Observable } from "babylonjs/Misc/observable";
  41928. import { Nullable } from "babylonjs/types";
  41929. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41930. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41932. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41933. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41934. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41935. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41936. import { Scene } from "babylonjs/scene";
  41937. /**
  41938. * Single axis drag gizmo
  41939. */
  41940. export class AxisDragGizmo extends Gizmo {
  41941. /**
  41942. * Drag behavior responsible for the gizmos dragging interactions
  41943. */
  41944. dragBehavior: PointerDragBehavior;
  41945. private _pointerObserver;
  41946. /**
  41947. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41948. */
  41949. snapDistance: number;
  41950. /**
  41951. * Event that fires each time the gizmo snaps to a new location.
  41952. * * snapDistance is the the change in distance
  41953. */
  41954. onSnapObservable: Observable<{
  41955. snapDistance: number;
  41956. }>;
  41957. /** @hidden */
  41958. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41959. /** @hidden */
  41960. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41961. /**
  41962. * Creates an AxisDragGizmo
  41963. * @param gizmoLayer The utility layer the gizmo will be added to
  41964. * @param dragAxis The axis which the gizmo will be able to drag on
  41965. * @param color The color of the gizmo
  41966. */
  41967. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41968. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41969. /**
  41970. * Disposes of the gizmo
  41971. */
  41972. dispose(): void;
  41973. }
  41974. }
  41975. declare module "babylonjs/Debug/axesViewer" {
  41976. import { Vector3 } from "babylonjs/Maths/math";
  41977. import { Nullable } from "babylonjs/types";
  41978. import { Scene } from "babylonjs/scene";
  41979. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41980. /**
  41981. * The Axes viewer will show 3 axes in a specific point in space
  41982. */
  41983. export class AxesViewer {
  41984. private _xAxis;
  41985. private _yAxis;
  41986. private _zAxis;
  41987. private _scaleLinesFactor;
  41988. private _instanced;
  41989. /**
  41990. * Gets the hosting scene
  41991. */
  41992. scene: Scene;
  41993. /**
  41994. * Gets or sets a number used to scale line length
  41995. */
  41996. scaleLines: number;
  41997. /** Gets the node hierarchy used to render x-axis */
  41998. readonly xAxis: TransformNode;
  41999. /** Gets the node hierarchy used to render y-axis */
  42000. readonly yAxis: TransformNode;
  42001. /** Gets the node hierarchy used to render z-axis */
  42002. readonly zAxis: TransformNode;
  42003. /**
  42004. * Creates a new AxesViewer
  42005. * @param scene defines the hosting scene
  42006. * @param scaleLines defines a number used to scale line length (1 by default)
  42007. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42008. * @param xAxis defines the node hierarchy used to render the x-axis
  42009. * @param yAxis defines the node hierarchy used to render the y-axis
  42010. * @param zAxis defines the node hierarchy used to render the z-axis
  42011. */
  42012. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42013. /**
  42014. * Force the viewer to update
  42015. * @param position defines the position of the viewer
  42016. * @param xaxis defines the x axis of the viewer
  42017. * @param yaxis defines the y axis of the viewer
  42018. * @param zaxis defines the z axis of the viewer
  42019. */
  42020. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42021. /**
  42022. * Creates an instance of this axes viewer.
  42023. * @returns a new axes viewer with instanced meshes
  42024. */
  42025. createInstance(): AxesViewer;
  42026. /** Releases resources */
  42027. dispose(): void;
  42028. private static _SetRenderingGroupId;
  42029. }
  42030. }
  42031. declare module "babylonjs/Debug/boneAxesViewer" {
  42032. import { Nullable } from "babylonjs/types";
  42033. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42034. import { Vector3 } from "babylonjs/Maths/math";
  42035. import { Mesh } from "babylonjs/Meshes/mesh";
  42036. import { Bone } from "babylonjs/Bones/bone";
  42037. import { Scene } from "babylonjs/scene";
  42038. /**
  42039. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42040. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42041. */
  42042. export class BoneAxesViewer extends AxesViewer {
  42043. /**
  42044. * Gets or sets the target mesh where to display the axes viewer
  42045. */
  42046. mesh: Nullable<Mesh>;
  42047. /**
  42048. * Gets or sets the target bone where to display the axes viewer
  42049. */
  42050. bone: Nullable<Bone>;
  42051. /** Gets current position */
  42052. pos: Vector3;
  42053. /** Gets direction of X axis */
  42054. xaxis: Vector3;
  42055. /** Gets direction of Y axis */
  42056. yaxis: Vector3;
  42057. /** Gets direction of Z axis */
  42058. zaxis: Vector3;
  42059. /**
  42060. * Creates a new BoneAxesViewer
  42061. * @param scene defines the hosting scene
  42062. * @param bone defines the target bone
  42063. * @param mesh defines the target mesh
  42064. * @param scaleLines defines a scaling factor for line length (1 by default)
  42065. */
  42066. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42067. /**
  42068. * Force the viewer to update
  42069. */
  42070. update(): void;
  42071. /** Releases resources */
  42072. dispose(): void;
  42073. }
  42074. }
  42075. declare module "babylonjs/Debug/debugLayer" {
  42076. import { Observable } from "babylonjs/Misc/observable";
  42077. import { Scene } from "babylonjs/scene";
  42078. /**
  42079. * Interface used to define scene explorer extensibility option
  42080. */
  42081. export interface IExplorerExtensibilityOption {
  42082. /**
  42083. * Define the option label
  42084. */
  42085. label: string;
  42086. /**
  42087. * Defines the action to execute on click
  42088. */
  42089. action: (entity: any) => void;
  42090. }
  42091. /**
  42092. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42093. */
  42094. export interface IExplorerExtensibilityGroup {
  42095. /**
  42096. * Defines a predicate to test if a given type mut be extended
  42097. */
  42098. predicate: (entity: any) => boolean;
  42099. /**
  42100. * Gets the list of options added to a type
  42101. */
  42102. entries: IExplorerExtensibilityOption[];
  42103. }
  42104. /**
  42105. * Interface used to define the options to use to create the Inspector
  42106. */
  42107. export interface IInspectorOptions {
  42108. /**
  42109. * Display in overlay mode (default: false)
  42110. */
  42111. overlay?: boolean;
  42112. /**
  42113. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42114. */
  42115. globalRoot?: HTMLElement;
  42116. /**
  42117. * Display the Scene explorer
  42118. */
  42119. showExplorer?: boolean;
  42120. /**
  42121. * Display the property inspector
  42122. */
  42123. showInspector?: boolean;
  42124. /**
  42125. * Display in embed mode (both panes on the right)
  42126. */
  42127. embedMode?: boolean;
  42128. /**
  42129. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42130. */
  42131. handleResize?: boolean;
  42132. /**
  42133. * Allow the panes to popup (default: true)
  42134. */
  42135. enablePopup?: boolean;
  42136. /**
  42137. * Allow the panes to be closed by users (default: true)
  42138. */
  42139. enableClose?: boolean;
  42140. /**
  42141. * Optional list of extensibility entries
  42142. */
  42143. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42144. /**
  42145. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42146. */
  42147. inspectorURL?: string;
  42148. }
  42149. module "babylonjs/scene" {
  42150. interface Scene {
  42151. /**
  42152. * @hidden
  42153. * Backing field
  42154. */
  42155. _debugLayer: DebugLayer;
  42156. /**
  42157. * Gets the debug layer (aka Inspector) associated with the scene
  42158. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42159. */
  42160. debugLayer: DebugLayer;
  42161. }
  42162. }
  42163. /**
  42164. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42165. * what is happening in your scene
  42166. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42167. */
  42168. export class DebugLayer {
  42169. /**
  42170. * Define the url to get the inspector script from.
  42171. * By default it uses the babylonjs CDN.
  42172. * @ignoreNaming
  42173. */
  42174. static InspectorURL: string;
  42175. private _scene;
  42176. private BJSINSPECTOR;
  42177. /**
  42178. * Observable triggered when a property is changed through the inspector.
  42179. */
  42180. onPropertyChangedObservable: Observable<{
  42181. object: any;
  42182. property: string;
  42183. value: any;
  42184. initialValue: any;
  42185. }>;
  42186. /**
  42187. * Instantiates a new debug layer.
  42188. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42189. * what is happening in your scene
  42190. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42191. * @param scene Defines the scene to inspect
  42192. */
  42193. constructor(scene: Scene);
  42194. /** Creates the inspector window. */
  42195. private _createInspector;
  42196. /**
  42197. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42198. * @param entity defines the entity to select
  42199. * @param lineContainerTitle defines the specific block to highlight
  42200. */
  42201. select(entity: any, lineContainerTitle?: string): void;
  42202. /** Get the inspector from bundle or global */
  42203. private _getGlobalInspector;
  42204. /**
  42205. * Get if the inspector is visible or not.
  42206. * @returns true if visible otherwise, false
  42207. */
  42208. isVisible(): boolean;
  42209. /**
  42210. * Hide the inspector and close its window.
  42211. */
  42212. hide(): void;
  42213. /**
  42214. * Launch the debugLayer.
  42215. * @param config Define the configuration of the inspector
  42216. * @return a promise fulfilled when the debug layer is visible
  42217. */
  42218. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42219. }
  42220. }
  42221. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42222. import { Nullable } from "babylonjs/types";
  42223. import { Scene } from "babylonjs/scene";
  42224. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42225. import { Mesh } from "babylonjs/Meshes/mesh";
  42226. /**
  42227. * Class containing static functions to help procedurally build meshes
  42228. */
  42229. export class BoxBuilder {
  42230. /**
  42231. * Creates a box mesh
  42232. * * The parameter `size` sets the size (float) of each box side (default 1)
  42233. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42234. * * 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)
  42235. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42239. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42240. * @param name defines the name of the mesh
  42241. * @param options defines the options used to create the mesh
  42242. * @param scene defines the hosting scene
  42243. * @returns the box mesh
  42244. */
  42245. static CreateBox(name: string, options: {
  42246. size?: number;
  42247. width?: number;
  42248. height?: number;
  42249. depth?: number;
  42250. faceUV?: Vector4[];
  42251. faceColors?: Color4[];
  42252. sideOrientation?: number;
  42253. frontUVs?: Vector4;
  42254. backUVs?: Vector4;
  42255. wrap?: boolean;
  42256. topBaseAt?: number;
  42257. bottomBaseAt?: number;
  42258. updatable?: boolean;
  42259. }, scene?: Nullable<Scene>): Mesh;
  42260. }
  42261. }
  42262. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42263. import { Vector4 } from "babylonjs/Maths/math";
  42264. import { Mesh } from "babylonjs/Meshes/mesh";
  42265. /**
  42266. * Class containing static functions to help procedurally build meshes
  42267. */
  42268. export class SphereBuilder {
  42269. /**
  42270. * Creates a sphere mesh
  42271. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42272. * * 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`)
  42273. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42274. * * 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
  42275. * * 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)
  42276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42279. * @param name defines the name of the mesh
  42280. * @param options defines the options used to create the mesh
  42281. * @param scene defines the hosting scene
  42282. * @returns the sphere mesh
  42283. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42284. */
  42285. static CreateSphere(name: string, options: {
  42286. segments?: number;
  42287. diameter?: number;
  42288. diameterX?: number;
  42289. diameterY?: number;
  42290. diameterZ?: number;
  42291. arc?: number;
  42292. slice?: number;
  42293. sideOrientation?: number;
  42294. frontUVs?: Vector4;
  42295. backUVs?: Vector4;
  42296. updatable?: boolean;
  42297. }, scene: any): Mesh;
  42298. }
  42299. }
  42300. declare module "babylonjs/Debug/physicsViewer" {
  42301. import { Nullable } from "babylonjs/types";
  42302. import { Scene } from "babylonjs/scene";
  42303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42304. import { Mesh } from "babylonjs/Meshes/mesh";
  42305. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42306. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42307. /**
  42308. * Used to show the physics impostor around the specific mesh
  42309. */
  42310. export class PhysicsViewer {
  42311. /** @hidden */
  42312. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42313. /** @hidden */
  42314. protected _meshes: Array<Nullable<AbstractMesh>>;
  42315. /** @hidden */
  42316. protected _scene: Nullable<Scene>;
  42317. /** @hidden */
  42318. protected _numMeshes: number;
  42319. /** @hidden */
  42320. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42321. private _renderFunction;
  42322. private _utilityLayer;
  42323. private _debugBoxMesh;
  42324. private _debugSphereMesh;
  42325. private _debugCylinderMesh;
  42326. private _debugMaterial;
  42327. private _debugMeshMeshes;
  42328. /**
  42329. * Creates a new PhysicsViewer
  42330. * @param scene defines the hosting scene
  42331. */
  42332. constructor(scene: Scene);
  42333. /** @hidden */
  42334. protected _updateDebugMeshes(): void;
  42335. /**
  42336. * Renders a specified physic impostor
  42337. * @param impostor defines the impostor to render
  42338. * @param targetMesh defines the mesh represented by the impostor
  42339. * @returns the new debug mesh used to render the impostor
  42340. */
  42341. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42342. /**
  42343. * Hides a specified physic impostor
  42344. * @param impostor defines the impostor to hide
  42345. */
  42346. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42347. private _getDebugMaterial;
  42348. private _getDebugBoxMesh;
  42349. private _getDebugSphereMesh;
  42350. private _getDebugCylinderMesh;
  42351. private _getDebugMeshMesh;
  42352. private _getDebugMesh;
  42353. /** Releases all resources */
  42354. dispose(): void;
  42355. }
  42356. }
  42357. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42358. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42359. import { Nullable } from "babylonjs/types";
  42360. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42361. import { Scene } from "babylonjs/scene";
  42362. /**
  42363. * Class containing static functions to help procedurally build meshes
  42364. */
  42365. export class LinesBuilder {
  42366. /**
  42367. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42368. * * 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
  42369. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42370. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42371. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42372. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42373. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42374. * * 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
  42375. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42377. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42378. * @param name defines the name of the new line system
  42379. * @param options defines the options used to create the line system
  42380. * @param scene defines the hosting scene
  42381. * @returns a new line system mesh
  42382. */
  42383. static CreateLineSystem(name: string, options: {
  42384. lines: Vector3[][];
  42385. updatable?: boolean;
  42386. instance?: Nullable<LinesMesh>;
  42387. colors?: Nullable<Color4[][]>;
  42388. useVertexAlpha?: boolean;
  42389. }, scene: Nullable<Scene>): LinesMesh;
  42390. /**
  42391. * Creates a line mesh
  42392. * 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
  42393. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42394. * * The parameter `points` is an array successive Vector3
  42395. * * 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
  42396. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42397. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42398. * * When updating an instance, remember that only point positions can change, not the number of points
  42399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42401. * @param name defines the name of the new line system
  42402. * @param options defines the options used to create the line system
  42403. * @param scene defines the hosting scene
  42404. * @returns a new line mesh
  42405. */
  42406. static CreateLines(name: string, options: {
  42407. points: Vector3[];
  42408. updatable?: boolean;
  42409. instance?: Nullable<LinesMesh>;
  42410. colors?: Color4[];
  42411. useVertexAlpha?: boolean;
  42412. }, scene?: Nullable<Scene>): LinesMesh;
  42413. /**
  42414. * Creates a dashed line mesh
  42415. * * 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
  42416. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42417. * * The parameter `points` is an array successive Vector3
  42418. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42419. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42420. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42421. * * 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
  42422. * * When updating an instance, remember that only point positions can change, not the number of points
  42423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42424. * @param name defines the name of the mesh
  42425. * @param options defines the options used to create the mesh
  42426. * @param scene defines the hosting scene
  42427. * @returns the dashed line mesh
  42428. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42429. */
  42430. static CreateDashedLines(name: string, options: {
  42431. points: Vector3[];
  42432. dashSize?: number;
  42433. gapSize?: number;
  42434. dashNb?: number;
  42435. updatable?: boolean;
  42436. instance?: LinesMesh;
  42437. }, scene?: Nullable<Scene>): LinesMesh;
  42438. }
  42439. }
  42440. declare module "babylonjs/Debug/rayHelper" {
  42441. import { Nullable } from "babylonjs/types";
  42442. import { Ray } from "babylonjs/Culling/ray";
  42443. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42444. import { Scene } from "babylonjs/scene";
  42445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42446. import "babylonjs/Meshes/Builders/linesBuilder";
  42447. /**
  42448. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42449. * in order to better appreciate the issue one might have.
  42450. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42451. */
  42452. export class RayHelper {
  42453. /**
  42454. * Defines the ray we are currently tryin to visualize.
  42455. */
  42456. ray: Nullable<Ray>;
  42457. private _renderPoints;
  42458. private _renderLine;
  42459. private _renderFunction;
  42460. private _scene;
  42461. private _updateToMeshFunction;
  42462. private _attachedToMesh;
  42463. private _meshSpaceDirection;
  42464. private _meshSpaceOrigin;
  42465. /**
  42466. * Helper function to create a colored helper in a scene in one line.
  42467. * @param ray Defines the ray we are currently tryin to visualize
  42468. * @param scene Defines the scene the ray is used in
  42469. * @param color Defines the color we want to see the ray in
  42470. * @returns The newly created ray helper.
  42471. */
  42472. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42473. /**
  42474. * Instantiate a new ray helper.
  42475. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42476. * in order to better appreciate the issue one might have.
  42477. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42478. * @param ray Defines the ray we are currently tryin to visualize
  42479. */
  42480. constructor(ray: Ray);
  42481. /**
  42482. * Shows the ray we are willing to debug.
  42483. * @param scene Defines the scene the ray needs to be rendered in
  42484. * @param color Defines the color the ray needs to be rendered in
  42485. */
  42486. show(scene: Scene, color?: Color3): void;
  42487. /**
  42488. * Hides the ray we are debugging.
  42489. */
  42490. hide(): void;
  42491. private _render;
  42492. /**
  42493. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42494. * @param mesh Defines the mesh we want the helper attached to
  42495. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42496. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42497. * @param length Defines the length of the ray
  42498. */
  42499. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42500. /**
  42501. * Detach the ray helper from the mesh it has previously been attached to.
  42502. */
  42503. detachFromMesh(): void;
  42504. private _updateToMesh;
  42505. /**
  42506. * Dispose the helper and release its associated resources.
  42507. */
  42508. dispose(): void;
  42509. }
  42510. }
  42511. declare module "babylonjs/Debug/skeletonViewer" {
  42512. import { Color3 } from "babylonjs/Maths/math";
  42513. import { Scene } from "babylonjs/scene";
  42514. import { Nullable } from "babylonjs/types";
  42515. import { Skeleton } from "babylonjs/Bones/skeleton";
  42516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42517. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42518. /**
  42519. * Class used to render a debug view of a given skeleton
  42520. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42521. */
  42522. export class SkeletonViewer {
  42523. /** defines the skeleton to render */
  42524. skeleton: Skeleton;
  42525. /** defines the mesh attached to the skeleton */
  42526. mesh: AbstractMesh;
  42527. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42528. autoUpdateBonesMatrices: boolean;
  42529. /** defines the rendering group id to use with the viewer */
  42530. renderingGroupId: number;
  42531. /** Gets or sets the color used to render the skeleton */
  42532. color: Color3;
  42533. private _scene;
  42534. private _debugLines;
  42535. private _debugMesh;
  42536. private _isEnabled;
  42537. private _renderFunction;
  42538. private _utilityLayer;
  42539. /**
  42540. * Returns the mesh used to render the bones
  42541. */
  42542. readonly debugMesh: Nullable<LinesMesh>;
  42543. /**
  42544. * Creates a new SkeletonViewer
  42545. * @param skeleton defines the skeleton to render
  42546. * @param mesh defines the mesh attached to the skeleton
  42547. * @param scene defines the hosting scene
  42548. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42549. * @param renderingGroupId defines the rendering group id to use with the viewer
  42550. */
  42551. constructor(
  42552. /** defines the skeleton to render */
  42553. skeleton: Skeleton,
  42554. /** defines the mesh attached to the skeleton */
  42555. mesh: AbstractMesh, scene: Scene,
  42556. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42557. autoUpdateBonesMatrices?: boolean,
  42558. /** defines the rendering group id to use with the viewer */
  42559. renderingGroupId?: number);
  42560. /** Gets or sets a boolean indicating if the viewer is enabled */
  42561. isEnabled: boolean;
  42562. private _getBonePosition;
  42563. private _getLinesForBonesWithLength;
  42564. private _getLinesForBonesNoLength;
  42565. /** Update the viewer to sync with current skeleton state */
  42566. update(): void;
  42567. /** Release associated resources */
  42568. dispose(): void;
  42569. }
  42570. }
  42571. declare module "babylonjs/Debug/index" {
  42572. export * from "babylonjs/Debug/axesViewer";
  42573. export * from "babylonjs/Debug/boneAxesViewer";
  42574. export * from "babylonjs/Debug/debugLayer";
  42575. export * from "babylonjs/Debug/physicsViewer";
  42576. export * from "babylonjs/Debug/rayHelper";
  42577. export * from "babylonjs/Debug/skeletonViewer";
  42578. }
  42579. declare module "babylonjs/Engines/nullEngine" {
  42580. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42581. import { Scene } from "babylonjs/scene";
  42582. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42583. import { Engine } from "babylonjs/Engines/engine";
  42584. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42585. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42586. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42587. import { Effect } from "babylonjs/Materials/effect";
  42588. /**
  42589. * Options to create the null engine
  42590. */
  42591. export class NullEngineOptions {
  42592. /**
  42593. * Render width (Default: 512)
  42594. */
  42595. renderWidth: number;
  42596. /**
  42597. * Render height (Default: 256)
  42598. */
  42599. renderHeight: number;
  42600. /**
  42601. * Texture size (Default: 512)
  42602. */
  42603. textureSize: number;
  42604. /**
  42605. * If delta time between frames should be constant
  42606. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42607. */
  42608. deterministicLockstep: boolean;
  42609. /**
  42610. * Maximum about of steps between frames (Default: 4)
  42611. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42612. */
  42613. lockstepMaxSteps: number;
  42614. }
  42615. /**
  42616. * The null engine class provides support for headless version of babylon.js.
  42617. * This can be used in server side scenario or for testing purposes
  42618. */
  42619. export class NullEngine extends Engine {
  42620. private _options;
  42621. /**
  42622. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42623. */
  42624. isDeterministicLockStep(): boolean;
  42625. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42626. getLockstepMaxSteps(): number;
  42627. /**
  42628. * Sets hardware scaling, used to save performance if needed
  42629. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42630. */
  42631. getHardwareScalingLevel(): number;
  42632. constructor(options?: NullEngineOptions);
  42633. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42634. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42635. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42636. getRenderWidth(useScreen?: boolean): number;
  42637. getRenderHeight(useScreen?: boolean): number;
  42638. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42639. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42640. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42641. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42642. bindSamplers(effect: Effect): void;
  42643. enableEffect(effect: Effect): void;
  42644. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42645. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42646. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42647. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42648. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42649. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42650. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42651. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42652. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42653. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42654. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42655. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42656. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42657. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42658. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42659. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42660. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42661. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42662. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42663. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42664. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42665. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42666. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42667. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42668. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42669. bindBuffers(vertexBuffers: {
  42670. [key: string]: VertexBuffer;
  42671. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42672. wipeCaches(bruteForce?: boolean): void;
  42673. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42674. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42675. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42676. /** @hidden */
  42677. _createTexture(): WebGLTexture;
  42678. /** @hidden */
  42679. _releaseTexture(texture: InternalTexture): void;
  42680. 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;
  42681. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42682. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42683. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42684. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42685. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42686. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42687. areAllEffectsReady(): boolean;
  42688. /**
  42689. * @hidden
  42690. * Get the current error code of the webGL context
  42691. * @returns the error code
  42692. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42693. */
  42694. getError(): number;
  42695. /** @hidden */
  42696. _getUnpackAlignement(): number;
  42697. /** @hidden */
  42698. _unpackFlipY(value: boolean): void;
  42699. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42700. /**
  42701. * Updates a dynamic vertex buffer.
  42702. * @param vertexBuffer the vertex buffer to update
  42703. * @param data the data used to update the vertex buffer
  42704. * @param byteOffset the byte offset of the data (optional)
  42705. * @param byteLength the byte length of the data (optional)
  42706. */
  42707. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42708. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42709. /** @hidden */
  42710. _bindTexture(channel: number, texture: InternalTexture): void;
  42711. /** @hidden */
  42712. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42713. releaseEffects(): void;
  42714. displayLoadingUI(): void;
  42715. hideLoadingUI(): void;
  42716. /** @hidden */
  42717. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42718. /** @hidden */
  42719. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42720. /** @hidden */
  42721. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42722. /** @hidden */
  42723. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42724. }
  42725. }
  42726. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42727. import { Nullable, int } from "babylonjs/types";
  42728. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42729. /** @hidden */
  42730. export class _OcclusionDataStorage {
  42731. /** @hidden */
  42732. occlusionInternalRetryCounter: number;
  42733. /** @hidden */
  42734. isOcclusionQueryInProgress: boolean;
  42735. /** @hidden */
  42736. isOccluded: boolean;
  42737. /** @hidden */
  42738. occlusionRetryCount: number;
  42739. /** @hidden */
  42740. occlusionType: number;
  42741. /** @hidden */
  42742. occlusionQueryAlgorithmType: number;
  42743. }
  42744. module "babylonjs/Engines/engine" {
  42745. interface Engine {
  42746. /**
  42747. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42748. * @return the new query
  42749. */
  42750. createQuery(): WebGLQuery;
  42751. /**
  42752. * Delete and release a webGL query
  42753. * @param query defines the query to delete
  42754. * @return the current engine
  42755. */
  42756. deleteQuery(query: WebGLQuery): Engine;
  42757. /**
  42758. * Check if a given query has resolved and got its value
  42759. * @param query defines the query to check
  42760. * @returns true if the query got its value
  42761. */
  42762. isQueryResultAvailable(query: WebGLQuery): boolean;
  42763. /**
  42764. * Gets the value of a given query
  42765. * @param query defines the query to check
  42766. * @returns the value of the query
  42767. */
  42768. getQueryResult(query: WebGLQuery): number;
  42769. /**
  42770. * Initiates an occlusion query
  42771. * @param algorithmType defines the algorithm to use
  42772. * @param query defines the query to use
  42773. * @returns the current engine
  42774. * @see http://doc.babylonjs.com/features/occlusionquery
  42775. */
  42776. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42777. /**
  42778. * Ends an occlusion query
  42779. * @see http://doc.babylonjs.com/features/occlusionquery
  42780. * @param algorithmType defines the algorithm to use
  42781. * @returns the current engine
  42782. */
  42783. endOcclusionQuery(algorithmType: number): Engine;
  42784. /**
  42785. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42786. * Please note that only one query can be issued at a time
  42787. * @returns a time token used to track the time span
  42788. */
  42789. startTimeQuery(): Nullable<_TimeToken>;
  42790. /**
  42791. * Ends a time query
  42792. * @param token defines the token used to measure the time span
  42793. * @returns the time spent (in ns)
  42794. */
  42795. endTimeQuery(token: _TimeToken): int;
  42796. /** @hidden */
  42797. _currentNonTimestampToken: Nullable<_TimeToken>;
  42798. /** @hidden */
  42799. _createTimeQuery(): WebGLQuery;
  42800. /** @hidden */
  42801. _deleteTimeQuery(query: WebGLQuery): void;
  42802. /** @hidden */
  42803. _getGlAlgorithmType(algorithmType: number): number;
  42804. /** @hidden */
  42805. _getTimeQueryResult(query: WebGLQuery): any;
  42806. /** @hidden */
  42807. _getTimeQueryAvailability(query: WebGLQuery): any;
  42808. }
  42809. }
  42810. module "babylonjs/Meshes/abstractMesh" {
  42811. interface AbstractMesh {
  42812. /**
  42813. * Backing filed
  42814. * @hidden
  42815. */
  42816. __occlusionDataStorage: _OcclusionDataStorage;
  42817. /**
  42818. * Access property
  42819. * @hidden
  42820. */
  42821. _occlusionDataStorage: _OcclusionDataStorage;
  42822. /**
  42823. * 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.
  42824. * The default value is -1 which means don't break the query and wait till the result
  42825. * @see http://doc.babylonjs.com/features/occlusionquery
  42826. */
  42827. occlusionRetryCount: number;
  42828. /**
  42829. * 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:
  42830. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42831. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42832. * * 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.
  42833. * @see http://doc.babylonjs.com/features/occlusionquery
  42834. */
  42835. occlusionType: number;
  42836. /**
  42837. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42838. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42839. * * 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.
  42840. * @see http://doc.babylonjs.com/features/occlusionquery
  42841. */
  42842. occlusionQueryAlgorithmType: number;
  42843. /**
  42844. * 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
  42845. * @see http://doc.babylonjs.com/features/occlusionquery
  42846. */
  42847. isOccluded: boolean;
  42848. /**
  42849. * Flag to check the progress status of the query
  42850. * @see http://doc.babylonjs.com/features/occlusionquery
  42851. */
  42852. isOcclusionQueryInProgress: boolean;
  42853. }
  42854. }
  42855. }
  42856. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42857. import { Nullable } from "babylonjs/types";
  42858. /** @hidden */
  42859. export var _forceTransformFeedbackToBundle: boolean;
  42860. module "babylonjs/Engines/engine" {
  42861. interface Engine {
  42862. /**
  42863. * Creates a webGL transform feedback object
  42864. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42865. * @returns the webGL transform feedback object
  42866. */
  42867. createTransformFeedback(): WebGLTransformFeedback;
  42868. /**
  42869. * Delete a webGL transform feedback object
  42870. * @param value defines the webGL transform feedback object to delete
  42871. */
  42872. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42873. /**
  42874. * Bind a webGL transform feedback object to the webgl context
  42875. * @param value defines the webGL transform feedback object to bind
  42876. */
  42877. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42878. /**
  42879. * Begins a transform feedback operation
  42880. * @param usePoints defines if points or triangles must be used
  42881. */
  42882. beginTransformFeedback(usePoints: boolean): void;
  42883. /**
  42884. * Ends a transform feedback operation
  42885. */
  42886. endTransformFeedback(): void;
  42887. /**
  42888. * Specify the varyings to use with transform feedback
  42889. * @param program defines the associated webGL program
  42890. * @param value defines the list of strings representing the varying names
  42891. */
  42892. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42893. /**
  42894. * Bind a webGL buffer for a transform feedback operation
  42895. * @param value defines the webGL buffer to bind
  42896. */
  42897. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42898. }
  42899. }
  42900. }
  42901. declare module "babylonjs/Engines/Extensions/index" {
  42902. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42903. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42904. export * from "babylonjs/Engines/Extensions/engine.multiview";
  42905. }
  42906. declare module "babylonjs/Engines/index" {
  42907. export * from "babylonjs/Engines/constants";
  42908. export * from "babylonjs/Engines/engine";
  42909. export * from "babylonjs/Engines/engineStore";
  42910. export * from "babylonjs/Engines/nullEngine";
  42911. export * from "babylonjs/Engines/Extensions/index";
  42912. }
  42913. declare module "babylonjs/Events/clipboardEvents" {
  42914. /**
  42915. * Gather the list of clipboard event types as constants.
  42916. */
  42917. export class ClipboardEventTypes {
  42918. /**
  42919. * The clipboard event is fired when a copy command is active (pressed).
  42920. */
  42921. static readonly COPY: number;
  42922. /**
  42923. * The clipboard event is fired when a cut command is active (pressed).
  42924. */
  42925. static readonly CUT: number;
  42926. /**
  42927. * The clipboard event is fired when a paste command is active (pressed).
  42928. */
  42929. static readonly PASTE: number;
  42930. }
  42931. /**
  42932. * This class is used to store clipboard related info for the onClipboardObservable event.
  42933. */
  42934. export class ClipboardInfo {
  42935. /**
  42936. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42937. */
  42938. type: number;
  42939. /**
  42940. * Defines the related dom event
  42941. */
  42942. event: ClipboardEvent;
  42943. /**
  42944. *Creates an instance of ClipboardInfo.
  42945. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42946. * @param event Defines the related dom event
  42947. */
  42948. constructor(
  42949. /**
  42950. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42951. */
  42952. type: number,
  42953. /**
  42954. * Defines the related dom event
  42955. */
  42956. event: ClipboardEvent);
  42957. /**
  42958. * Get the clipboard event's type from the keycode.
  42959. * @param keyCode Defines the keyCode for the current keyboard event.
  42960. * @return {number}
  42961. */
  42962. static GetTypeFromCharacter(keyCode: number): number;
  42963. }
  42964. }
  42965. declare module "babylonjs/Events/index" {
  42966. export * from "babylonjs/Events/keyboardEvents";
  42967. export * from "babylonjs/Events/pointerEvents";
  42968. export * from "babylonjs/Events/clipboardEvents";
  42969. }
  42970. declare module "babylonjs/Loading/sceneLoader" {
  42971. import { Observable } from "babylonjs/Misc/observable";
  42972. import { Nullable } from "babylonjs/types";
  42973. import { Scene } from "babylonjs/scene";
  42974. import { Engine } from "babylonjs/Engines/engine";
  42975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42976. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42977. import { AssetContainer } from "babylonjs/assetContainer";
  42978. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42979. import { Skeleton } from "babylonjs/Bones/skeleton";
  42980. /**
  42981. * Class used to represent data loading progression
  42982. */
  42983. export class SceneLoaderProgressEvent {
  42984. /** defines if data length to load can be evaluated */
  42985. readonly lengthComputable: boolean;
  42986. /** defines the loaded data length */
  42987. readonly loaded: number;
  42988. /** defines the data length to load */
  42989. readonly total: number;
  42990. /**
  42991. * Create a new progress event
  42992. * @param lengthComputable defines if data length to load can be evaluated
  42993. * @param loaded defines the loaded data length
  42994. * @param total defines the data length to load
  42995. */
  42996. constructor(
  42997. /** defines if data length to load can be evaluated */
  42998. lengthComputable: boolean,
  42999. /** defines the loaded data length */
  43000. loaded: number,
  43001. /** defines the data length to load */
  43002. total: number);
  43003. /**
  43004. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43005. * @param event defines the source event
  43006. * @returns a new SceneLoaderProgressEvent
  43007. */
  43008. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43009. }
  43010. /**
  43011. * Interface used by SceneLoader plugins to define supported file extensions
  43012. */
  43013. export interface ISceneLoaderPluginExtensions {
  43014. /**
  43015. * Defines the list of supported extensions
  43016. */
  43017. [extension: string]: {
  43018. isBinary: boolean;
  43019. };
  43020. }
  43021. /**
  43022. * Interface used by SceneLoader plugin factory
  43023. */
  43024. export interface ISceneLoaderPluginFactory {
  43025. /**
  43026. * Defines the name of the factory
  43027. */
  43028. name: string;
  43029. /**
  43030. * Function called to create a new plugin
  43031. * @return the new plugin
  43032. */
  43033. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43034. /**
  43035. * Boolean indicating if the plugin can direct load specific data
  43036. */
  43037. canDirectLoad?: (data: string) => boolean;
  43038. }
  43039. /**
  43040. * Interface used to define a SceneLoader plugin
  43041. */
  43042. export interface ISceneLoaderPlugin {
  43043. /**
  43044. * The friendly name of this plugin.
  43045. */
  43046. name: string;
  43047. /**
  43048. * The file extensions supported by this plugin.
  43049. */
  43050. extensions: string | ISceneLoaderPluginExtensions;
  43051. /**
  43052. * Import meshes into a scene.
  43053. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43054. * @param scene The scene to import into
  43055. * @param data The data to import
  43056. * @param rootUrl The root url for scene and resources
  43057. * @param meshes The meshes array to import into
  43058. * @param particleSystems The particle systems array to import into
  43059. * @param skeletons The skeletons array to import into
  43060. * @param onError The callback when import fails
  43061. * @returns True if successful or false otherwise
  43062. */
  43063. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43064. /**
  43065. * Load into a scene.
  43066. * @param scene The scene to load into
  43067. * @param data The data to import
  43068. * @param rootUrl The root url for scene and resources
  43069. * @param onError The callback when import fails
  43070. * @returns true if successful or false otherwise
  43071. */
  43072. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43073. /**
  43074. * The callback that returns true if the data can be directly loaded.
  43075. */
  43076. canDirectLoad?: (data: string) => boolean;
  43077. /**
  43078. * The callback that allows custom handling of the root url based on the response url.
  43079. */
  43080. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43081. /**
  43082. * Load into an asset container.
  43083. * @param scene The scene to load into
  43084. * @param data The data to import
  43085. * @param rootUrl The root url for scene and resources
  43086. * @param onError The callback when import fails
  43087. * @returns The loaded asset container
  43088. */
  43089. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43090. }
  43091. /**
  43092. * Interface used to define an async SceneLoader plugin
  43093. */
  43094. export interface ISceneLoaderPluginAsync {
  43095. /**
  43096. * The friendly name of this plugin.
  43097. */
  43098. name: string;
  43099. /**
  43100. * The file extensions supported by this plugin.
  43101. */
  43102. extensions: string | ISceneLoaderPluginExtensions;
  43103. /**
  43104. * Import meshes into a scene.
  43105. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43106. * @param scene The scene to import into
  43107. * @param data The data to import
  43108. * @param rootUrl The root url for scene and resources
  43109. * @param onProgress The callback when the load progresses
  43110. * @param fileName Defines the name of the file to load
  43111. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43112. */
  43113. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43114. meshes: AbstractMesh[];
  43115. particleSystems: IParticleSystem[];
  43116. skeletons: Skeleton[];
  43117. animationGroups: AnimationGroup[];
  43118. }>;
  43119. /**
  43120. * Load into a scene.
  43121. * @param scene The scene to load into
  43122. * @param data The data to import
  43123. * @param rootUrl The root url for scene and resources
  43124. * @param onProgress The callback when the load progresses
  43125. * @param fileName Defines the name of the file to load
  43126. * @returns Nothing
  43127. */
  43128. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43129. /**
  43130. * The callback that returns true if the data can be directly loaded.
  43131. */
  43132. canDirectLoad?: (data: string) => boolean;
  43133. /**
  43134. * The callback that allows custom handling of the root url based on the response url.
  43135. */
  43136. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43137. /**
  43138. * Load into an asset container.
  43139. * @param scene The scene to load into
  43140. * @param data The data to import
  43141. * @param rootUrl The root url for scene and resources
  43142. * @param onProgress The callback when the load progresses
  43143. * @param fileName Defines the name of the file to load
  43144. * @returns The loaded asset container
  43145. */
  43146. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43147. }
  43148. /**
  43149. * Class used to load scene from various file formats using registered plugins
  43150. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43151. */
  43152. export class SceneLoader {
  43153. /**
  43154. * No logging while loading
  43155. */
  43156. static readonly NO_LOGGING: number;
  43157. /**
  43158. * Minimal logging while loading
  43159. */
  43160. static readonly MINIMAL_LOGGING: number;
  43161. /**
  43162. * Summary logging while loading
  43163. */
  43164. static readonly SUMMARY_LOGGING: number;
  43165. /**
  43166. * Detailled logging while loading
  43167. */
  43168. static readonly DETAILED_LOGGING: number;
  43169. /**
  43170. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43171. */
  43172. static ForceFullSceneLoadingForIncremental: boolean;
  43173. /**
  43174. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43175. */
  43176. static ShowLoadingScreen: boolean;
  43177. /**
  43178. * Defines the current logging level (while loading the scene)
  43179. * @ignorenaming
  43180. */
  43181. static loggingLevel: number;
  43182. /**
  43183. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43184. */
  43185. static CleanBoneMatrixWeights: boolean;
  43186. /**
  43187. * Event raised when a plugin is used to load a scene
  43188. */
  43189. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43190. private static _registeredPlugins;
  43191. private static _getDefaultPlugin;
  43192. private static _getPluginForExtension;
  43193. private static _getPluginForDirectLoad;
  43194. private static _getPluginForFilename;
  43195. private static _getDirectLoad;
  43196. private static _loadData;
  43197. private static _getFileInfo;
  43198. /**
  43199. * Gets a plugin that can load the given extension
  43200. * @param extension defines the extension to load
  43201. * @returns a plugin or null if none works
  43202. */
  43203. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43204. /**
  43205. * Gets a boolean indicating that the given extension can be loaded
  43206. * @param extension defines the extension to load
  43207. * @returns true if the extension is supported
  43208. */
  43209. static IsPluginForExtensionAvailable(extension: string): boolean;
  43210. /**
  43211. * Adds a new plugin to the list of registered plugins
  43212. * @param plugin defines the plugin to add
  43213. */
  43214. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43215. /**
  43216. * Import meshes into a scene
  43217. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43218. * @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)
  43219. * @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)
  43220. * @param scene the instance of BABYLON.Scene to append to
  43221. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43222. * @param onProgress a callback with a progress event for each file being loaded
  43223. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43224. * @param pluginExtension the extension used to determine the plugin
  43225. * @returns The loaded plugin
  43226. */
  43227. 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>;
  43228. /**
  43229. * Import meshes into a scene
  43230. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43231. * @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)
  43232. * @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)
  43233. * @param scene the instance of BABYLON.Scene to append to
  43234. * @param onProgress a callback with a progress event for each file being loaded
  43235. * @param pluginExtension the extension used to determine the plugin
  43236. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43237. */
  43238. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43239. meshes: AbstractMesh[];
  43240. particleSystems: IParticleSystem[];
  43241. skeletons: Skeleton[];
  43242. animationGroups: AnimationGroup[];
  43243. }>;
  43244. /**
  43245. * Load a scene
  43246. * @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)
  43247. * @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)
  43248. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43249. * @param onSuccess a callback with the scene when import succeeds
  43250. * @param onProgress a callback with a progress event for each file being loaded
  43251. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43252. * @param pluginExtension the extension used to determine the plugin
  43253. * @returns The loaded plugin
  43254. */
  43255. 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>;
  43256. /**
  43257. * Load a scene
  43258. * @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)
  43259. * @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)
  43260. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43261. * @param onProgress a callback with a progress event for each file being loaded
  43262. * @param pluginExtension the extension used to determine the plugin
  43263. * @returns The loaded scene
  43264. */
  43265. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43266. /**
  43267. * Append a scene
  43268. * @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)
  43269. * @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)
  43270. * @param scene is the instance of BABYLON.Scene to append to
  43271. * @param onSuccess a callback with the scene when import succeeds
  43272. * @param onProgress a callback with a progress event for each file being loaded
  43273. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43274. * @param pluginExtension the extension used to determine the plugin
  43275. * @returns The loaded plugin
  43276. */
  43277. 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>;
  43278. /**
  43279. * Append a scene
  43280. * @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)
  43281. * @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)
  43282. * @param scene is the instance of BABYLON.Scene to append to
  43283. * @param onProgress a callback with a progress event for each file being loaded
  43284. * @param pluginExtension the extension used to determine the plugin
  43285. * @returns The given scene
  43286. */
  43287. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43288. /**
  43289. * Load a scene into an asset container
  43290. * @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)
  43291. * @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)
  43292. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43293. * @param onSuccess a callback with the scene when import succeeds
  43294. * @param onProgress a callback with a progress event for each file being loaded
  43295. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43296. * @param pluginExtension the extension used to determine the plugin
  43297. * @returns The loaded plugin
  43298. */
  43299. 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>;
  43300. /**
  43301. * Load a scene into an asset container
  43302. * @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)
  43303. * @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)
  43304. * @param scene is the instance of Scene to append to
  43305. * @param onProgress a callback with a progress event for each file being loaded
  43306. * @param pluginExtension the extension used to determine the plugin
  43307. * @returns The loaded asset container
  43308. */
  43309. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43310. }
  43311. }
  43312. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43313. import { Scene } from "babylonjs/scene";
  43314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43315. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43316. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43317. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43318. /**
  43319. * Google Daydream controller
  43320. */
  43321. export class DaydreamController extends WebVRController {
  43322. /**
  43323. * Base Url for the controller model.
  43324. */
  43325. static MODEL_BASE_URL: string;
  43326. /**
  43327. * File name for the controller model.
  43328. */
  43329. static MODEL_FILENAME: string;
  43330. /**
  43331. * Gamepad Id prefix used to identify Daydream Controller.
  43332. */
  43333. static readonly GAMEPAD_ID_PREFIX: string;
  43334. /**
  43335. * Creates a new DaydreamController from a gamepad
  43336. * @param vrGamepad the gamepad that the controller should be created from
  43337. */
  43338. constructor(vrGamepad: any);
  43339. /**
  43340. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43341. * @param scene scene in which to add meshes
  43342. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43343. */
  43344. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43345. /**
  43346. * Called once for each button that changed state since the last frame
  43347. * @param buttonIdx Which button index changed
  43348. * @param state New state of the button
  43349. * @param changes Which properties on the state changed since last frame
  43350. */
  43351. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43352. }
  43353. }
  43354. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43355. import { Scene } from "babylonjs/scene";
  43356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43357. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43358. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43359. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43360. /**
  43361. * Gear VR Controller
  43362. */
  43363. export class GearVRController extends WebVRController {
  43364. /**
  43365. * Base Url for the controller model.
  43366. */
  43367. static MODEL_BASE_URL: string;
  43368. /**
  43369. * File name for the controller model.
  43370. */
  43371. static MODEL_FILENAME: string;
  43372. /**
  43373. * Gamepad Id prefix used to identify this controller.
  43374. */
  43375. static readonly GAMEPAD_ID_PREFIX: string;
  43376. private readonly _buttonIndexToObservableNameMap;
  43377. /**
  43378. * Creates a new GearVRController from a gamepad
  43379. * @param vrGamepad the gamepad that the controller should be created from
  43380. */
  43381. constructor(vrGamepad: any);
  43382. /**
  43383. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43384. * @param scene scene in which to add meshes
  43385. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43386. */
  43387. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43388. /**
  43389. * Called once for each button that changed state since the last frame
  43390. * @param buttonIdx Which button index changed
  43391. * @param state New state of the button
  43392. * @param changes Which properties on the state changed since last frame
  43393. */
  43394. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43395. }
  43396. }
  43397. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43398. import { Scene } from "babylonjs/scene";
  43399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43400. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43401. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43402. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43403. /**
  43404. * Generic Controller
  43405. */
  43406. export class GenericController extends WebVRController {
  43407. /**
  43408. * Base Url for the controller model.
  43409. */
  43410. static readonly MODEL_BASE_URL: string;
  43411. /**
  43412. * File name for the controller model.
  43413. */
  43414. static readonly MODEL_FILENAME: string;
  43415. /**
  43416. * Creates a new GenericController from a gamepad
  43417. * @param vrGamepad the gamepad that the controller should be created from
  43418. */
  43419. constructor(vrGamepad: any);
  43420. /**
  43421. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43422. * @param scene scene in which to add meshes
  43423. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43424. */
  43425. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43426. /**
  43427. * Called once for each button that changed state since the last frame
  43428. * @param buttonIdx Which button index changed
  43429. * @param state New state of the button
  43430. * @param changes Which properties on the state changed since last frame
  43431. */
  43432. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43433. }
  43434. }
  43435. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43436. import { Observable } from "babylonjs/Misc/observable";
  43437. import { Scene } from "babylonjs/scene";
  43438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43439. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43440. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43441. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43442. /**
  43443. * Oculus Touch Controller
  43444. */
  43445. export class OculusTouchController extends WebVRController {
  43446. /**
  43447. * Base Url for the controller model.
  43448. */
  43449. static MODEL_BASE_URL: string;
  43450. /**
  43451. * File name for the left controller model.
  43452. */
  43453. static MODEL_LEFT_FILENAME: string;
  43454. /**
  43455. * File name for the right controller model.
  43456. */
  43457. static MODEL_RIGHT_FILENAME: string;
  43458. /**
  43459. * Fired when the secondary trigger on this controller is modified
  43460. */
  43461. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43462. /**
  43463. * Fired when the thumb rest on this controller is modified
  43464. */
  43465. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43466. /**
  43467. * Creates a new OculusTouchController from a gamepad
  43468. * @param vrGamepad the gamepad that the controller should be created from
  43469. */
  43470. constructor(vrGamepad: any);
  43471. /**
  43472. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43473. * @param scene scene in which to add meshes
  43474. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43475. */
  43476. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43477. /**
  43478. * Fired when the A button on this controller is modified
  43479. */
  43480. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43481. /**
  43482. * Fired when the B button on this controller is modified
  43483. */
  43484. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43485. /**
  43486. * Fired when the X button on this controller is modified
  43487. */
  43488. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43489. /**
  43490. * Fired when the Y button on this controller is modified
  43491. */
  43492. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43493. /**
  43494. * Called once for each button that changed state since the last frame
  43495. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43496. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43497. * 2) secondary trigger (same)
  43498. * 3) A (right) X (left), touch, pressed = value
  43499. * 4) B / Y
  43500. * 5) thumb rest
  43501. * @param buttonIdx Which button index changed
  43502. * @param state New state of the button
  43503. * @param changes Which properties on the state changed since last frame
  43504. */
  43505. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43506. }
  43507. }
  43508. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43509. import { Scene } from "babylonjs/scene";
  43510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43511. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43512. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43513. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43514. import { Observable } from "babylonjs/Misc/observable";
  43515. /**
  43516. * Vive Controller
  43517. */
  43518. export class ViveController extends WebVRController {
  43519. /**
  43520. * Base Url for the controller model.
  43521. */
  43522. static MODEL_BASE_URL: string;
  43523. /**
  43524. * File name for the controller model.
  43525. */
  43526. static MODEL_FILENAME: string;
  43527. /**
  43528. * Creates a new ViveController from a gamepad
  43529. * @param vrGamepad the gamepad that the controller should be created from
  43530. */
  43531. constructor(vrGamepad: any);
  43532. /**
  43533. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43534. * @param scene scene in which to add meshes
  43535. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43536. */
  43537. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43538. /**
  43539. * Fired when the left button on this controller is modified
  43540. */
  43541. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43542. /**
  43543. * Fired when the right button on this controller is modified
  43544. */
  43545. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43546. /**
  43547. * Fired when the menu button on this controller is modified
  43548. */
  43549. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43550. /**
  43551. * Called once for each button that changed state since the last frame
  43552. * Vive mapping:
  43553. * 0: touchpad
  43554. * 1: trigger
  43555. * 2: left AND right buttons
  43556. * 3: menu button
  43557. * @param buttonIdx Which button index changed
  43558. * @param state New state of the button
  43559. * @param changes Which properties on the state changed since last frame
  43560. */
  43561. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43562. }
  43563. }
  43564. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43565. import { Observable } from "babylonjs/Misc/observable";
  43566. import { Scene } from "babylonjs/scene";
  43567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43568. import { Ray } from "babylonjs/Culling/ray";
  43569. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43570. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43571. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43572. /**
  43573. * Defines the WindowsMotionController object that the state of the windows motion controller
  43574. */
  43575. export class WindowsMotionController extends WebVRController {
  43576. /**
  43577. * The base url used to load the left and right controller models
  43578. */
  43579. static MODEL_BASE_URL: string;
  43580. /**
  43581. * The name of the left controller model file
  43582. */
  43583. static MODEL_LEFT_FILENAME: string;
  43584. /**
  43585. * The name of the right controller model file
  43586. */
  43587. static MODEL_RIGHT_FILENAME: string;
  43588. /**
  43589. * The controller name prefix for this controller type
  43590. */
  43591. static readonly GAMEPAD_ID_PREFIX: string;
  43592. /**
  43593. * The controller id pattern for this controller type
  43594. */
  43595. private static readonly GAMEPAD_ID_PATTERN;
  43596. private _loadedMeshInfo;
  43597. private readonly _mapping;
  43598. /**
  43599. * Fired when the trackpad on this controller is clicked
  43600. */
  43601. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43602. /**
  43603. * Fired when the trackpad on this controller is modified
  43604. */
  43605. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43606. /**
  43607. * The current x and y values of this controller's trackpad
  43608. */
  43609. trackpad: StickValues;
  43610. /**
  43611. * Creates a new WindowsMotionController from a gamepad
  43612. * @param vrGamepad the gamepad that the controller should be created from
  43613. */
  43614. constructor(vrGamepad: any);
  43615. /**
  43616. * Fired when the trigger on this controller is modified
  43617. */
  43618. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43619. /**
  43620. * Fired when the menu button on this controller is modified
  43621. */
  43622. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43623. /**
  43624. * Fired when the grip button on this controller is modified
  43625. */
  43626. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43627. /**
  43628. * Fired when the thumbstick button on this controller is modified
  43629. */
  43630. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43631. /**
  43632. * Fired when the touchpad button on this controller is modified
  43633. */
  43634. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43635. /**
  43636. * Fired when the touchpad values on this controller are modified
  43637. */
  43638. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43639. private _updateTrackpad;
  43640. /**
  43641. * Called once per frame by the engine.
  43642. */
  43643. update(): void;
  43644. /**
  43645. * Called once for each button that changed state since the last frame
  43646. * @param buttonIdx Which button index changed
  43647. * @param state New state of the button
  43648. * @param changes Which properties on the state changed since last frame
  43649. */
  43650. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43651. /**
  43652. * Moves the buttons on the controller mesh based on their current state
  43653. * @param buttonName the name of the button to move
  43654. * @param buttonValue the value of the button which determines the buttons new position
  43655. */
  43656. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43657. /**
  43658. * Moves the axis on the controller mesh based on its current state
  43659. * @param axis the index of the axis
  43660. * @param axisValue the value of the axis which determines the meshes new position
  43661. * @hidden
  43662. */
  43663. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43664. /**
  43665. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43666. * @param scene scene in which to add meshes
  43667. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43668. */
  43669. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43670. /**
  43671. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43672. * can be transformed by button presses and axes values, based on this._mapping.
  43673. *
  43674. * @param scene scene in which the meshes exist
  43675. * @param meshes list of meshes that make up the controller model to process
  43676. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43677. */
  43678. private processModel;
  43679. private createMeshInfo;
  43680. /**
  43681. * Gets the ray of the controller in the direction the controller is pointing
  43682. * @param length the length the resulting ray should be
  43683. * @returns a ray in the direction the controller is pointing
  43684. */
  43685. getForwardRay(length?: number): Ray;
  43686. /**
  43687. * Disposes of the controller
  43688. */
  43689. dispose(): void;
  43690. }
  43691. }
  43692. declare module "babylonjs/Gamepads/Controllers/index" {
  43693. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43694. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43695. export * from "babylonjs/Gamepads/Controllers/genericController";
  43696. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43697. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43698. export * from "babylonjs/Gamepads/Controllers/viveController";
  43699. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43700. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43701. }
  43702. declare module "babylonjs/Gamepads/index" {
  43703. export * from "babylonjs/Gamepads/Controllers/index";
  43704. export * from "babylonjs/Gamepads/gamepad";
  43705. export * from "babylonjs/Gamepads/gamepadManager";
  43706. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43707. export * from "babylonjs/Gamepads/xboxGamepad";
  43708. }
  43709. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43710. import { Observable } from "babylonjs/Misc/observable";
  43711. import { Nullable } from "babylonjs/types";
  43712. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43714. import { Mesh } from "babylonjs/Meshes/mesh";
  43715. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43716. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43717. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43718. /**
  43719. * Single axis scale gizmo
  43720. */
  43721. export class AxisScaleGizmo extends Gizmo {
  43722. private _coloredMaterial;
  43723. /**
  43724. * Drag behavior responsible for the gizmos dragging interactions
  43725. */
  43726. dragBehavior: PointerDragBehavior;
  43727. private _pointerObserver;
  43728. /**
  43729. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43730. */
  43731. snapDistance: number;
  43732. /**
  43733. * Event that fires each time the gizmo snaps to a new location.
  43734. * * snapDistance is the the change in distance
  43735. */
  43736. onSnapObservable: Observable<{
  43737. snapDistance: number;
  43738. }>;
  43739. /**
  43740. * If the scaling operation should be done on all axis (default: false)
  43741. */
  43742. uniformScaling: boolean;
  43743. /**
  43744. * Creates an AxisScaleGizmo
  43745. * @param gizmoLayer The utility layer the gizmo will be added to
  43746. * @param dragAxis The axis which the gizmo will be able to scale on
  43747. * @param color The color of the gizmo
  43748. */
  43749. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43750. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43751. /**
  43752. * Disposes of the gizmo
  43753. */
  43754. dispose(): void;
  43755. /**
  43756. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43757. * @param mesh The mesh to replace the default mesh of the gizmo
  43758. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43759. */
  43760. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43761. }
  43762. }
  43763. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43764. import { Observable } from "babylonjs/Misc/observable";
  43765. import { Nullable } from "babylonjs/types";
  43766. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43768. import { Mesh } from "babylonjs/Meshes/mesh";
  43769. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43770. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43771. import "babylonjs/Meshes/Builders/boxBuilder";
  43772. /**
  43773. * Bounding box gizmo
  43774. */
  43775. export class BoundingBoxGizmo extends Gizmo {
  43776. private _lineBoundingBox;
  43777. private _rotateSpheresParent;
  43778. private _scaleBoxesParent;
  43779. private _boundingDimensions;
  43780. private _renderObserver;
  43781. private _pointerObserver;
  43782. private _scaleDragSpeed;
  43783. private _tmpQuaternion;
  43784. private _tmpVector;
  43785. private _tmpRotationMatrix;
  43786. /**
  43787. * 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)
  43788. */
  43789. ignoreChildren: boolean;
  43790. /**
  43791. * 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)
  43792. */
  43793. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43794. /**
  43795. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43796. */
  43797. rotationSphereSize: number;
  43798. /**
  43799. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43800. */
  43801. scaleBoxSize: number;
  43802. /**
  43803. * 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)
  43804. */
  43805. fixedDragMeshScreenSize: boolean;
  43806. /**
  43807. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43808. */
  43809. fixedDragMeshScreenSizeDistanceFactor: number;
  43810. /**
  43811. * Fired when a rotation sphere or scale box is dragged
  43812. */
  43813. onDragStartObservable: Observable<{}>;
  43814. /**
  43815. * Fired when a scale box is dragged
  43816. */
  43817. onScaleBoxDragObservable: Observable<{}>;
  43818. /**
  43819. * Fired when a scale box drag is ended
  43820. */
  43821. onScaleBoxDragEndObservable: Observable<{}>;
  43822. /**
  43823. * Fired when a rotation sphere is dragged
  43824. */
  43825. onRotationSphereDragObservable: Observable<{}>;
  43826. /**
  43827. * Fired when a rotation sphere drag is ended
  43828. */
  43829. onRotationSphereDragEndObservable: Observable<{}>;
  43830. /**
  43831. * 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)
  43832. */
  43833. scalePivot: Nullable<Vector3>;
  43834. private _anchorMesh;
  43835. private _existingMeshScale;
  43836. private _dragMesh;
  43837. private pointerDragBehavior;
  43838. private coloredMaterial;
  43839. private hoverColoredMaterial;
  43840. /**
  43841. * Sets the color of the bounding box gizmo
  43842. * @param color the color to set
  43843. */
  43844. setColor(color: Color3): void;
  43845. /**
  43846. * Creates an BoundingBoxGizmo
  43847. * @param gizmoLayer The utility layer the gizmo will be added to
  43848. * @param color The color of the gizmo
  43849. */
  43850. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43851. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43852. private _selectNode;
  43853. /**
  43854. * Updates the bounding box information for the Gizmo
  43855. */
  43856. updateBoundingBox(): void;
  43857. private _updateRotationSpheres;
  43858. private _updateScaleBoxes;
  43859. /**
  43860. * Enables rotation on the specified axis and disables rotation on the others
  43861. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43862. */
  43863. setEnabledRotationAxis(axis: string): void;
  43864. /**
  43865. * Enables/disables scaling
  43866. * @param enable if scaling should be enabled
  43867. */
  43868. setEnabledScaling(enable: boolean): void;
  43869. private _updateDummy;
  43870. /**
  43871. * Enables a pointer drag behavior on the bounding box of the gizmo
  43872. */
  43873. enableDragBehavior(): void;
  43874. /**
  43875. * Disposes of the gizmo
  43876. */
  43877. dispose(): void;
  43878. /**
  43879. * 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)
  43880. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43881. * @returns the bounding box mesh with the passed in mesh as a child
  43882. */
  43883. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43884. /**
  43885. * CustomMeshes are not supported by this gizmo
  43886. * @param mesh The mesh to replace the default mesh of the gizmo
  43887. */
  43888. setCustomMesh(mesh: Mesh): void;
  43889. }
  43890. }
  43891. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43892. import { Observable } from "babylonjs/Misc/observable";
  43893. import { Nullable } from "babylonjs/types";
  43894. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43896. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43897. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43898. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43899. import "babylonjs/Meshes/Builders/linesBuilder";
  43900. /**
  43901. * Single plane rotation gizmo
  43902. */
  43903. export class PlaneRotationGizmo extends Gizmo {
  43904. /**
  43905. * Drag behavior responsible for the gizmos dragging interactions
  43906. */
  43907. dragBehavior: PointerDragBehavior;
  43908. private _pointerObserver;
  43909. /**
  43910. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43911. */
  43912. snapDistance: number;
  43913. /**
  43914. * Event that fires each time the gizmo snaps to a new location.
  43915. * * snapDistance is the the change in distance
  43916. */
  43917. onSnapObservable: Observable<{
  43918. snapDistance: number;
  43919. }>;
  43920. /**
  43921. * Creates a PlaneRotationGizmo
  43922. * @param gizmoLayer The utility layer the gizmo will be added to
  43923. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43924. * @param color The color of the gizmo
  43925. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43926. */
  43927. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43928. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43929. /**
  43930. * Disposes of the gizmo
  43931. */
  43932. dispose(): void;
  43933. }
  43934. }
  43935. declare module "babylonjs/Gizmos/rotationGizmo" {
  43936. import { Observable } from "babylonjs/Misc/observable";
  43937. import { Nullable } from "babylonjs/types";
  43938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43939. import { Mesh } from "babylonjs/Meshes/mesh";
  43940. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43941. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43942. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43943. /**
  43944. * Gizmo that enables rotating a mesh along 3 axis
  43945. */
  43946. export class RotationGizmo extends Gizmo {
  43947. /**
  43948. * Internal gizmo used for interactions on the x axis
  43949. */
  43950. xGizmo: PlaneRotationGizmo;
  43951. /**
  43952. * Internal gizmo used for interactions on the y axis
  43953. */
  43954. yGizmo: PlaneRotationGizmo;
  43955. /**
  43956. * Internal gizmo used for interactions on the z axis
  43957. */
  43958. zGizmo: PlaneRotationGizmo;
  43959. /** Fires an event when any of it's sub gizmos are dragged */
  43960. onDragStartObservable: Observable<{}>;
  43961. /** Fires an event when any of it's sub gizmos are released from dragging */
  43962. onDragEndObservable: Observable<{}>;
  43963. attachedMesh: Nullable<AbstractMesh>;
  43964. /**
  43965. * Creates a RotationGizmo
  43966. * @param gizmoLayer The utility layer the gizmo will be added to
  43967. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43968. */
  43969. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43970. updateGizmoRotationToMatchAttachedMesh: boolean;
  43971. /**
  43972. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43973. */
  43974. snapDistance: number;
  43975. /**
  43976. * Ratio for the scale of the gizmo (Default: 1)
  43977. */
  43978. scaleRatio: number;
  43979. /**
  43980. * Disposes of the gizmo
  43981. */
  43982. dispose(): void;
  43983. /**
  43984. * CustomMeshes are not supported by this gizmo
  43985. * @param mesh The mesh to replace the default mesh of the gizmo
  43986. */
  43987. setCustomMesh(mesh: Mesh): void;
  43988. }
  43989. }
  43990. declare module "babylonjs/Gizmos/positionGizmo" {
  43991. import { Observable } from "babylonjs/Misc/observable";
  43992. import { Nullable } from "babylonjs/types";
  43993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43994. import { Mesh } from "babylonjs/Meshes/mesh";
  43995. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43996. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43997. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43998. /**
  43999. * Gizmo that enables dragging a mesh along 3 axis
  44000. */
  44001. export class PositionGizmo extends Gizmo {
  44002. /**
  44003. * Internal gizmo used for interactions on the x axis
  44004. */
  44005. xGizmo: AxisDragGizmo;
  44006. /**
  44007. * Internal gizmo used for interactions on the y axis
  44008. */
  44009. yGizmo: AxisDragGizmo;
  44010. /**
  44011. * Internal gizmo used for interactions on the z axis
  44012. */
  44013. zGizmo: AxisDragGizmo;
  44014. /** Fires an event when any of it's sub gizmos are dragged */
  44015. onDragStartObservable: Observable<{}>;
  44016. /** Fires an event when any of it's sub gizmos are released from dragging */
  44017. onDragEndObservable: Observable<{}>;
  44018. attachedMesh: Nullable<AbstractMesh>;
  44019. /**
  44020. * Creates a PositionGizmo
  44021. * @param gizmoLayer The utility layer the gizmo will be added to
  44022. */
  44023. constructor(gizmoLayer?: UtilityLayerRenderer);
  44024. updateGizmoRotationToMatchAttachedMesh: boolean;
  44025. /**
  44026. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44027. */
  44028. snapDistance: number;
  44029. /**
  44030. * Ratio for the scale of the gizmo (Default: 1)
  44031. */
  44032. scaleRatio: number;
  44033. /**
  44034. * Disposes of the gizmo
  44035. */
  44036. dispose(): void;
  44037. /**
  44038. * CustomMeshes are not supported by this gizmo
  44039. * @param mesh The mesh to replace the default mesh of the gizmo
  44040. */
  44041. setCustomMesh(mesh: Mesh): void;
  44042. }
  44043. }
  44044. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44045. import { Scene } from "babylonjs/scene";
  44046. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44047. import { Mesh } from "babylonjs/Meshes/mesh";
  44048. import { Nullable } from "babylonjs/types";
  44049. /**
  44050. * Class containing static functions to help procedurally build meshes
  44051. */
  44052. export class PolyhedronBuilder {
  44053. /**
  44054. * Creates a polyhedron mesh
  44055. * * 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
  44056. * * The parameter `size` (positive float, default 1) sets the polygon size
  44057. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44058. * * 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`
  44059. * * 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
  44060. * * 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)`)
  44061. * * 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
  44062. * * 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
  44063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44066. * @param name defines the name of the mesh
  44067. * @param options defines the options used to create the mesh
  44068. * @param scene defines the hosting scene
  44069. * @returns the polyhedron mesh
  44070. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44071. */
  44072. static CreatePolyhedron(name: string, options: {
  44073. type?: number;
  44074. size?: number;
  44075. sizeX?: number;
  44076. sizeY?: number;
  44077. sizeZ?: number;
  44078. custom?: any;
  44079. faceUV?: Vector4[];
  44080. faceColors?: Color4[];
  44081. flat?: boolean;
  44082. updatable?: boolean;
  44083. sideOrientation?: number;
  44084. frontUVs?: Vector4;
  44085. backUVs?: Vector4;
  44086. }, scene?: Nullable<Scene>): Mesh;
  44087. }
  44088. }
  44089. declare module "babylonjs/Gizmos/scaleGizmo" {
  44090. import { Observable } from "babylonjs/Misc/observable";
  44091. import { Nullable } from "babylonjs/types";
  44092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44093. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44094. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44095. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44096. /**
  44097. * Gizmo that enables scaling a mesh along 3 axis
  44098. */
  44099. export class ScaleGizmo extends Gizmo {
  44100. /**
  44101. * Internal gizmo used for interactions on the x axis
  44102. */
  44103. xGizmo: AxisScaleGizmo;
  44104. /**
  44105. * Internal gizmo used for interactions on the y axis
  44106. */
  44107. yGizmo: AxisScaleGizmo;
  44108. /**
  44109. * Internal gizmo used for interactions on the z axis
  44110. */
  44111. zGizmo: AxisScaleGizmo;
  44112. /**
  44113. * Internal gizmo used to scale all axis equally
  44114. */
  44115. uniformScaleGizmo: AxisScaleGizmo;
  44116. /** Fires an event when any of it's sub gizmos are dragged */
  44117. onDragStartObservable: Observable<{}>;
  44118. /** Fires an event when any of it's sub gizmos are released from dragging */
  44119. onDragEndObservable: Observable<{}>;
  44120. attachedMesh: Nullable<AbstractMesh>;
  44121. /**
  44122. * Creates a ScaleGizmo
  44123. * @param gizmoLayer The utility layer the gizmo will be added to
  44124. */
  44125. constructor(gizmoLayer?: UtilityLayerRenderer);
  44126. updateGizmoRotationToMatchAttachedMesh: boolean;
  44127. /**
  44128. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44129. */
  44130. snapDistance: number;
  44131. /**
  44132. * Ratio for the scale of the gizmo (Default: 1)
  44133. */
  44134. scaleRatio: number;
  44135. /**
  44136. * Disposes of the gizmo
  44137. */
  44138. dispose(): void;
  44139. }
  44140. }
  44141. declare module "babylonjs/Gizmos/gizmoManager" {
  44142. import { Observable } from "babylonjs/Misc/observable";
  44143. import { Nullable } from "babylonjs/types";
  44144. import { Scene, IDisposable } from "babylonjs/scene";
  44145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44146. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44147. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44148. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44149. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44150. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44151. /**
  44152. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44153. */
  44154. export class GizmoManager implements IDisposable {
  44155. private scene;
  44156. /**
  44157. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44158. */
  44159. gizmos: {
  44160. positionGizmo: Nullable<PositionGizmo>;
  44161. rotationGizmo: Nullable<RotationGizmo>;
  44162. scaleGizmo: Nullable<ScaleGizmo>;
  44163. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44164. };
  44165. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44166. clearGizmoOnEmptyPointerEvent: boolean;
  44167. /** Fires an event when the manager is attached to a mesh */
  44168. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44169. private _gizmosEnabled;
  44170. private _pointerObserver;
  44171. private _attachedMesh;
  44172. private _boundingBoxColor;
  44173. private _defaultUtilityLayer;
  44174. private _defaultKeepDepthUtilityLayer;
  44175. /**
  44176. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44177. */
  44178. boundingBoxDragBehavior: SixDofDragBehavior;
  44179. /**
  44180. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44181. */
  44182. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44183. /**
  44184. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44185. */
  44186. usePointerToAttachGizmos: boolean;
  44187. /**
  44188. * Instatiates a gizmo manager
  44189. * @param scene the scene to overlay the gizmos on top of
  44190. */
  44191. constructor(scene: Scene);
  44192. /**
  44193. * Attaches a set of gizmos to the specified mesh
  44194. * @param mesh The mesh the gizmo's should be attached to
  44195. */
  44196. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44197. /**
  44198. * If the position gizmo is enabled
  44199. */
  44200. positionGizmoEnabled: boolean;
  44201. /**
  44202. * If the rotation gizmo is enabled
  44203. */
  44204. rotationGizmoEnabled: boolean;
  44205. /**
  44206. * If the scale gizmo is enabled
  44207. */
  44208. scaleGizmoEnabled: boolean;
  44209. /**
  44210. * If the boundingBox gizmo is enabled
  44211. */
  44212. boundingBoxGizmoEnabled: boolean;
  44213. /**
  44214. * Disposes of the gizmo manager
  44215. */
  44216. dispose(): void;
  44217. }
  44218. }
  44219. declare module "babylonjs/Lights/directionalLight" {
  44220. import { Camera } from "babylonjs/Cameras/camera";
  44221. import { Scene } from "babylonjs/scene";
  44222. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44224. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44225. import { Effect } from "babylonjs/Materials/effect";
  44226. /**
  44227. * A directional light is defined by a direction (what a surprise!).
  44228. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44229. * 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.
  44230. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44231. */
  44232. export class DirectionalLight extends ShadowLight {
  44233. private _shadowFrustumSize;
  44234. /**
  44235. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44236. */
  44237. /**
  44238. * Specifies a fix frustum size for the shadow generation.
  44239. */
  44240. shadowFrustumSize: number;
  44241. private _shadowOrthoScale;
  44242. /**
  44243. * Gets the shadow projection scale against the optimal computed one.
  44244. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44245. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44246. */
  44247. /**
  44248. * Sets the shadow projection scale against the optimal computed one.
  44249. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44250. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44251. */
  44252. shadowOrthoScale: number;
  44253. /**
  44254. * Automatically compute the projection matrix to best fit (including all the casters)
  44255. * on each frame.
  44256. */
  44257. autoUpdateExtends: boolean;
  44258. private _orthoLeft;
  44259. private _orthoRight;
  44260. private _orthoTop;
  44261. private _orthoBottom;
  44262. /**
  44263. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44264. * The directional light is emitted from everywhere in the given direction.
  44265. * It can cast shadows.
  44266. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44267. * @param name The friendly name of the light
  44268. * @param direction The direction of the light
  44269. * @param scene The scene the light belongs to
  44270. */
  44271. constructor(name: string, direction: Vector3, scene: Scene);
  44272. /**
  44273. * Returns the string "DirectionalLight".
  44274. * @return The class name
  44275. */
  44276. getClassName(): string;
  44277. /**
  44278. * Returns the integer 1.
  44279. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44280. */
  44281. getTypeID(): number;
  44282. /**
  44283. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44284. * Returns the DirectionalLight Shadow projection matrix.
  44285. */
  44286. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44287. /**
  44288. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44289. * Returns the DirectionalLight Shadow projection matrix.
  44290. */
  44291. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44292. /**
  44293. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44294. * Returns the DirectionalLight Shadow projection matrix.
  44295. */
  44296. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44297. protected _buildUniformLayout(): void;
  44298. /**
  44299. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44300. * @param effect The effect to update
  44301. * @param lightIndex The index of the light in the effect to update
  44302. * @returns The directional light
  44303. */
  44304. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44305. /**
  44306. * Gets the minZ used for shadow according to both the scene and the light.
  44307. *
  44308. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44309. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44310. * @param activeCamera The camera we are returning the min for
  44311. * @returns the depth min z
  44312. */
  44313. getDepthMinZ(activeCamera: Camera): number;
  44314. /**
  44315. * Gets the maxZ used for shadow according to both the scene and the light.
  44316. *
  44317. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44318. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44319. * @param activeCamera The camera we are returning the max for
  44320. * @returns the depth max z
  44321. */
  44322. getDepthMaxZ(activeCamera: Camera): number;
  44323. /**
  44324. * Prepares the list of defines specific to the light type.
  44325. * @param defines the list of defines
  44326. * @param lightIndex defines the index of the light for the effect
  44327. */
  44328. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44329. }
  44330. }
  44331. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44332. import { Mesh } from "babylonjs/Meshes/mesh";
  44333. /**
  44334. * Class containing static functions to help procedurally build meshes
  44335. */
  44336. export class HemisphereBuilder {
  44337. /**
  44338. * Creates a hemisphere mesh
  44339. * @param name defines the name of the mesh
  44340. * @param options defines the options used to create the mesh
  44341. * @param scene defines the hosting scene
  44342. * @returns the hemisphere mesh
  44343. */
  44344. static CreateHemisphere(name: string, options: {
  44345. segments?: number;
  44346. diameter?: number;
  44347. sideOrientation?: number;
  44348. }, scene: any): Mesh;
  44349. }
  44350. }
  44351. declare module "babylonjs/Lights/spotLight" {
  44352. import { Nullable } from "babylonjs/types";
  44353. import { Scene } from "babylonjs/scene";
  44354. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44356. import { Effect } from "babylonjs/Materials/effect";
  44357. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44358. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44359. /**
  44360. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44361. * These values define a cone of light starting from the position, emitting toward the direction.
  44362. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44363. * and the exponent defines the speed of the decay of the light with distance (reach).
  44364. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44365. */
  44366. export class SpotLight extends ShadowLight {
  44367. private _angle;
  44368. private _innerAngle;
  44369. private _cosHalfAngle;
  44370. private _lightAngleScale;
  44371. private _lightAngleOffset;
  44372. /**
  44373. * Gets the cone angle of the spot light in Radians.
  44374. */
  44375. /**
  44376. * Sets the cone angle of the spot light in Radians.
  44377. */
  44378. angle: number;
  44379. /**
  44380. * Only used in gltf falloff mode, this defines the angle where
  44381. * the directional falloff will start before cutting at angle which could be seen
  44382. * as outer angle.
  44383. */
  44384. /**
  44385. * Only used in gltf falloff mode, this defines the angle where
  44386. * the directional falloff will start before cutting at angle which could be seen
  44387. * as outer angle.
  44388. */
  44389. innerAngle: number;
  44390. private _shadowAngleScale;
  44391. /**
  44392. * Allows scaling the angle of the light for shadow generation only.
  44393. */
  44394. /**
  44395. * Allows scaling the angle of the light for shadow generation only.
  44396. */
  44397. shadowAngleScale: number;
  44398. /**
  44399. * The light decay speed with the distance from the emission spot.
  44400. */
  44401. exponent: number;
  44402. private _projectionTextureMatrix;
  44403. /**
  44404. * Allows reading the projecton texture
  44405. */
  44406. readonly projectionTextureMatrix: Matrix;
  44407. protected _projectionTextureLightNear: number;
  44408. /**
  44409. * Gets the near clip of the Spotlight for texture projection.
  44410. */
  44411. /**
  44412. * Sets the near clip of the Spotlight for texture projection.
  44413. */
  44414. projectionTextureLightNear: number;
  44415. protected _projectionTextureLightFar: number;
  44416. /**
  44417. * Gets the far clip of the Spotlight for texture projection.
  44418. */
  44419. /**
  44420. * Sets the far clip of the Spotlight for texture projection.
  44421. */
  44422. projectionTextureLightFar: number;
  44423. protected _projectionTextureUpDirection: Vector3;
  44424. /**
  44425. * Gets the Up vector of the Spotlight for texture projection.
  44426. */
  44427. /**
  44428. * Sets the Up vector of the Spotlight for texture projection.
  44429. */
  44430. projectionTextureUpDirection: Vector3;
  44431. private _projectionTexture;
  44432. /**
  44433. * Gets the projection texture of the light.
  44434. */
  44435. /**
  44436. * Sets the projection texture of the light.
  44437. */
  44438. projectionTexture: Nullable<BaseTexture>;
  44439. private _projectionTextureViewLightDirty;
  44440. private _projectionTextureProjectionLightDirty;
  44441. private _projectionTextureDirty;
  44442. private _projectionTextureViewTargetVector;
  44443. private _projectionTextureViewLightMatrix;
  44444. private _projectionTextureProjectionLightMatrix;
  44445. private _projectionTextureScalingMatrix;
  44446. /**
  44447. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44448. * It can cast shadows.
  44449. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44450. * @param name The light friendly name
  44451. * @param position The position of the spot light in the scene
  44452. * @param direction The direction of the light in the scene
  44453. * @param angle The cone angle of the light in Radians
  44454. * @param exponent The light decay speed with the distance from the emission spot
  44455. * @param scene The scene the lights belongs to
  44456. */
  44457. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44458. /**
  44459. * Returns the string "SpotLight".
  44460. * @returns the class name
  44461. */
  44462. getClassName(): string;
  44463. /**
  44464. * Returns the integer 2.
  44465. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44466. */
  44467. getTypeID(): number;
  44468. /**
  44469. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44470. */
  44471. protected _setDirection(value: Vector3): void;
  44472. /**
  44473. * Overrides the position setter to recompute the projection texture view light Matrix.
  44474. */
  44475. protected _setPosition(value: Vector3): void;
  44476. /**
  44477. * 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.
  44478. * Returns the SpotLight.
  44479. */
  44480. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44481. protected _computeProjectionTextureViewLightMatrix(): void;
  44482. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44483. /**
  44484. * Main function for light texture projection matrix computing.
  44485. */
  44486. protected _computeProjectionTextureMatrix(): void;
  44487. protected _buildUniformLayout(): void;
  44488. private _computeAngleValues;
  44489. /**
  44490. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44491. * @param effect The effect to update
  44492. * @param lightIndex The index of the light in the effect to update
  44493. * @returns The spot light
  44494. */
  44495. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44496. /**
  44497. * Disposes the light and the associated resources.
  44498. */
  44499. dispose(): void;
  44500. /**
  44501. * Prepares the list of defines specific to the light type.
  44502. * @param defines the list of defines
  44503. * @param lightIndex defines the index of the light for the effect
  44504. */
  44505. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44506. }
  44507. }
  44508. declare module "babylonjs/Gizmos/lightGizmo" {
  44509. import { Nullable } from "babylonjs/types";
  44510. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44511. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44512. import { Light } from "babylonjs/Lights/light";
  44513. /**
  44514. * Gizmo that enables viewing a light
  44515. */
  44516. export class LightGizmo extends Gizmo {
  44517. private _lightMesh;
  44518. private _material;
  44519. /**
  44520. * Creates a LightGizmo
  44521. * @param gizmoLayer The utility layer the gizmo will be added to
  44522. */
  44523. constructor(gizmoLayer?: UtilityLayerRenderer);
  44524. private _light;
  44525. /**
  44526. * The light that the gizmo is attached to
  44527. */
  44528. light: Nullable<Light>;
  44529. /**
  44530. * @hidden
  44531. * Updates the gizmo to match the attached mesh's position/rotation
  44532. */
  44533. protected _update(): void;
  44534. private static _Scale;
  44535. /**
  44536. * Creates the lines for a light mesh
  44537. */
  44538. private static _createLightLines;
  44539. private static _CreateHemisphericLightMesh;
  44540. private static _CreatePointLightMesh;
  44541. private static _CreateSpotLightMesh;
  44542. private static _CreateDirectionalLightMesh;
  44543. }
  44544. }
  44545. declare module "babylonjs/Gizmos/index" {
  44546. export * from "babylonjs/Gizmos/axisDragGizmo";
  44547. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44548. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44549. export * from "babylonjs/Gizmos/gizmo";
  44550. export * from "babylonjs/Gizmos/gizmoManager";
  44551. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44552. export * from "babylonjs/Gizmos/positionGizmo";
  44553. export * from "babylonjs/Gizmos/rotationGizmo";
  44554. export * from "babylonjs/Gizmos/scaleGizmo";
  44555. export * from "babylonjs/Gizmos/lightGizmo";
  44556. }
  44557. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44558. /** @hidden */
  44559. export var backgroundFragmentDeclaration: {
  44560. name: string;
  44561. shader: string;
  44562. };
  44563. }
  44564. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44565. /** @hidden */
  44566. export var backgroundUboDeclaration: {
  44567. name: string;
  44568. shader: string;
  44569. };
  44570. }
  44571. declare module "babylonjs/Shaders/background.fragment" {
  44572. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44573. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44574. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44575. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44576. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44577. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44578. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44579. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44580. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44581. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44582. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44583. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44584. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44585. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44586. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44587. /** @hidden */
  44588. export var backgroundPixelShader: {
  44589. name: string;
  44590. shader: string;
  44591. };
  44592. }
  44593. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44594. /** @hidden */
  44595. export var backgroundVertexDeclaration: {
  44596. name: string;
  44597. shader: string;
  44598. };
  44599. }
  44600. declare module "babylonjs/Shaders/background.vertex" {
  44601. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44602. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44603. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44604. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44605. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44606. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44607. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44608. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44609. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44610. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44611. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44612. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44613. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44614. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44615. /** @hidden */
  44616. export var backgroundVertexShader: {
  44617. name: string;
  44618. shader: string;
  44619. };
  44620. }
  44621. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44622. import { Nullable, int, float } from "babylonjs/types";
  44623. import { Scene } from "babylonjs/scene";
  44624. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44625. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44627. import { Mesh } from "babylonjs/Meshes/mesh";
  44628. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44629. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44630. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44631. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44632. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44633. import "babylonjs/Shaders/background.fragment";
  44634. import "babylonjs/Shaders/background.vertex";
  44635. /**
  44636. * Background material used to create an efficient environement around your scene.
  44637. */
  44638. export class BackgroundMaterial extends PushMaterial {
  44639. /**
  44640. * Standard reflectance value at parallel view angle.
  44641. */
  44642. static StandardReflectance0: number;
  44643. /**
  44644. * Standard reflectance value at grazing angle.
  44645. */
  44646. static StandardReflectance90: number;
  44647. protected _primaryColor: Color3;
  44648. /**
  44649. * Key light Color (multiply against the environement texture)
  44650. */
  44651. primaryColor: Color3;
  44652. protected __perceptualColor: Nullable<Color3>;
  44653. /**
  44654. * Experimental Internal Use Only.
  44655. *
  44656. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44657. * This acts as a helper to set the primary color to a more "human friendly" value.
  44658. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44659. * output color as close as possible from the chosen value.
  44660. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44661. * part of lighting setup.)
  44662. */
  44663. _perceptualColor: Nullable<Color3>;
  44664. protected _primaryColorShadowLevel: float;
  44665. /**
  44666. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44667. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44668. */
  44669. primaryColorShadowLevel: float;
  44670. protected _primaryColorHighlightLevel: float;
  44671. /**
  44672. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44673. * The primary color is used at the level chosen to define what the white area would look.
  44674. */
  44675. primaryColorHighlightLevel: float;
  44676. protected _reflectionTexture: Nullable<BaseTexture>;
  44677. /**
  44678. * Reflection Texture used in the material.
  44679. * Should be author in a specific way for the best result (refer to the documentation).
  44680. */
  44681. reflectionTexture: Nullable<BaseTexture>;
  44682. protected _reflectionBlur: float;
  44683. /**
  44684. * Reflection Texture level of blur.
  44685. *
  44686. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44687. * texture twice.
  44688. */
  44689. reflectionBlur: float;
  44690. protected _diffuseTexture: Nullable<BaseTexture>;
  44691. /**
  44692. * Diffuse Texture used in the material.
  44693. * Should be author in a specific way for the best result (refer to the documentation).
  44694. */
  44695. diffuseTexture: Nullable<BaseTexture>;
  44696. protected _shadowLights: Nullable<IShadowLight[]>;
  44697. /**
  44698. * Specify the list of lights casting shadow on the material.
  44699. * All scene shadow lights will be included if null.
  44700. */
  44701. shadowLights: Nullable<IShadowLight[]>;
  44702. protected _shadowLevel: float;
  44703. /**
  44704. * Helps adjusting the shadow to a softer level if required.
  44705. * 0 means black shadows and 1 means no shadows.
  44706. */
  44707. shadowLevel: float;
  44708. protected _sceneCenter: Vector3;
  44709. /**
  44710. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44711. * It is usually zero but might be interesting to modify according to your setup.
  44712. */
  44713. sceneCenter: Vector3;
  44714. protected _opacityFresnel: boolean;
  44715. /**
  44716. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44717. * This helps ensuring a nice transition when the camera goes under the ground.
  44718. */
  44719. opacityFresnel: boolean;
  44720. protected _reflectionFresnel: boolean;
  44721. /**
  44722. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44723. * This helps adding a mirror texture on the ground.
  44724. */
  44725. reflectionFresnel: boolean;
  44726. protected _reflectionFalloffDistance: number;
  44727. /**
  44728. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44729. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44730. */
  44731. reflectionFalloffDistance: number;
  44732. protected _reflectionAmount: number;
  44733. /**
  44734. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44735. */
  44736. reflectionAmount: number;
  44737. protected _reflectionReflectance0: number;
  44738. /**
  44739. * This specifies the weight of the reflection at grazing angle.
  44740. */
  44741. reflectionReflectance0: number;
  44742. protected _reflectionReflectance90: number;
  44743. /**
  44744. * This specifies the weight of the reflection at a perpendicular point of view.
  44745. */
  44746. reflectionReflectance90: number;
  44747. /**
  44748. * Sets the reflection reflectance fresnel values according to the default standard
  44749. * empirically know to work well :-)
  44750. */
  44751. reflectionStandardFresnelWeight: number;
  44752. protected _useRGBColor: boolean;
  44753. /**
  44754. * Helps to directly use the maps channels instead of their level.
  44755. */
  44756. useRGBColor: boolean;
  44757. protected _enableNoise: boolean;
  44758. /**
  44759. * This helps reducing the banding effect that could occur on the background.
  44760. */
  44761. enableNoise: boolean;
  44762. /**
  44763. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44764. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44765. * Recommended to be keep at 1.0 except for special cases.
  44766. */
  44767. fovMultiplier: number;
  44768. private _fovMultiplier;
  44769. /**
  44770. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44771. */
  44772. useEquirectangularFOV: boolean;
  44773. private _maxSimultaneousLights;
  44774. /**
  44775. * Number of Simultaneous lights allowed on the material.
  44776. */
  44777. maxSimultaneousLights: int;
  44778. /**
  44779. * Default configuration related to image processing available in the Background Material.
  44780. */
  44781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44782. /**
  44783. * Keep track of the image processing observer to allow dispose and replace.
  44784. */
  44785. private _imageProcessingObserver;
  44786. /**
  44787. * Attaches a new image processing configuration to the PBR Material.
  44788. * @param configuration (if null the scene configuration will be use)
  44789. */
  44790. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44791. /**
  44792. * Gets the image processing configuration used either in this material.
  44793. */
  44794. /**
  44795. * Sets the Default image processing configuration used either in the this material.
  44796. *
  44797. * If sets to null, the scene one is in use.
  44798. */
  44799. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44800. /**
  44801. * Gets wether the color curves effect is enabled.
  44802. */
  44803. /**
  44804. * Sets wether the color curves effect is enabled.
  44805. */
  44806. cameraColorCurvesEnabled: boolean;
  44807. /**
  44808. * Gets wether the color grading effect is enabled.
  44809. */
  44810. /**
  44811. * Gets wether the color grading effect is enabled.
  44812. */
  44813. cameraColorGradingEnabled: boolean;
  44814. /**
  44815. * Gets wether tonemapping is enabled or not.
  44816. */
  44817. /**
  44818. * Sets wether tonemapping is enabled or not
  44819. */
  44820. cameraToneMappingEnabled: boolean;
  44821. /**
  44822. * The camera exposure used on this material.
  44823. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44824. * This corresponds to a photographic exposure.
  44825. */
  44826. /**
  44827. * The camera exposure used on this material.
  44828. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44829. * This corresponds to a photographic exposure.
  44830. */
  44831. cameraExposure: float;
  44832. /**
  44833. * Gets The camera contrast used on this material.
  44834. */
  44835. /**
  44836. * Sets The camera contrast used on this material.
  44837. */
  44838. cameraContrast: float;
  44839. /**
  44840. * Gets the Color Grading 2D Lookup Texture.
  44841. */
  44842. /**
  44843. * Sets the Color Grading 2D Lookup Texture.
  44844. */
  44845. cameraColorGradingTexture: Nullable<BaseTexture>;
  44846. /**
  44847. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44848. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44849. * 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;
  44850. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44851. */
  44852. /**
  44853. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44854. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44855. * 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;
  44856. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44857. */
  44858. cameraColorCurves: Nullable<ColorCurves>;
  44859. /**
  44860. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44861. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44862. */
  44863. switchToBGR: boolean;
  44864. private _renderTargets;
  44865. private _reflectionControls;
  44866. private _white;
  44867. private _primaryShadowColor;
  44868. private _primaryHighlightColor;
  44869. /**
  44870. * Instantiates a Background Material in the given scene
  44871. * @param name The friendly name of the material
  44872. * @param scene The scene to add the material to
  44873. */
  44874. constructor(name: string, scene: Scene);
  44875. /**
  44876. * Gets a boolean indicating that current material needs to register RTT
  44877. */
  44878. readonly hasRenderTargetTextures: boolean;
  44879. /**
  44880. * The entire material has been created in order to prevent overdraw.
  44881. * @returns false
  44882. */
  44883. needAlphaTesting(): boolean;
  44884. /**
  44885. * The entire material has been created in order to prevent overdraw.
  44886. * @returns true if blending is enable
  44887. */
  44888. needAlphaBlending(): boolean;
  44889. /**
  44890. * Checks wether the material is ready to be rendered for a given mesh.
  44891. * @param mesh The mesh to render
  44892. * @param subMesh The submesh to check against
  44893. * @param useInstances Specify wether or not the material is used with instances
  44894. * @returns true if all the dependencies are ready (Textures, Effects...)
  44895. */
  44896. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44897. /**
  44898. * Compute the primary color according to the chosen perceptual color.
  44899. */
  44900. private _computePrimaryColorFromPerceptualColor;
  44901. /**
  44902. * Compute the highlights and shadow colors according to their chosen levels.
  44903. */
  44904. private _computePrimaryColors;
  44905. /**
  44906. * Build the uniform buffer used in the material.
  44907. */
  44908. buildUniformLayout(): void;
  44909. /**
  44910. * Unbind the material.
  44911. */
  44912. unbind(): void;
  44913. /**
  44914. * Bind only the world matrix to the material.
  44915. * @param world The world matrix to bind.
  44916. */
  44917. bindOnlyWorldMatrix(world: Matrix): void;
  44918. /**
  44919. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44920. * @param world The world matrix to bind.
  44921. * @param subMesh The submesh to bind for.
  44922. */
  44923. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44924. /**
  44925. * Dispose the material.
  44926. * @param forceDisposeEffect Force disposal of the associated effect.
  44927. * @param forceDisposeTextures Force disposal of the associated textures.
  44928. */
  44929. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44930. /**
  44931. * Clones the material.
  44932. * @param name The cloned name.
  44933. * @returns The cloned material.
  44934. */
  44935. clone(name: string): BackgroundMaterial;
  44936. /**
  44937. * Serializes the current material to its JSON representation.
  44938. * @returns The JSON representation.
  44939. */
  44940. serialize(): any;
  44941. /**
  44942. * Gets the class name of the material
  44943. * @returns "BackgroundMaterial"
  44944. */
  44945. getClassName(): string;
  44946. /**
  44947. * Parse a JSON input to create back a background material.
  44948. * @param source The JSON data to parse
  44949. * @param scene The scene to create the parsed material in
  44950. * @param rootUrl The root url of the assets the material depends upon
  44951. * @returns the instantiated BackgroundMaterial.
  44952. */
  44953. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44954. }
  44955. }
  44956. declare module "babylonjs/Helpers/environmentHelper" {
  44957. import { Observable } from "babylonjs/Misc/observable";
  44958. import { Nullable } from "babylonjs/types";
  44959. import { Scene } from "babylonjs/scene";
  44960. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44962. import { Mesh } from "babylonjs/Meshes/mesh";
  44963. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44964. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44965. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44966. import "babylonjs/Meshes/Builders/planeBuilder";
  44967. import "babylonjs/Meshes/Builders/boxBuilder";
  44968. /**
  44969. * Represents the different options available during the creation of
  44970. * a Environment helper.
  44971. *
  44972. * This can control the default ground, skybox and image processing setup of your scene.
  44973. */
  44974. export interface IEnvironmentHelperOptions {
  44975. /**
  44976. * Specifies wether or not to create a ground.
  44977. * True by default.
  44978. */
  44979. createGround: boolean;
  44980. /**
  44981. * Specifies the ground size.
  44982. * 15 by default.
  44983. */
  44984. groundSize: number;
  44985. /**
  44986. * The texture used on the ground for the main color.
  44987. * Comes from the BabylonJS CDN by default.
  44988. *
  44989. * Remarks: Can be either a texture or a url.
  44990. */
  44991. groundTexture: string | BaseTexture;
  44992. /**
  44993. * The color mixed in the ground texture by default.
  44994. * BabylonJS clearColor by default.
  44995. */
  44996. groundColor: Color3;
  44997. /**
  44998. * Specifies the ground opacity.
  44999. * 1 by default.
  45000. */
  45001. groundOpacity: number;
  45002. /**
  45003. * Enables the ground to receive shadows.
  45004. * True by default.
  45005. */
  45006. enableGroundShadow: boolean;
  45007. /**
  45008. * Helps preventing the shadow to be fully black on the ground.
  45009. * 0.5 by default.
  45010. */
  45011. groundShadowLevel: number;
  45012. /**
  45013. * Creates a mirror texture attach to the ground.
  45014. * false by default.
  45015. */
  45016. enableGroundMirror: boolean;
  45017. /**
  45018. * Specifies the ground mirror size ratio.
  45019. * 0.3 by default as the default kernel is 64.
  45020. */
  45021. groundMirrorSizeRatio: number;
  45022. /**
  45023. * Specifies the ground mirror blur kernel size.
  45024. * 64 by default.
  45025. */
  45026. groundMirrorBlurKernel: number;
  45027. /**
  45028. * Specifies the ground mirror visibility amount.
  45029. * 1 by default
  45030. */
  45031. groundMirrorAmount: number;
  45032. /**
  45033. * Specifies the ground mirror reflectance weight.
  45034. * This uses the standard weight of the background material to setup the fresnel effect
  45035. * of the mirror.
  45036. * 1 by default.
  45037. */
  45038. groundMirrorFresnelWeight: number;
  45039. /**
  45040. * Specifies the ground mirror Falloff distance.
  45041. * This can helps reducing the size of the reflection.
  45042. * 0 by Default.
  45043. */
  45044. groundMirrorFallOffDistance: number;
  45045. /**
  45046. * Specifies the ground mirror texture type.
  45047. * Unsigned Int by Default.
  45048. */
  45049. groundMirrorTextureType: number;
  45050. /**
  45051. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45052. * the shown objects.
  45053. */
  45054. groundYBias: number;
  45055. /**
  45056. * Specifies wether or not to create a skybox.
  45057. * True by default.
  45058. */
  45059. createSkybox: boolean;
  45060. /**
  45061. * Specifies the skybox size.
  45062. * 20 by default.
  45063. */
  45064. skyboxSize: number;
  45065. /**
  45066. * The texture used on the skybox for the main color.
  45067. * Comes from the BabylonJS CDN by default.
  45068. *
  45069. * Remarks: Can be either a texture or a url.
  45070. */
  45071. skyboxTexture: string | BaseTexture;
  45072. /**
  45073. * The color mixed in the skybox texture by default.
  45074. * BabylonJS clearColor by default.
  45075. */
  45076. skyboxColor: Color3;
  45077. /**
  45078. * The background rotation around the Y axis of the scene.
  45079. * This helps aligning the key lights of your scene with the background.
  45080. * 0 by default.
  45081. */
  45082. backgroundYRotation: number;
  45083. /**
  45084. * Compute automatically the size of the elements to best fit with the scene.
  45085. */
  45086. sizeAuto: boolean;
  45087. /**
  45088. * Default position of the rootMesh if autoSize is not true.
  45089. */
  45090. rootPosition: Vector3;
  45091. /**
  45092. * Sets up the image processing in the scene.
  45093. * true by default.
  45094. */
  45095. setupImageProcessing: boolean;
  45096. /**
  45097. * The texture used as your environment texture in the scene.
  45098. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45099. *
  45100. * Remarks: Can be either a texture or a url.
  45101. */
  45102. environmentTexture: string | BaseTexture;
  45103. /**
  45104. * The value of the exposure to apply to the scene.
  45105. * 0.6 by default if setupImageProcessing is true.
  45106. */
  45107. cameraExposure: number;
  45108. /**
  45109. * The value of the contrast to apply to the scene.
  45110. * 1.6 by default if setupImageProcessing is true.
  45111. */
  45112. cameraContrast: number;
  45113. /**
  45114. * Specifies wether or not tonemapping should be enabled in the scene.
  45115. * true by default if setupImageProcessing is true.
  45116. */
  45117. toneMappingEnabled: boolean;
  45118. }
  45119. /**
  45120. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45121. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45122. * It also helps with the default setup of your imageProcessing configuration.
  45123. */
  45124. export class EnvironmentHelper {
  45125. /**
  45126. * Default ground texture URL.
  45127. */
  45128. private static _groundTextureCDNUrl;
  45129. /**
  45130. * Default skybox texture URL.
  45131. */
  45132. private static _skyboxTextureCDNUrl;
  45133. /**
  45134. * Default environment texture URL.
  45135. */
  45136. private static _environmentTextureCDNUrl;
  45137. /**
  45138. * Creates the default options for the helper.
  45139. */
  45140. private static _getDefaultOptions;
  45141. private _rootMesh;
  45142. /**
  45143. * Gets the root mesh created by the helper.
  45144. */
  45145. readonly rootMesh: Mesh;
  45146. private _skybox;
  45147. /**
  45148. * Gets the skybox created by the helper.
  45149. */
  45150. readonly skybox: Nullable<Mesh>;
  45151. private _skyboxTexture;
  45152. /**
  45153. * Gets the skybox texture created by the helper.
  45154. */
  45155. readonly skyboxTexture: Nullable<BaseTexture>;
  45156. private _skyboxMaterial;
  45157. /**
  45158. * Gets the skybox material created by the helper.
  45159. */
  45160. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45161. private _ground;
  45162. /**
  45163. * Gets the ground mesh created by the helper.
  45164. */
  45165. readonly ground: Nullable<Mesh>;
  45166. private _groundTexture;
  45167. /**
  45168. * Gets the ground texture created by the helper.
  45169. */
  45170. readonly groundTexture: Nullable<BaseTexture>;
  45171. private _groundMirror;
  45172. /**
  45173. * Gets the ground mirror created by the helper.
  45174. */
  45175. readonly groundMirror: Nullable<MirrorTexture>;
  45176. /**
  45177. * Gets the ground mirror render list to helps pushing the meshes
  45178. * you wish in the ground reflection.
  45179. */
  45180. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45181. private _groundMaterial;
  45182. /**
  45183. * Gets the ground material created by the helper.
  45184. */
  45185. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45186. /**
  45187. * Stores the creation options.
  45188. */
  45189. private readonly _scene;
  45190. private _options;
  45191. /**
  45192. * This observable will be notified with any error during the creation of the environment,
  45193. * mainly texture creation errors.
  45194. */
  45195. onErrorObservable: Observable<{
  45196. message?: string;
  45197. exception?: any;
  45198. }>;
  45199. /**
  45200. * constructor
  45201. * @param options Defines the options we want to customize the helper
  45202. * @param scene The scene to add the material to
  45203. */
  45204. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45205. /**
  45206. * Updates the background according to the new options
  45207. * @param options
  45208. */
  45209. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45210. /**
  45211. * Sets the primary color of all the available elements.
  45212. * @param color the main color to affect to the ground and the background
  45213. */
  45214. setMainColor(color: Color3): void;
  45215. /**
  45216. * Setup the image processing according to the specified options.
  45217. */
  45218. private _setupImageProcessing;
  45219. /**
  45220. * Setup the environment texture according to the specified options.
  45221. */
  45222. private _setupEnvironmentTexture;
  45223. /**
  45224. * Setup the background according to the specified options.
  45225. */
  45226. private _setupBackground;
  45227. /**
  45228. * Get the scene sizes according to the setup.
  45229. */
  45230. private _getSceneSize;
  45231. /**
  45232. * Setup the ground according to the specified options.
  45233. */
  45234. private _setupGround;
  45235. /**
  45236. * Setup the ground material according to the specified options.
  45237. */
  45238. private _setupGroundMaterial;
  45239. /**
  45240. * Setup the ground diffuse texture according to the specified options.
  45241. */
  45242. private _setupGroundDiffuseTexture;
  45243. /**
  45244. * Setup the ground mirror texture according to the specified options.
  45245. */
  45246. private _setupGroundMirrorTexture;
  45247. /**
  45248. * Setup the ground to receive the mirror texture.
  45249. */
  45250. private _setupMirrorInGroundMaterial;
  45251. /**
  45252. * Setup the skybox according to the specified options.
  45253. */
  45254. private _setupSkybox;
  45255. /**
  45256. * Setup the skybox material according to the specified options.
  45257. */
  45258. private _setupSkyboxMaterial;
  45259. /**
  45260. * Setup the skybox reflection texture according to the specified options.
  45261. */
  45262. private _setupSkyboxReflectionTexture;
  45263. private _errorHandler;
  45264. /**
  45265. * Dispose all the elements created by the Helper.
  45266. */
  45267. dispose(): void;
  45268. }
  45269. }
  45270. declare module "babylonjs/Helpers/photoDome" {
  45271. import { Observable } from "babylonjs/Misc/observable";
  45272. import { Nullable } from "babylonjs/types";
  45273. import { Scene } from "babylonjs/scene";
  45274. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45275. import { Mesh } from "babylonjs/Meshes/mesh";
  45276. import { Texture } from "babylonjs/Materials/Textures/texture";
  45277. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45278. import "babylonjs/Meshes/Builders/sphereBuilder";
  45279. /**
  45280. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45281. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45282. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45283. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45284. */
  45285. export class PhotoDome extends TransformNode {
  45286. private _useDirectMapping;
  45287. /**
  45288. * The texture being displayed on the sphere
  45289. */
  45290. protected _photoTexture: Texture;
  45291. /**
  45292. * Gets or sets the texture being displayed on the sphere
  45293. */
  45294. photoTexture: Texture;
  45295. /**
  45296. * Observable raised when an error occured while loading the 360 image
  45297. */
  45298. onLoadErrorObservable: Observable<string>;
  45299. /**
  45300. * The skybox material
  45301. */
  45302. protected _material: BackgroundMaterial;
  45303. /**
  45304. * The surface used for the skybox
  45305. */
  45306. protected _mesh: Mesh;
  45307. /**
  45308. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45309. * Also see the options.resolution property.
  45310. */
  45311. fovMultiplier: number;
  45312. /**
  45313. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45314. * @param name Element's name, child elements will append suffixes for their own names.
  45315. * @param urlsOfPhoto defines the url of the photo to display
  45316. * @param options defines an object containing optional or exposed sub element properties
  45317. * @param onError defines a callback called when an error occured while loading the texture
  45318. */
  45319. constructor(name: string, urlOfPhoto: string, options: {
  45320. resolution?: number;
  45321. size?: number;
  45322. useDirectMapping?: boolean;
  45323. faceForward?: boolean;
  45324. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45325. /**
  45326. * Releases resources associated with this node.
  45327. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45328. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45329. */
  45330. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45331. }
  45332. }
  45333. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45334. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45335. /** @hidden */
  45336. export var rgbdDecodePixelShader: {
  45337. name: string;
  45338. shader: string;
  45339. };
  45340. }
  45341. declare module "babylonjs/Misc/brdfTextureTools" {
  45342. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45343. import { Scene } from "babylonjs/scene";
  45344. import "babylonjs/Shaders/rgbdDecode.fragment";
  45345. /**
  45346. * Class used to host texture specific utilities
  45347. */
  45348. export class BRDFTextureTools {
  45349. /**
  45350. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45351. * @param texture the texture to expand.
  45352. */
  45353. private static _ExpandDefaultBRDFTexture;
  45354. /**
  45355. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45356. * @param scene defines the hosting scene
  45357. * @returns the environment BRDF texture
  45358. */
  45359. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45360. private static _environmentBRDFBase64Texture;
  45361. }
  45362. }
  45363. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45364. import { Nullable } from "babylonjs/types";
  45365. import { IAnimatable } from "babylonjs/Misc/tools";
  45366. import { Color3 } from "babylonjs/Maths/math";
  45367. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45368. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45369. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45370. import { Engine } from "babylonjs/Engines/engine";
  45371. import { Scene } from "babylonjs/scene";
  45372. /**
  45373. * @hidden
  45374. */
  45375. export interface IMaterialClearCoatDefines {
  45376. CLEARCOAT: boolean;
  45377. CLEARCOAT_DEFAULTIOR: boolean;
  45378. CLEARCOAT_TEXTURE: boolean;
  45379. CLEARCOAT_TEXTUREDIRECTUV: number;
  45380. CLEARCOAT_BUMP: boolean;
  45381. CLEARCOAT_BUMPDIRECTUV: number;
  45382. CLEARCOAT_TINT: boolean;
  45383. CLEARCOAT_TINT_TEXTURE: boolean;
  45384. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45385. /** @hidden */
  45386. _areTexturesDirty: boolean;
  45387. }
  45388. /**
  45389. * Define the code related to the clear coat parameters of the pbr material.
  45390. */
  45391. export class PBRClearCoatConfiguration {
  45392. /**
  45393. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45394. * The default fits with a polyurethane material.
  45395. */
  45396. private static readonly _DefaultIndiceOfRefraction;
  45397. private _isEnabled;
  45398. /**
  45399. * Defines if the clear coat is enabled in the material.
  45400. */
  45401. isEnabled: boolean;
  45402. /**
  45403. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45404. */
  45405. intensity: number;
  45406. /**
  45407. * Defines the clear coat layer roughness.
  45408. */
  45409. roughness: number;
  45410. private _indiceOfRefraction;
  45411. /**
  45412. * Defines the indice of refraction of the clear coat.
  45413. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45414. * The default fits with a polyurethane material.
  45415. * Changing the default value is more performance intensive.
  45416. */
  45417. indiceOfRefraction: number;
  45418. private _texture;
  45419. /**
  45420. * Stores the clear coat values in a texture.
  45421. */
  45422. texture: Nullable<BaseTexture>;
  45423. private _bumpTexture;
  45424. /**
  45425. * Define the clear coat specific bump texture.
  45426. */
  45427. bumpTexture: Nullable<BaseTexture>;
  45428. private _isTintEnabled;
  45429. /**
  45430. * Defines if the clear coat tint is enabled in the material.
  45431. */
  45432. isTintEnabled: boolean;
  45433. /**
  45434. * Defines the clear coat tint of the material.
  45435. * This is only use if tint is enabled
  45436. */
  45437. tintColor: Color3;
  45438. /**
  45439. * Defines the distance at which the tint color should be found in the
  45440. * clear coat media.
  45441. * This is only use if tint is enabled
  45442. */
  45443. tintColorAtDistance: number;
  45444. /**
  45445. * Defines the clear coat layer thickness.
  45446. * This is only use if tint is enabled
  45447. */
  45448. tintThickness: number;
  45449. private _tintTexture;
  45450. /**
  45451. * Stores the clear tint values in a texture.
  45452. * rgb is tint
  45453. * a is a thickness factor
  45454. */
  45455. tintTexture: Nullable<BaseTexture>;
  45456. /** @hidden */
  45457. private _internalMarkAllSubMeshesAsTexturesDirty;
  45458. /** @hidden */
  45459. _markAllSubMeshesAsTexturesDirty(): void;
  45460. /**
  45461. * Instantiate a new istance of clear coat configuration.
  45462. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45463. */
  45464. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45465. /**
  45466. * Gets wehter the submesh is ready to be used or not.
  45467. * @param defines the list of "defines" to update.
  45468. * @param scene defines the scene the material belongs to.
  45469. * @param engine defines the engine the material belongs to.
  45470. * @param disableBumpMap defines wether the material disables bump or not.
  45471. * @returns - boolean indicating that the submesh is ready or not.
  45472. */
  45473. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45474. /**
  45475. * Checks to see if a texture is used in the material.
  45476. * @param defines the list of "defines" to update.
  45477. * @param scene defines the scene to the material belongs to.
  45478. */
  45479. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45480. /**
  45481. * Binds the material data.
  45482. * @param uniformBuffer defines the Uniform buffer to fill in.
  45483. * @param scene defines the scene the material belongs to.
  45484. * @param engine defines the engine the material belongs to.
  45485. * @param disableBumpMap defines wether the material disables bump or not.
  45486. * @param isFrozen defines wether the material is frozen or not.
  45487. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45488. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45489. */
  45490. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45491. /**
  45492. * Checks to see if a texture is used in the material.
  45493. * @param texture - Base texture to use.
  45494. * @returns - Boolean specifying if a texture is used in the material.
  45495. */
  45496. hasTexture(texture: BaseTexture): boolean;
  45497. /**
  45498. * Returns an array of the actively used textures.
  45499. * @param activeTextures Array of BaseTextures
  45500. */
  45501. getActiveTextures(activeTextures: BaseTexture[]): void;
  45502. /**
  45503. * Returns the animatable textures.
  45504. * @param animatables Array of animatable textures.
  45505. */
  45506. getAnimatables(animatables: IAnimatable[]): void;
  45507. /**
  45508. * Disposes the resources of the material.
  45509. * @param forceDisposeTextures - Forces the disposal of all textures.
  45510. */
  45511. dispose(forceDisposeTextures?: boolean): void;
  45512. /**
  45513. * Get the current class name of the texture useful for serialization or dynamic coding.
  45514. * @returns "PBRClearCoatConfiguration"
  45515. */
  45516. getClassName(): string;
  45517. /**
  45518. * Add fallbacks to the effect fallbacks list.
  45519. * @param defines defines the Base texture to use.
  45520. * @param fallbacks defines the current fallback list.
  45521. * @param currentRank defines the current fallback rank.
  45522. * @returns the new fallback rank.
  45523. */
  45524. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45525. /**
  45526. * Add the required uniforms to the current list.
  45527. * @param uniforms defines the current uniform list.
  45528. */
  45529. static AddUniforms(uniforms: string[]): void;
  45530. /**
  45531. * Add the required samplers to the current list.
  45532. * @param samplers defines the current sampler list.
  45533. */
  45534. static AddSamplers(samplers: string[]): void;
  45535. /**
  45536. * Add the required uniforms to the current buffer.
  45537. * @param uniformBuffer defines the current uniform buffer.
  45538. */
  45539. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45540. /**
  45541. * Makes a duplicate of the current configuration into another one.
  45542. * @param clearCoatConfiguration define the config where to copy the info
  45543. */
  45544. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45545. /**
  45546. * Serializes this clear coat configuration.
  45547. * @returns - An object with the serialized config.
  45548. */
  45549. serialize(): any;
  45550. /**
  45551. * Parses a Clear Coat Configuration from a serialized object.
  45552. * @param source - Serialized object.
  45553. */
  45554. parse(source: any): void;
  45555. }
  45556. }
  45557. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45558. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45559. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45561. import { Vector2 } from "babylonjs/Maths/math";
  45562. import { Scene } from "babylonjs/scene";
  45563. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45564. import { IAnimatable } from "babylonjs/Misc/tools";
  45565. import { Nullable } from "babylonjs/types";
  45566. /**
  45567. * @hidden
  45568. */
  45569. export interface IMaterialAnisotropicDefines {
  45570. ANISOTROPIC: boolean;
  45571. ANISOTROPIC_TEXTURE: boolean;
  45572. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45573. MAINUV1: boolean;
  45574. _areTexturesDirty: boolean;
  45575. _needUVs: boolean;
  45576. }
  45577. /**
  45578. * Define the code related to the anisotropic parameters of the pbr material.
  45579. */
  45580. export class PBRAnisotropicConfiguration {
  45581. private _isEnabled;
  45582. /**
  45583. * Defines if the anisotropy is enabled in the material.
  45584. */
  45585. isEnabled: boolean;
  45586. /**
  45587. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45588. */
  45589. intensity: number;
  45590. /**
  45591. * Defines if the effect is along the tangents, bitangents or in between.
  45592. * By default, the effect is "strectching" the highlights along the tangents.
  45593. */
  45594. direction: Vector2;
  45595. private _texture;
  45596. /**
  45597. * Stores the anisotropy values in a texture.
  45598. * rg is direction (like normal from -1 to 1)
  45599. * b is a intensity
  45600. */
  45601. texture: Nullable<BaseTexture>;
  45602. /** @hidden */
  45603. private _internalMarkAllSubMeshesAsTexturesDirty;
  45604. /** @hidden */
  45605. _markAllSubMeshesAsTexturesDirty(): void;
  45606. /**
  45607. * Instantiate a new istance of anisotropy configuration.
  45608. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45609. */
  45610. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45611. /**
  45612. * Specifies that the submesh is ready to be used.
  45613. * @param defines the list of "defines" to update.
  45614. * @param scene defines the scene the material belongs to.
  45615. * @returns - boolean indicating that the submesh is ready or not.
  45616. */
  45617. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45618. /**
  45619. * Checks to see if a texture is used in the material.
  45620. * @param defines the list of "defines" to update.
  45621. * @param mesh the mesh we are preparing the defines for.
  45622. * @param scene defines the scene the material belongs to.
  45623. */
  45624. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45625. /**
  45626. * Binds the material data.
  45627. * @param uniformBuffer defines the Uniform buffer to fill in.
  45628. * @param scene defines the scene the material belongs to.
  45629. * @param isFrozen defines wether the material is frozen or not.
  45630. */
  45631. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45632. /**
  45633. * Checks to see if a texture is used in the material.
  45634. * @param texture - Base texture to use.
  45635. * @returns - Boolean specifying if a texture is used in the material.
  45636. */
  45637. hasTexture(texture: BaseTexture): boolean;
  45638. /**
  45639. * Returns an array of the actively used textures.
  45640. * @param activeTextures Array of BaseTextures
  45641. */
  45642. getActiveTextures(activeTextures: BaseTexture[]): void;
  45643. /**
  45644. * Returns the animatable textures.
  45645. * @param animatables Array of animatable textures.
  45646. */
  45647. getAnimatables(animatables: IAnimatable[]): void;
  45648. /**
  45649. * Disposes the resources of the material.
  45650. * @param forceDisposeTextures - Forces the disposal of all textures.
  45651. */
  45652. dispose(forceDisposeTextures?: boolean): void;
  45653. /**
  45654. * Get the current class name of the texture useful for serialization or dynamic coding.
  45655. * @returns "PBRAnisotropicConfiguration"
  45656. */
  45657. getClassName(): string;
  45658. /**
  45659. * Add fallbacks to the effect fallbacks list.
  45660. * @param defines defines the Base texture to use.
  45661. * @param fallbacks defines the current fallback list.
  45662. * @param currentRank defines the current fallback rank.
  45663. * @returns the new fallback rank.
  45664. */
  45665. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45666. /**
  45667. * Add the required uniforms to the current list.
  45668. * @param uniforms defines the current uniform list.
  45669. */
  45670. static AddUniforms(uniforms: string[]): void;
  45671. /**
  45672. * Add the required uniforms to the current buffer.
  45673. * @param uniformBuffer defines the current uniform buffer.
  45674. */
  45675. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45676. /**
  45677. * Add the required samplers to the current list.
  45678. * @param samplers defines the current sampler list.
  45679. */
  45680. static AddSamplers(samplers: string[]): void;
  45681. /**
  45682. * Makes a duplicate of the current configuration into another one.
  45683. * @param anisotropicConfiguration define the config where to copy the info
  45684. */
  45685. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45686. /**
  45687. * Serializes this anisotropy configuration.
  45688. * @returns - An object with the serialized config.
  45689. */
  45690. serialize(): any;
  45691. /**
  45692. * Parses a anisotropy Configuration from a serialized object.
  45693. * @param source - Serialized object.
  45694. */
  45695. parse(source: any): void;
  45696. }
  45697. }
  45698. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45699. /**
  45700. * @hidden
  45701. */
  45702. export interface IMaterialBRDFDefines {
  45703. BRDF_V_HEIGHT_CORRELATED: boolean;
  45704. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45705. /** @hidden */
  45706. _areMiscDirty: boolean;
  45707. }
  45708. /**
  45709. * Define the code related to the BRDF parameters of the pbr material.
  45710. */
  45711. export class PBRBRDFConfiguration {
  45712. /**
  45713. * Default value used for the energy conservation.
  45714. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45715. */
  45716. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45717. /**
  45718. * Default value used for the Smith Visibility Height Correlated mode.
  45719. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45720. */
  45721. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45722. private _useEnergyConservation;
  45723. /**
  45724. * Defines if the material uses energy conservation.
  45725. */
  45726. useEnergyConservation: boolean;
  45727. private _useSmithVisibilityHeightCorrelated;
  45728. /**
  45729. * LEGACY Mode set to false
  45730. * Defines if the material uses height smith correlated visibility term.
  45731. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45732. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45733. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45734. * Not relying on height correlated will also disable energy conservation.
  45735. */
  45736. useSmithVisibilityHeightCorrelated: boolean;
  45737. /** @hidden */
  45738. private _internalMarkAllSubMeshesAsMiscDirty;
  45739. /** @hidden */
  45740. _markAllSubMeshesAsMiscDirty(): void;
  45741. /**
  45742. * Instantiate a new istance of clear coat configuration.
  45743. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45744. */
  45745. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45746. /**
  45747. * Checks to see if a texture is used in the material.
  45748. * @param defines the list of "defines" to update.
  45749. */
  45750. prepareDefines(defines: IMaterialBRDFDefines): void;
  45751. /**
  45752. * Get the current class name of the texture useful for serialization or dynamic coding.
  45753. * @returns "PBRClearCoatConfiguration"
  45754. */
  45755. getClassName(): string;
  45756. /**
  45757. * Makes a duplicate of the current configuration into another one.
  45758. * @param brdfConfiguration define the config where to copy the info
  45759. */
  45760. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45761. /**
  45762. * Serializes this BRDF configuration.
  45763. * @returns - An object with the serialized config.
  45764. */
  45765. serialize(): any;
  45766. /**
  45767. * Parses a BRDF Configuration from a serialized object.
  45768. * @param source - Serialized object.
  45769. */
  45770. parse(source: any): void;
  45771. }
  45772. }
  45773. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45774. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45775. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45776. import { Color3 } from "babylonjs/Maths/math";
  45777. import { Scene } from "babylonjs/scene";
  45778. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45779. import { IAnimatable } from "babylonjs/Misc/tools";
  45780. import { Nullable } from "babylonjs/types";
  45781. /**
  45782. * @hidden
  45783. */
  45784. export interface IMaterialSheenDefines {
  45785. SHEEN: boolean;
  45786. SHEEN_TEXTURE: boolean;
  45787. SHEEN_TEXTUREDIRECTUV: number;
  45788. SHEEN_LINKWITHALBEDO: boolean;
  45789. /** @hidden */
  45790. _areTexturesDirty: boolean;
  45791. }
  45792. /**
  45793. * Define the code related to the Sheen parameters of the pbr material.
  45794. */
  45795. export class PBRSheenConfiguration {
  45796. private _isEnabled;
  45797. /**
  45798. * Defines if the material uses sheen.
  45799. */
  45800. isEnabled: boolean;
  45801. private _linkSheenWithAlbedo;
  45802. /**
  45803. * Defines if the sheen is linked to the sheen color.
  45804. */
  45805. linkSheenWithAlbedo: boolean;
  45806. /**
  45807. * Defines the sheen intensity.
  45808. */
  45809. intensity: number;
  45810. /**
  45811. * Defines the sheen color.
  45812. */
  45813. color: Color3;
  45814. private _texture;
  45815. /**
  45816. * Stores the sheen tint values in a texture.
  45817. * rgb is tint
  45818. * a is a intensity
  45819. */
  45820. texture: Nullable<BaseTexture>;
  45821. /** @hidden */
  45822. private _internalMarkAllSubMeshesAsTexturesDirty;
  45823. /** @hidden */
  45824. _markAllSubMeshesAsTexturesDirty(): void;
  45825. /**
  45826. * Instantiate a new istance of clear coat configuration.
  45827. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45828. */
  45829. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45830. /**
  45831. * Specifies that the submesh is ready to be used.
  45832. * @param defines the list of "defines" to update.
  45833. * @param scene defines the scene the material belongs to.
  45834. * @returns - boolean indicating that the submesh is ready or not.
  45835. */
  45836. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45837. /**
  45838. * Checks to see if a texture is used in the material.
  45839. * @param defines the list of "defines" to update.
  45840. * @param scene defines the scene the material belongs to.
  45841. */
  45842. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45843. /**
  45844. * Binds the material data.
  45845. * @param uniformBuffer defines the Uniform buffer to fill in.
  45846. * @param scene defines the scene the material belongs to.
  45847. * @param isFrozen defines wether the material is frozen or not.
  45848. */
  45849. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45850. /**
  45851. * Checks to see if a texture is used in the material.
  45852. * @param texture - Base texture to use.
  45853. * @returns - Boolean specifying if a texture is used in the material.
  45854. */
  45855. hasTexture(texture: BaseTexture): boolean;
  45856. /**
  45857. * Returns an array of the actively used textures.
  45858. * @param activeTextures Array of BaseTextures
  45859. */
  45860. getActiveTextures(activeTextures: BaseTexture[]): void;
  45861. /**
  45862. * Returns the animatable textures.
  45863. * @param animatables Array of animatable textures.
  45864. */
  45865. getAnimatables(animatables: IAnimatable[]): void;
  45866. /**
  45867. * Disposes the resources of the material.
  45868. * @param forceDisposeTextures - Forces the disposal of all textures.
  45869. */
  45870. dispose(forceDisposeTextures?: boolean): void;
  45871. /**
  45872. * Get the current class name of the texture useful for serialization or dynamic coding.
  45873. * @returns "PBRSheenConfiguration"
  45874. */
  45875. getClassName(): string;
  45876. /**
  45877. * Add fallbacks to the effect fallbacks list.
  45878. * @param defines defines the Base texture to use.
  45879. * @param fallbacks defines the current fallback list.
  45880. * @param currentRank defines the current fallback rank.
  45881. * @returns the new fallback rank.
  45882. */
  45883. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45884. /**
  45885. * Add the required uniforms to the current list.
  45886. * @param uniforms defines the current uniform list.
  45887. */
  45888. static AddUniforms(uniforms: string[]): void;
  45889. /**
  45890. * Add the required uniforms to the current buffer.
  45891. * @param uniformBuffer defines the current uniform buffer.
  45892. */
  45893. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45894. /**
  45895. * Add the required samplers to the current list.
  45896. * @param samplers defines the current sampler list.
  45897. */
  45898. static AddSamplers(samplers: string[]): void;
  45899. /**
  45900. * Makes a duplicate of the current configuration into another one.
  45901. * @param sheenConfiguration define the config where to copy the info
  45902. */
  45903. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45904. /**
  45905. * Serializes this BRDF configuration.
  45906. * @returns - An object with the serialized config.
  45907. */
  45908. serialize(): any;
  45909. /**
  45910. * Parses a Sheen Configuration from a serialized object.
  45911. * @param source - Serialized object.
  45912. */
  45913. parse(source: any): void;
  45914. }
  45915. }
  45916. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  45917. import { Nullable } from "babylonjs/types";
  45918. import { IAnimatable } from "babylonjs/Misc/tools";
  45919. import { Color3 } from "babylonjs/Maths/math";
  45920. import { SmartArray } from "babylonjs/Misc/smartArray";
  45921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45922. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45923. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  45924. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45925. import { Engine } from "babylonjs/Engines/engine";
  45926. import { Scene } from "babylonjs/scene";
  45927. /**
  45928. * @hidden
  45929. */
  45930. export interface IMaterialSubSurfaceDefines {
  45931. SUBSURFACE: boolean;
  45932. SS_REFRACTION: boolean;
  45933. SS_TRANSLUCENCY: boolean;
  45934. SS_SCATERRING: boolean;
  45935. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45936. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45937. SS_REFRACTIONMAP_3D: boolean;
  45938. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45939. SS_LODINREFRACTIONALPHA: boolean;
  45940. SS_GAMMAREFRACTION: boolean;
  45941. SS_RGBDREFRACTION: boolean;
  45942. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45943. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45944. /** @hidden */
  45945. _areTexturesDirty: boolean;
  45946. }
  45947. /**
  45948. * Define the code related to the sub surface parameters of the pbr material.
  45949. */
  45950. export class PBRSubSurfaceConfiguration {
  45951. private _isRefractionEnabled;
  45952. /**
  45953. * Defines if the refraction is enabled in the material.
  45954. */
  45955. isRefractionEnabled: boolean;
  45956. private _isTranslucencyEnabled;
  45957. /**
  45958. * Defines if the translucency is enabled in the material.
  45959. */
  45960. isTranslucencyEnabled: boolean;
  45961. private _isScatteringEnabled;
  45962. /**
  45963. * Defines the refraction intensity of the material.
  45964. * The refraction when enabled replaces the Diffuse part of the material.
  45965. * The intensity helps transitionning between diffuse and refraction.
  45966. */
  45967. refractionIntensity: number;
  45968. /**
  45969. * Defines the translucency intensity of the material.
  45970. * When translucency has been enabled, this defines how much of the "translucency"
  45971. * is addded to the diffuse part of the material.
  45972. */
  45973. translucencyIntensity: number;
  45974. /**
  45975. * Defines the scattering intensity of the material.
  45976. * When scattering has been enabled, this defines how much of the "scattered light"
  45977. * is addded to the diffuse part of the material.
  45978. */
  45979. scatteringIntensity: number;
  45980. private _thicknessTexture;
  45981. /**
  45982. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45983. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45984. * 0 would mean minimumThickness
  45985. * 1 would mean maximumThickness
  45986. * The other channels might be use as a mask to vary the different effects intensity.
  45987. */
  45988. thicknessTexture: Nullable<BaseTexture>;
  45989. private _refractionTexture;
  45990. /**
  45991. * Defines the texture to use for refraction.
  45992. */
  45993. refractionTexture: Nullable<BaseTexture>;
  45994. private _indexOfRefraction;
  45995. /**
  45996. * Defines the indice of refraction used in the material.
  45997. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45998. */
  45999. indexOfRefraction: number;
  46000. private _invertRefractionY;
  46001. /**
  46002. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46003. */
  46004. invertRefractionY: boolean;
  46005. private _linkRefractionWithTransparency;
  46006. /**
  46007. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46008. * Materials half opaque for instance using refraction could benefit from this control.
  46009. */
  46010. linkRefractionWithTransparency: boolean;
  46011. /**
  46012. * Defines the minimum thickness stored in the thickness map.
  46013. * If no thickness map is defined, this value will be used to simulate thickness.
  46014. */
  46015. minimumThickness: number;
  46016. /**
  46017. * Defines the maximum thickness stored in the thickness map.
  46018. */
  46019. maximumThickness: number;
  46020. /**
  46021. * Defines the volume tint of the material.
  46022. * This is used for both translucency and scattering.
  46023. */
  46024. tintColor: Color3;
  46025. /**
  46026. * Defines the distance at which the tint color should be found in the media.
  46027. * This is used for refraction only.
  46028. */
  46029. tintColorAtDistance: number;
  46030. /**
  46031. * Defines how far each channel transmit through the media.
  46032. * It is defined as a color to simplify it selection.
  46033. */
  46034. diffusionDistance: Color3;
  46035. private _useMaskFromThicknessTexture;
  46036. /**
  46037. * Stores the intensity of the different subsurface effects in the thickness texture.
  46038. * * the green channel is the translucency intensity.
  46039. * * the blue channel is the scattering intensity.
  46040. * * the alpha channel is the refraction intensity.
  46041. */
  46042. useMaskFromThicknessTexture: boolean;
  46043. /** @hidden */
  46044. private _internalMarkAllSubMeshesAsTexturesDirty;
  46045. /** @hidden */
  46046. _markAllSubMeshesAsTexturesDirty(): void;
  46047. /**
  46048. * Instantiate a new istance of sub surface configuration.
  46049. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46050. */
  46051. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46052. /**
  46053. * Gets wehter the submesh is ready to be used or not.
  46054. * @param defines the list of "defines" to update.
  46055. * @param scene defines the scene the material belongs to.
  46056. * @returns - boolean indicating that the submesh is ready or not.
  46057. */
  46058. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46059. /**
  46060. * Checks to see if a texture is used in the material.
  46061. * @param defines the list of "defines" to update.
  46062. * @param scene defines the scene to the material belongs to.
  46063. */
  46064. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46065. /**
  46066. * Binds the material data.
  46067. * @param uniformBuffer defines the Uniform buffer to fill in.
  46068. * @param scene defines the scene the material belongs to.
  46069. * @param engine defines the engine the material belongs to.
  46070. * @param isFrozen defines wether the material is frozen or not.
  46071. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46072. */
  46073. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46074. /**
  46075. * Unbinds the material from the mesh.
  46076. * @param activeEffect defines the effect that should be unbound from.
  46077. * @returns true if unbound, otherwise false
  46078. */
  46079. unbind(activeEffect: Effect): boolean;
  46080. /**
  46081. * Returns the texture used for refraction or null if none is used.
  46082. * @param scene defines the scene the material belongs to.
  46083. * @returns - Refraction texture if present. If no refraction texture and refraction
  46084. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46085. */
  46086. private _getRefractionTexture;
  46087. /**
  46088. * Returns true if alpha blending should be disabled.
  46089. */
  46090. readonly disableAlphaBlending: boolean;
  46091. /**
  46092. * Fills the list of render target textures.
  46093. * @param renderTargets the list of render targets to update
  46094. */
  46095. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46096. /**
  46097. * Checks to see if a texture is used in the material.
  46098. * @param texture - Base texture to use.
  46099. * @returns - Boolean specifying if a texture is used in the material.
  46100. */
  46101. hasTexture(texture: BaseTexture): boolean;
  46102. /**
  46103. * Gets a boolean indicating that current material needs to register RTT
  46104. * @returns true if this uses a render target otherwise false.
  46105. */
  46106. hasRenderTargetTextures(): boolean;
  46107. /**
  46108. * Returns an array of the actively used textures.
  46109. * @param activeTextures Array of BaseTextures
  46110. */
  46111. getActiveTextures(activeTextures: BaseTexture[]): void;
  46112. /**
  46113. * Returns the animatable textures.
  46114. * @param animatables Array of animatable textures.
  46115. */
  46116. getAnimatables(animatables: IAnimatable[]): void;
  46117. /**
  46118. * Disposes the resources of the material.
  46119. * @param forceDisposeTextures - Forces the disposal of all textures.
  46120. */
  46121. dispose(forceDisposeTextures?: boolean): void;
  46122. /**
  46123. * Get the current class name of the texture useful for serialization or dynamic coding.
  46124. * @returns "PBRSubSurfaceConfiguration"
  46125. */
  46126. getClassName(): string;
  46127. /**
  46128. * Add fallbacks to the effect fallbacks list.
  46129. * @param defines defines the Base texture to use.
  46130. * @param fallbacks defines the current fallback list.
  46131. * @param currentRank defines the current fallback rank.
  46132. * @returns the new fallback rank.
  46133. */
  46134. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46135. /**
  46136. * Add the required uniforms to the current list.
  46137. * @param uniforms defines the current uniform list.
  46138. */
  46139. static AddUniforms(uniforms: string[]): void;
  46140. /**
  46141. * Add the required samplers to the current list.
  46142. * @param samplers defines the current sampler list.
  46143. */
  46144. static AddSamplers(samplers: string[]): void;
  46145. /**
  46146. * Add the required uniforms to the current buffer.
  46147. * @param uniformBuffer defines the current uniform buffer.
  46148. */
  46149. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46150. /**
  46151. * Makes a duplicate of the current configuration into another one.
  46152. * @param configuration define the config where to copy the info
  46153. */
  46154. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46155. /**
  46156. * Serializes this Sub Surface configuration.
  46157. * @returns - An object with the serialized config.
  46158. */
  46159. serialize(): any;
  46160. /**
  46161. * Parses a Sub Surface Configuration from a serialized object.
  46162. * @param source - Serialized object.
  46163. */
  46164. parse(source: any): void;
  46165. }
  46166. }
  46167. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46168. /** @hidden */
  46169. export var pbrFragmentDeclaration: {
  46170. name: string;
  46171. shader: string;
  46172. };
  46173. }
  46174. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46175. /** @hidden */
  46176. export var pbrUboDeclaration: {
  46177. name: string;
  46178. shader: string;
  46179. };
  46180. }
  46181. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46182. /** @hidden */
  46183. export var pbrFragmentExtraDeclaration: {
  46184. name: string;
  46185. shader: string;
  46186. };
  46187. }
  46188. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46189. /** @hidden */
  46190. export var pbrFragmentSamplersDeclaration: {
  46191. name: string;
  46192. shader: string;
  46193. };
  46194. }
  46195. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46196. /** @hidden */
  46197. export var pbrHelperFunctions: {
  46198. name: string;
  46199. shader: string;
  46200. };
  46201. }
  46202. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46203. /** @hidden */
  46204. export var harmonicsFunctions: {
  46205. name: string;
  46206. shader: string;
  46207. };
  46208. }
  46209. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46210. /** @hidden */
  46211. export var pbrDirectLightingSetupFunctions: {
  46212. name: string;
  46213. shader: string;
  46214. };
  46215. }
  46216. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46217. /** @hidden */
  46218. export var pbrDirectLightingFalloffFunctions: {
  46219. name: string;
  46220. shader: string;
  46221. };
  46222. }
  46223. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46224. /** @hidden */
  46225. export var pbrBRDFFunctions: {
  46226. name: string;
  46227. shader: string;
  46228. };
  46229. }
  46230. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46231. /** @hidden */
  46232. export var pbrDirectLightingFunctions: {
  46233. name: string;
  46234. shader: string;
  46235. };
  46236. }
  46237. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46238. /** @hidden */
  46239. export var pbrIBLFunctions: {
  46240. name: string;
  46241. shader: string;
  46242. };
  46243. }
  46244. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46245. /** @hidden */
  46246. export var pbrDebug: {
  46247. name: string;
  46248. shader: string;
  46249. };
  46250. }
  46251. declare module "babylonjs/Shaders/pbr.fragment" {
  46252. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46253. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46254. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46255. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46256. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46257. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46258. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46259. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46260. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46261. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46262. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46263. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46264. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46265. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46266. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46267. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46268. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46269. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46270. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46271. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46272. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46273. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46274. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46275. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46276. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46277. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46278. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46279. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46280. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46281. /** @hidden */
  46282. export var pbrPixelShader: {
  46283. name: string;
  46284. shader: string;
  46285. };
  46286. }
  46287. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46288. /** @hidden */
  46289. export var pbrVertexDeclaration: {
  46290. name: string;
  46291. shader: string;
  46292. };
  46293. }
  46294. declare module "babylonjs/Shaders/pbr.vertex" {
  46295. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46296. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46297. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46298. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46299. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46300. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46301. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46302. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46303. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46304. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46305. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46306. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46307. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46308. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46309. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46310. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46311. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46312. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46313. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46314. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46315. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46316. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46317. /** @hidden */
  46318. export var pbrVertexShader: {
  46319. name: string;
  46320. shader: string;
  46321. };
  46322. }
  46323. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46324. import { IAnimatable } from "babylonjs/Misc/tools";
  46325. import { Nullable } from "babylonjs/types";
  46326. import { Scene } from "babylonjs/scene";
  46327. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46328. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46330. import { Mesh } from "babylonjs/Meshes/mesh";
  46331. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46332. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46333. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46334. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46335. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46336. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46337. import { Material } from "babylonjs/Materials/material";
  46338. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46339. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46340. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46341. import "babylonjs/Shaders/pbr.fragment";
  46342. import "babylonjs/Shaders/pbr.vertex";
  46343. /**
  46344. * Manages the defines for the PBR Material.
  46345. * @hidden
  46346. */
  46347. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46348. PBR: boolean;
  46349. MAINUV1: boolean;
  46350. MAINUV2: boolean;
  46351. UV1: boolean;
  46352. UV2: boolean;
  46353. ALBEDO: boolean;
  46354. ALBEDODIRECTUV: number;
  46355. VERTEXCOLOR: boolean;
  46356. AMBIENT: boolean;
  46357. AMBIENTDIRECTUV: number;
  46358. AMBIENTINGRAYSCALE: boolean;
  46359. OPACITY: boolean;
  46360. VERTEXALPHA: boolean;
  46361. OPACITYDIRECTUV: number;
  46362. OPACITYRGB: boolean;
  46363. ALPHATEST: boolean;
  46364. DEPTHPREPASS: boolean;
  46365. ALPHABLEND: boolean;
  46366. ALPHAFROMALBEDO: boolean;
  46367. ALPHATESTVALUE: string;
  46368. SPECULAROVERALPHA: boolean;
  46369. RADIANCEOVERALPHA: boolean;
  46370. ALPHAFRESNEL: boolean;
  46371. LINEARALPHAFRESNEL: boolean;
  46372. PREMULTIPLYALPHA: boolean;
  46373. EMISSIVE: boolean;
  46374. EMISSIVEDIRECTUV: number;
  46375. REFLECTIVITY: boolean;
  46376. REFLECTIVITYDIRECTUV: number;
  46377. SPECULARTERM: boolean;
  46378. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46379. MICROSURFACEAUTOMATIC: boolean;
  46380. LODBASEDMICROSFURACE: boolean;
  46381. MICROSURFACEMAP: boolean;
  46382. MICROSURFACEMAPDIRECTUV: number;
  46383. METALLICWORKFLOW: boolean;
  46384. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46385. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46386. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46387. AOSTOREINMETALMAPRED: boolean;
  46388. ENVIRONMENTBRDF: boolean;
  46389. ENVIRONMENTBRDF_RGBD: boolean;
  46390. NORMAL: boolean;
  46391. TANGENT: boolean;
  46392. BUMP: boolean;
  46393. BUMPDIRECTUV: number;
  46394. OBJECTSPACE_NORMALMAP: boolean;
  46395. PARALLAX: boolean;
  46396. PARALLAXOCCLUSION: boolean;
  46397. NORMALXYSCALE: boolean;
  46398. LIGHTMAP: boolean;
  46399. LIGHTMAPDIRECTUV: number;
  46400. USELIGHTMAPASSHADOWMAP: boolean;
  46401. GAMMALIGHTMAP: boolean;
  46402. REFLECTION: boolean;
  46403. REFLECTIONMAP_3D: boolean;
  46404. REFLECTIONMAP_SPHERICAL: boolean;
  46405. REFLECTIONMAP_PLANAR: boolean;
  46406. REFLECTIONMAP_CUBIC: boolean;
  46407. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46408. REFLECTIONMAP_PROJECTION: boolean;
  46409. REFLECTIONMAP_SKYBOX: boolean;
  46410. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46411. REFLECTIONMAP_EXPLICIT: boolean;
  46412. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46413. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46414. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46415. INVERTCUBICMAP: boolean;
  46416. USESPHERICALFROMREFLECTIONMAP: boolean;
  46417. USESPHERICALINVERTEX: boolean;
  46418. REFLECTIONMAP_OPPOSITEZ: boolean;
  46419. LODINREFLECTIONALPHA: boolean;
  46420. GAMMAREFLECTION: boolean;
  46421. RGBDREFLECTION: boolean;
  46422. RADIANCEOCCLUSION: boolean;
  46423. HORIZONOCCLUSION: boolean;
  46424. INSTANCES: boolean;
  46425. NUM_BONE_INFLUENCERS: number;
  46426. BonesPerMesh: number;
  46427. BONETEXTURE: boolean;
  46428. NONUNIFORMSCALING: boolean;
  46429. MORPHTARGETS: boolean;
  46430. MORPHTARGETS_NORMAL: boolean;
  46431. MORPHTARGETS_TANGENT: boolean;
  46432. NUM_MORPH_INFLUENCERS: number;
  46433. IMAGEPROCESSING: boolean;
  46434. VIGNETTE: boolean;
  46435. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46436. VIGNETTEBLENDMODEOPAQUE: boolean;
  46437. TONEMAPPING: boolean;
  46438. TONEMAPPING_ACES: boolean;
  46439. CONTRAST: boolean;
  46440. COLORCURVES: boolean;
  46441. COLORGRADING: boolean;
  46442. COLORGRADING3D: boolean;
  46443. SAMPLER3DGREENDEPTH: boolean;
  46444. SAMPLER3DBGRMAP: boolean;
  46445. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46446. EXPOSURE: boolean;
  46447. MULTIVIEW: boolean;
  46448. USEPHYSICALLIGHTFALLOFF: boolean;
  46449. USEGLTFLIGHTFALLOFF: boolean;
  46450. TWOSIDEDLIGHTING: boolean;
  46451. SHADOWFLOAT: boolean;
  46452. CLIPPLANE: boolean;
  46453. CLIPPLANE2: boolean;
  46454. CLIPPLANE3: boolean;
  46455. CLIPPLANE4: boolean;
  46456. POINTSIZE: boolean;
  46457. FOG: boolean;
  46458. LOGARITHMICDEPTH: boolean;
  46459. FORCENORMALFORWARD: boolean;
  46460. SPECULARAA: boolean;
  46461. CLEARCOAT: boolean;
  46462. CLEARCOAT_DEFAULTIOR: boolean;
  46463. CLEARCOAT_TEXTURE: boolean;
  46464. CLEARCOAT_TEXTUREDIRECTUV: number;
  46465. CLEARCOAT_BUMP: boolean;
  46466. CLEARCOAT_BUMPDIRECTUV: number;
  46467. CLEARCOAT_TINT: boolean;
  46468. CLEARCOAT_TINT_TEXTURE: boolean;
  46469. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46470. ANISOTROPIC: boolean;
  46471. ANISOTROPIC_TEXTURE: boolean;
  46472. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46473. BRDF_V_HEIGHT_CORRELATED: boolean;
  46474. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46475. SHEEN: boolean;
  46476. SHEEN_TEXTURE: boolean;
  46477. SHEEN_TEXTUREDIRECTUV: number;
  46478. SHEEN_LINKWITHALBEDO: boolean;
  46479. SUBSURFACE: boolean;
  46480. SS_REFRACTION: boolean;
  46481. SS_TRANSLUCENCY: boolean;
  46482. SS_SCATERRING: boolean;
  46483. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46484. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46485. SS_REFRACTIONMAP_3D: boolean;
  46486. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46487. SS_LODINREFRACTIONALPHA: boolean;
  46488. SS_GAMMAREFRACTION: boolean;
  46489. SS_RGBDREFRACTION: boolean;
  46490. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46491. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46492. UNLIT: boolean;
  46493. DEBUGMODE: number;
  46494. /**
  46495. * Initializes the PBR Material defines.
  46496. */
  46497. constructor();
  46498. /**
  46499. * Resets the PBR Material defines.
  46500. */
  46501. reset(): void;
  46502. }
  46503. /**
  46504. * The Physically based material base class of BJS.
  46505. *
  46506. * This offers the main features of a standard PBR material.
  46507. * For more information, please refer to the documentation :
  46508. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46509. */
  46510. export abstract class PBRBaseMaterial extends PushMaterial {
  46511. /**
  46512. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46513. */
  46514. static readonly PBRMATERIAL_OPAQUE: number;
  46515. /**
  46516. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46517. */
  46518. static readonly PBRMATERIAL_ALPHATEST: number;
  46519. /**
  46520. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46521. */
  46522. static readonly PBRMATERIAL_ALPHABLEND: number;
  46523. /**
  46524. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46525. * They are also discarded below the alpha cutoff threshold to improve performances.
  46526. */
  46527. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46528. /**
  46529. * Defines the default value of how much AO map is occluding the analytical lights
  46530. * (point spot...).
  46531. */
  46532. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46533. /**
  46534. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46535. */
  46536. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46537. /**
  46538. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46539. * to enhance interoperability with other engines.
  46540. */
  46541. static readonly LIGHTFALLOFF_GLTF: number;
  46542. /**
  46543. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46544. * to enhance interoperability with other materials.
  46545. */
  46546. static readonly LIGHTFALLOFF_STANDARD: number;
  46547. /**
  46548. * Intensity of the direct lights e.g. the four lights available in your scene.
  46549. * This impacts both the direct diffuse and specular highlights.
  46550. */
  46551. protected _directIntensity: number;
  46552. /**
  46553. * Intensity of the emissive part of the material.
  46554. * This helps controlling the emissive effect without modifying the emissive color.
  46555. */
  46556. protected _emissiveIntensity: number;
  46557. /**
  46558. * Intensity of the environment e.g. how much the environment will light the object
  46559. * either through harmonics for rough material or through the refelction for shiny ones.
  46560. */
  46561. protected _environmentIntensity: number;
  46562. /**
  46563. * This is a special control allowing the reduction of the specular highlights coming from the
  46564. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46565. */
  46566. protected _specularIntensity: number;
  46567. /**
  46568. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46569. */
  46570. private _lightingInfos;
  46571. /**
  46572. * Debug Control allowing disabling the bump map on this material.
  46573. */
  46574. protected _disableBumpMap: boolean;
  46575. /**
  46576. * AKA Diffuse Texture in standard nomenclature.
  46577. */
  46578. protected _albedoTexture: BaseTexture;
  46579. /**
  46580. * AKA Occlusion Texture in other nomenclature.
  46581. */
  46582. protected _ambientTexture: BaseTexture;
  46583. /**
  46584. * AKA Occlusion Texture Intensity in other nomenclature.
  46585. */
  46586. protected _ambientTextureStrength: number;
  46587. /**
  46588. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46589. * 1 means it completely occludes it
  46590. * 0 mean it has no impact
  46591. */
  46592. protected _ambientTextureImpactOnAnalyticalLights: number;
  46593. /**
  46594. * Stores the alpha values in a texture.
  46595. */
  46596. protected _opacityTexture: BaseTexture;
  46597. /**
  46598. * Stores the reflection values in a texture.
  46599. */
  46600. protected _reflectionTexture: BaseTexture;
  46601. /**
  46602. * Stores the emissive values in a texture.
  46603. */
  46604. protected _emissiveTexture: BaseTexture;
  46605. /**
  46606. * AKA Specular texture in other nomenclature.
  46607. */
  46608. protected _reflectivityTexture: BaseTexture;
  46609. /**
  46610. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46611. */
  46612. protected _metallicTexture: BaseTexture;
  46613. /**
  46614. * Specifies the metallic scalar of the metallic/roughness workflow.
  46615. * Can also be used to scale the metalness values of the metallic texture.
  46616. */
  46617. protected _metallic: Nullable<number>;
  46618. /**
  46619. * Specifies the roughness scalar of the metallic/roughness workflow.
  46620. * Can also be used to scale the roughness values of the metallic texture.
  46621. */
  46622. protected _roughness: Nullable<number>;
  46623. /**
  46624. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46625. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46626. */
  46627. protected _microSurfaceTexture: BaseTexture;
  46628. /**
  46629. * Stores surface normal data used to displace a mesh in a texture.
  46630. */
  46631. protected _bumpTexture: BaseTexture;
  46632. /**
  46633. * Stores the pre-calculated light information of a mesh in a texture.
  46634. */
  46635. protected _lightmapTexture: BaseTexture;
  46636. /**
  46637. * The color of a material in ambient lighting.
  46638. */
  46639. protected _ambientColor: Color3;
  46640. /**
  46641. * AKA Diffuse Color in other nomenclature.
  46642. */
  46643. protected _albedoColor: Color3;
  46644. /**
  46645. * AKA Specular Color in other nomenclature.
  46646. */
  46647. protected _reflectivityColor: Color3;
  46648. /**
  46649. * The color applied when light is reflected from a material.
  46650. */
  46651. protected _reflectionColor: Color3;
  46652. /**
  46653. * The color applied when light is emitted from a material.
  46654. */
  46655. protected _emissiveColor: Color3;
  46656. /**
  46657. * AKA Glossiness in other nomenclature.
  46658. */
  46659. protected _microSurface: number;
  46660. /**
  46661. * Specifies that the material will use the light map as a show map.
  46662. */
  46663. protected _useLightmapAsShadowmap: boolean;
  46664. /**
  46665. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46666. * makes the reflect vector face the model (under horizon).
  46667. */
  46668. protected _useHorizonOcclusion: boolean;
  46669. /**
  46670. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46671. * too much the area relying on ambient texture to define their ambient occlusion.
  46672. */
  46673. protected _useRadianceOcclusion: boolean;
  46674. /**
  46675. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46676. */
  46677. protected _useAlphaFromAlbedoTexture: boolean;
  46678. /**
  46679. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46680. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46681. */
  46682. protected _useSpecularOverAlpha: boolean;
  46683. /**
  46684. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46685. */
  46686. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46687. /**
  46688. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46689. */
  46690. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46691. /**
  46692. * Specifies if the metallic texture contains the roughness information in its green channel.
  46693. */
  46694. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46695. /**
  46696. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46697. */
  46698. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46699. /**
  46700. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46701. */
  46702. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46703. /**
  46704. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46705. */
  46706. protected _useAmbientInGrayScale: boolean;
  46707. /**
  46708. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46709. * The material will try to infer what glossiness each pixel should be.
  46710. */
  46711. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46712. /**
  46713. * Defines the falloff type used in this material.
  46714. * It by default is Physical.
  46715. */
  46716. protected _lightFalloff: number;
  46717. /**
  46718. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46719. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46720. */
  46721. protected _useRadianceOverAlpha: boolean;
  46722. /**
  46723. * Allows using an object space normal map (instead of tangent space).
  46724. */
  46725. protected _useObjectSpaceNormalMap: boolean;
  46726. /**
  46727. * Allows using the bump map in parallax mode.
  46728. */
  46729. protected _useParallax: boolean;
  46730. /**
  46731. * Allows using the bump map in parallax occlusion mode.
  46732. */
  46733. protected _useParallaxOcclusion: boolean;
  46734. /**
  46735. * Controls the scale bias of the parallax mode.
  46736. */
  46737. protected _parallaxScaleBias: number;
  46738. /**
  46739. * If sets to true, disables all the lights affecting the material.
  46740. */
  46741. protected _disableLighting: boolean;
  46742. /**
  46743. * Number of Simultaneous lights allowed on the material.
  46744. */
  46745. protected _maxSimultaneousLights: number;
  46746. /**
  46747. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46748. */
  46749. protected _invertNormalMapX: boolean;
  46750. /**
  46751. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46752. */
  46753. protected _invertNormalMapY: boolean;
  46754. /**
  46755. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46756. */
  46757. protected _twoSidedLighting: boolean;
  46758. /**
  46759. * Defines the alpha limits in alpha test mode.
  46760. */
  46761. protected _alphaCutOff: number;
  46762. /**
  46763. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46764. */
  46765. protected _forceAlphaTest: boolean;
  46766. /**
  46767. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46768. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46769. */
  46770. protected _useAlphaFresnel: boolean;
  46771. /**
  46772. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46773. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46774. */
  46775. protected _useLinearAlphaFresnel: boolean;
  46776. /**
  46777. * The transparency mode of the material.
  46778. */
  46779. protected _transparencyMode: Nullable<number>;
  46780. /**
  46781. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46782. * from cos thetav and roughness:
  46783. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46784. */
  46785. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46786. /**
  46787. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46788. */
  46789. protected _forceIrradianceInFragment: boolean;
  46790. /**
  46791. * Force normal to face away from face.
  46792. */
  46793. protected _forceNormalForward: boolean;
  46794. /**
  46795. * Enables specular anti aliasing in the PBR shader.
  46796. * It will both interacts on the Geometry for analytical and IBL lighting.
  46797. * It also prefilter the roughness map based on the bump values.
  46798. */
  46799. protected _enableSpecularAntiAliasing: boolean;
  46800. /**
  46801. * Default configuration related to image processing available in the PBR Material.
  46802. */
  46803. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46804. /**
  46805. * Keep track of the image processing observer to allow dispose and replace.
  46806. */
  46807. private _imageProcessingObserver;
  46808. /**
  46809. * Attaches a new image processing configuration to the PBR Material.
  46810. * @param configuration
  46811. */
  46812. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46813. /**
  46814. * Stores the available render targets.
  46815. */
  46816. private _renderTargets;
  46817. /**
  46818. * Sets the global ambient color for the material used in lighting calculations.
  46819. */
  46820. private _globalAmbientColor;
  46821. /**
  46822. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46823. */
  46824. private _useLogarithmicDepth;
  46825. /**
  46826. * If set to true, no lighting calculations will be applied.
  46827. */
  46828. private _unlit;
  46829. private _debugMode;
  46830. /**
  46831. * @hidden
  46832. * This is reserved for the inspector.
  46833. * Defines the material debug mode.
  46834. * It helps seeing only some components of the material while troubleshooting.
  46835. */
  46836. debugMode: number;
  46837. /**
  46838. * @hidden
  46839. * This is reserved for the inspector.
  46840. * Specify from where on screen the debug mode should start.
  46841. * The value goes from -1 (full screen) to 1 (not visible)
  46842. * It helps with side by side comparison against the final render
  46843. * This defaults to -1
  46844. */
  46845. private debugLimit;
  46846. /**
  46847. * @hidden
  46848. * This is reserved for the inspector.
  46849. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46850. * You can use the factor to better multiply the final value.
  46851. */
  46852. private debugFactor;
  46853. /**
  46854. * Defines the clear coat layer parameters for the material.
  46855. */
  46856. readonly clearCoat: PBRClearCoatConfiguration;
  46857. /**
  46858. * Defines the anisotropic parameters for the material.
  46859. */
  46860. readonly anisotropy: PBRAnisotropicConfiguration;
  46861. /**
  46862. * Defines the BRDF parameters for the material.
  46863. */
  46864. readonly brdf: PBRBRDFConfiguration;
  46865. /**
  46866. * Defines the Sheen parameters for the material.
  46867. */
  46868. readonly sheen: PBRSheenConfiguration;
  46869. /**
  46870. * Defines the SubSurface parameters for the material.
  46871. */
  46872. readonly subSurface: PBRSubSurfaceConfiguration;
  46873. /**
  46874. * Custom callback helping to override the default shader used in the material.
  46875. */
  46876. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46877. /**
  46878. * Instantiates a new PBRMaterial instance.
  46879. *
  46880. * @param name The material name
  46881. * @param scene The scene the material will be use in.
  46882. */
  46883. constructor(name: string, scene: Scene);
  46884. /**
  46885. * Gets a boolean indicating that current material needs to register RTT
  46886. */
  46887. readonly hasRenderTargetTextures: boolean;
  46888. /**
  46889. * Gets the name of the material class.
  46890. */
  46891. getClassName(): string;
  46892. /**
  46893. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46894. */
  46895. /**
  46896. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46897. */
  46898. useLogarithmicDepth: boolean;
  46899. /**
  46900. * Gets the current transparency mode.
  46901. */
  46902. /**
  46903. * Sets the transparency mode of the material.
  46904. *
  46905. * | Value | Type | Description |
  46906. * | ----- | ----------------------------------- | ----------- |
  46907. * | 0 | OPAQUE | |
  46908. * | 1 | ALPHATEST | |
  46909. * | 2 | ALPHABLEND | |
  46910. * | 3 | ALPHATESTANDBLEND | |
  46911. *
  46912. */
  46913. transparencyMode: Nullable<number>;
  46914. /**
  46915. * Returns true if alpha blending should be disabled.
  46916. */
  46917. private readonly _disableAlphaBlending;
  46918. /**
  46919. * Specifies whether or not this material should be rendered in alpha blend mode.
  46920. */
  46921. needAlphaBlending(): boolean;
  46922. /**
  46923. * Specifies if the mesh will require alpha blending.
  46924. * @param mesh - BJS mesh.
  46925. */
  46926. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46927. /**
  46928. * Specifies whether or not this material should be rendered in alpha test mode.
  46929. */
  46930. needAlphaTesting(): boolean;
  46931. /**
  46932. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46933. */
  46934. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46935. /**
  46936. * Gets the texture used for the alpha test.
  46937. */
  46938. getAlphaTestTexture(): BaseTexture;
  46939. /**
  46940. * Specifies that the submesh is ready to be used.
  46941. * @param mesh - BJS mesh.
  46942. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46943. * @param useInstances - Specifies that instances should be used.
  46944. * @returns - boolean indicating that the submesh is ready or not.
  46945. */
  46946. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46947. /**
  46948. * Specifies if the material uses metallic roughness workflow.
  46949. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46950. */
  46951. isMetallicWorkflow(): boolean;
  46952. private _prepareEffect;
  46953. private _prepareDefines;
  46954. /**
  46955. * Force shader compilation
  46956. */
  46957. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46958. clipPlane: boolean;
  46959. }>): void;
  46960. /**
  46961. * Initializes the uniform buffer layout for the shader.
  46962. */
  46963. buildUniformLayout(): void;
  46964. /**
  46965. * Unbinds the material from the mesh
  46966. */
  46967. unbind(): void;
  46968. /**
  46969. * Binds the submesh data.
  46970. * @param world - The world matrix.
  46971. * @param mesh - The BJS mesh.
  46972. * @param subMesh - A submesh of the BJS mesh.
  46973. */
  46974. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46975. /**
  46976. * Returns the animatable textures.
  46977. * @returns - Array of animatable textures.
  46978. */
  46979. getAnimatables(): IAnimatable[];
  46980. /**
  46981. * Returns the texture used for reflections.
  46982. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46983. */
  46984. private _getReflectionTexture;
  46985. /**
  46986. * Returns an array of the actively used textures.
  46987. * @returns - Array of BaseTextures
  46988. */
  46989. getActiveTextures(): BaseTexture[];
  46990. /**
  46991. * Checks to see if a texture is used in the material.
  46992. * @param texture - Base texture to use.
  46993. * @returns - Boolean specifying if a texture is used in the material.
  46994. */
  46995. hasTexture(texture: BaseTexture): boolean;
  46996. /**
  46997. * Disposes the resources of the material.
  46998. * @param forceDisposeEffect - Forces the disposal of effects.
  46999. * @param forceDisposeTextures - Forces the disposal of all textures.
  47000. */
  47001. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47002. }
  47003. }
  47004. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47005. import { Nullable } from "babylonjs/types";
  47006. import { Scene } from "babylonjs/scene";
  47007. import { Color3 } from "babylonjs/Maths/math";
  47008. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47009. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47010. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47011. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47012. /**
  47013. * The Physically based material of BJS.
  47014. *
  47015. * This offers the main features of a standard PBR material.
  47016. * For more information, please refer to the documentation :
  47017. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47018. */
  47019. export class PBRMaterial extends PBRBaseMaterial {
  47020. /**
  47021. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47022. */
  47023. static readonly PBRMATERIAL_OPAQUE: number;
  47024. /**
  47025. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47026. */
  47027. static readonly PBRMATERIAL_ALPHATEST: number;
  47028. /**
  47029. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47030. */
  47031. static readonly PBRMATERIAL_ALPHABLEND: number;
  47032. /**
  47033. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47034. * They are also discarded below the alpha cutoff threshold to improve performances.
  47035. */
  47036. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47037. /**
  47038. * Defines the default value of how much AO map is occluding the analytical lights
  47039. * (point spot...).
  47040. */
  47041. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47042. /**
  47043. * Intensity of the direct lights e.g. the four lights available in your scene.
  47044. * This impacts both the direct diffuse and specular highlights.
  47045. */
  47046. directIntensity: number;
  47047. /**
  47048. * Intensity of the emissive part of the material.
  47049. * This helps controlling the emissive effect without modifying the emissive color.
  47050. */
  47051. emissiveIntensity: number;
  47052. /**
  47053. * Intensity of the environment e.g. how much the environment will light the object
  47054. * either through harmonics for rough material or through the refelction for shiny ones.
  47055. */
  47056. environmentIntensity: number;
  47057. /**
  47058. * This is a special control allowing the reduction of the specular highlights coming from the
  47059. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47060. */
  47061. specularIntensity: number;
  47062. /**
  47063. * Debug Control allowing disabling the bump map on this material.
  47064. */
  47065. disableBumpMap: boolean;
  47066. /**
  47067. * AKA Diffuse Texture in standard nomenclature.
  47068. */
  47069. albedoTexture: BaseTexture;
  47070. /**
  47071. * AKA Occlusion Texture in other nomenclature.
  47072. */
  47073. ambientTexture: BaseTexture;
  47074. /**
  47075. * AKA Occlusion Texture Intensity in other nomenclature.
  47076. */
  47077. ambientTextureStrength: number;
  47078. /**
  47079. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47080. * 1 means it completely occludes it
  47081. * 0 mean it has no impact
  47082. */
  47083. ambientTextureImpactOnAnalyticalLights: number;
  47084. /**
  47085. * Stores the alpha values in a texture.
  47086. */
  47087. opacityTexture: BaseTexture;
  47088. /**
  47089. * Stores the reflection values in a texture.
  47090. */
  47091. reflectionTexture: Nullable<BaseTexture>;
  47092. /**
  47093. * Stores the emissive values in a texture.
  47094. */
  47095. emissiveTexture: BaseTexture;
  47096. /**
  47097. * AKA Specular texture in other nomenclature.
  47098. */
  47099. reflectivityTexture: BaseTexture;
  47100. /**
  47101. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47102. */
  47103. metallicTexture: BaseTexture;
  47104. /**
  47105. * Specifies the metallic scalar of the metallic/roughness workflow.
  47106. * Can also be used to scale the metalness values of the metallic texture.
  47107. */
  47108. metallic: Nullable<number>;
  47109. /**
  47110. * Specifies the roughness scalar of the metallic/roughness workflow.
  47111. * Can also be used to scale the roughness values of the metallic texture.
  47112. */
  47113. roughness: Nullable<number>;
  47114. /**
  47115. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47116. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47117. */
  47118. microSurfaceTexture: BaseTexture;
  47119. /**
  47120. * Stores surface normal data used to displace a mesh in a texture.
  47121. */
  47122. bumpTexture: BaseTexture;
  47123. /**
  47124. * Stores the pre-calculated light information of a mesh in a texture.
  47125. */
  47126. lightmapTexture: BaseTexture;
  47127. /**
  47128. * Stores the refracted light information in a texture.
  47129. */
  47130. refractionTexture: Nullable<BaseTexture>;
  47131. /**
  47132. * The color of a material in ambient lighting.
  47133. */
  47134. ambientColor: Color3;
  47135. /**
  47136. * AKA Diffuse Color in other nomenclature.
  47137. */
  47138. albedoColor: Color3;
  47139. /**
  47140. * AKA Specular Color in other nomenclature.
  47141. */
  47142. reflectivityColor: Color3;
  47143. /**
  47144. * The color reflected from the material.
  47145. */
  47146. reflectionColor: Color3;
  47147. /**
  47148. * The color emitted from the material.
  47149. */
  47150. emissiveColor: Color3;
  47151. /**
  47152. * AKA Glossiness in other nomenclature.
  47153. */
  47154. microSurface: number;
  47155. /**
  47156. * source material index of refraction (IOR)' / 'destination material IOR.
  47157. */
  47158. indexOfRefraction: number;
  47159. /**
  47160. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47161. */
  47162. invertRefractionY: boolean;
  47163. /**
  47164. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47165. * Materials half opaque for instance using refraction could benefit from this control.
  47166. */
  47167. linkRefractionWithTransparency: boolean;
  47168. /**
  47169. * If true, the light map contains occlusion information instead of lighting info.
  47170. */
  47171. useLightmapAsShadowmap: boolean;
  47172. /**
  47173. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47174. */
  47175. useAlphaFromAlbedoTexture: boolean;
  47176. /**
  47177. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47178. */
  47179. forceAlphaTest: boolean;
  47180. /**
  47181. * Defines the alpha limits in alpha test mode.
  47182. */
  47183. alphaCutOff: number;
  47184. /**
  47185. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47186. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47187. */
  47188. useSpecularOverAlpha: boolean;
  47189. /**
  47190. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47191. */
  47192. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47193. /**
  47194. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47195. */
  47196. useRoughnessFromMetallicTextureAlpha: boolean;
  47197. /**
  47198. * Specifies if the metallic texture contains the roughness information in its green channel.
  47199. */
  47200. useRoughnessFromMetallicTextureGreen: boolean;
  47201. /**
  47202. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47203. */
  47204. useMetallnessFromMetallicTextureBlue: boolean;
  47205. /**
  47206. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47207. */
  47208. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47209. /**
  47210. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47211. */
  47212. useAmbientInGrayScale: boolean;
  47213. /**
  47214. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47215. * The material will try to infer what glossiness each pixel should be.
  47216. */
  47217. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47218. /**
  47219. * BJS is using an harcoded light falloff based on a manually sets up range.
  47220. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47221. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47222. */
  47223. /**
  47224. * BJS is using an harcoded light falloff based on a manually sets up range.
  47225. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47226. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47227. */
  47228. usePhysicalLightFalloff: boolean;
  47229. /**
  47230. * In order to support the falloff compatibility with gltf, a special mode has been added
  47231. * to reproduce the gltf light falloff.
  47232. */
  47233. /**
  47234. * In order to support the falloff compatibility with gltf, a special mode has been added
  47235. * to reproduce the gltf light falloff.
  47236. */
  47237. useGLTFLightFalloff: boolean;
  47238. /**
  47239. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47240. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47241. */
  47242. useRadianceOverAlpha: boolean;
  47243. /**
  47244. * Allows using an object space normal map (instead of tangent space).
  47245. */
  47246. useObjectSpaceNormalMap: boolean;
  47247. /**
  47248. * Allows using the bump map in parallax mode.
  47249. */
  47250. useParallax: boolean;
  47251. /**
  47252. * Allows using the bump map in parallax occlusion mode.
  47253. */
  47254. useParallaxOcclusion: boolean;
  47255. /**
  47256. * Controls the scale bias of the parallax mode.
  47257. */
  47258. parallaxScaleBias: number;
  47259. /**
  47260. * If sets to true, disables all the lights affecting the material.
  47261. */
  47262. disableLighting: boolean;
  47263. /**
  47264. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47265. */
  47266. forceIrradianceInFragment: boolean;
  47267. /**
  47268. * Number of Simultaneous lights allowed on the material.
  47269. */
  47270. maxSimultaneousLights: number;
  47271. /**
  47272. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47273. */
  47274. invertNormalMapX: boolean;
  47275. /**
  47276. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47277. */
  47278. invertNormalMapY: boolean;
  47279. /**
  47280. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47281. */
  47282. twoSidedLighting: boolean;
  47283. /**
  47284. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47285. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47286. */
  47287. useAlphaFresnel: boolean;
  47288. /**
  47289. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47290. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47291. */
  47292. useLinearAlphaFresnel: boolean;
  47293. /**
  47294. * Let user defines the brdf lookup texture used for IBL.
  47295. * A default 8bit version is embedded but you could point at :
  47296. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47297. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47298. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47299. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47300. */
  47301. environmentBRDFTexture: Nullable<BaseTexture>;
  47302. /**
  47303. * Force normal to face away from face.
  47304. */
  47305. forceNormalForward: boolean;
  47306. /**
  47307. * Enables specular anti aliasing in the PBR shader.
  47308. * It will both interacts on the Geometry for analytical and IBL lighting.
  47309. * It also prefilter the roughness map based on the bump values.
  47310. */
  47311. enableSpecularAntiAliasing: boolean;
  47312. /**
  47313. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47314. * makes the reflect vector face the model (under horizon).
  47315. */
  47316. useHorizonOcclusion: boolean;
  47317. /**
  47318. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47319. * too much the area relying on ambient texture to define their ambient occlusion.
  47320. */
  47321. useRadianceOcclusion: boolean;
  47322. /**
  47323. * If set to true, no lighting calculations will be applied.
  47324. */
  47325. unlit: boolean;
  47326. /**
  47327. * Gets the image processing configuration used either in this material.
  47328. */
  47329. /**
  47330. * Sets the Default image processing configuration used either in the this material.
  47331. *
  47332. * If sets to null, the scene one is in use.
  47333. */
  47334. imageProcessingConfiguration: ImageProcessingConfiguration;
  47335. /**
  47336. * Gets wether the color curves effect is enabled.
  47337. */
  47338. /**
  47339. * Sets wether the color curves effect is enabled.
  47340. */
  47341. cameraColorCurvesEnabled: boolean;
  47342. /**
  47343. * Gets wether the color grading effect is enabled.
  47344. */
  47345. /**
  47346. * Gets wether the color grading effect is enabled.
  47347. */
  47348. cameraColorGradingEnabled: boolean;
  47349. /**
  47350. * Gets wether tonemapping is enabled or not.
  47351. */
  47352. /**
  47353. * Sets wether tonemapping is enabled or not
  47354. */
  47355. cameraToneMappingEnabled: boolean;
  47356. /**
  47357. * The camera exposure used on this material.
  47358. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47359. * This corresponds to a photographic exposure.
  47360. */
  47361. /**
  47362. * The camera exposure used on this material.
  47363. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47364. * This corresponds to a photographic exposure.
  47365. */
  47366. cameraExposure: number;
  47367. /**
  47368. * Gets The camera contrast used on this material.
  47369. */
  47370. /**
  47371. * Sets The camera contrast used on this material.
  47372. */
  47373. cameraContrast: number;
  47374. /**
  47375. * Gets the Color Grading 2D Lookup Texture.
  47376. */
  47377. /**
  47378. * Sets the Color Grading 2D Lookup Texture.
  47379. */
  47380. cameraColorGradingTexture: Nullable<BaseTexture>;
  47381. /**
  47382. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47383. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47384. * 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;
  47385. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47386. */
  47387. /**
  47388. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47389. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47390. * 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;
  47391. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47392. */
  47393. cameraColorCurves: Nullable<ColorCurves>;
  47394. /**
  47395. * Instantiates a new PBRMaterial instance.
  47396. *
  47397. * @param name The material name
  47398. * @param scene The scene the material will be use in.
  47399. */
  47400. constructor(name: string, scene: Scene);
  47401. /**
  47402. * Returns the name of this material class.
  47403. */
  47404. getClassName(): string;
  47405. /**
  47406. * Makes a duplicate of the current material.
  47407. * @param name - name to use for the new material.
  47408. */
  47409. clone(name: string): PBRMaterial;
  47410. /**
  47411. * Serializes this PBR Material.
  47412. * @returns - An object with the serialized material.
  47413. */
  47414. serialize(): any;
  47415. /**
  47416. * Parses a PBR Material from a serialized object.
  47417. * @param source - Serialized object.
  47418. * @param scene - BJS scene instance.
  47419. * @param rootUrl - url for the scene object
  47420. * @returns - PBRMaterial
  47421. */
  47422. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47423. }
  47424. }
  47425. declare module "babylonjs/Misc/dds" {
  47426. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47427. import { Engine } from "babylonjs/Engines/engine";
  47428. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47429. import { Nullable } from "babylonjs/types";
  47430. import { Scene } from "babylonjs/scene";
  47431. /**
  47432. * Direct draw surface info
  47433. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47434. */
  47435. export interface DDSInfo {
  47436. /**
  47437. * Width of the texture
  47438. */
  47439. width: number;
  47440. /**
  47441. * Width of the texture
  47442. */
  47443. height: number;
  47444. /**
  47445. * Number of Mipmaps for the texture
  47446. * @see https://en.wikipedia.org/wiki/Mipmap
  47447. */
  47448. mipmapCount: number;
  47449. /**
  47450. * If the textures format is a known fourCC format
  47451. * @see https://www.fourcc.org/
  47452. */
  47453. isFourCC: boolean;
  47454. /**
  47455. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47456. */
  47457. isRGB: boolean;
  47458. /**
  47459. * If the texture is a lumincance format
  47460. */
  47461. isLuminance: boolean;
  47462. /**
  47463. * If this is a cube texture
  47464. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47465. */
  47466. isCube: boolean;
  47467. /**
  47468. * If the texture is a compressed format eg. FOURCC_DXT1
  47469. */
  47470. isCompressed: boolean;
  47471. /**
  47472. * The dxgiFormat of the texture
  47473. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47474. */
  47475. dxgiFormat: number;
  47476. /**
  47477. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47478. */
  47479. textureType: number;
  47480. /**
  47481. * Sphericle polynomial created for the dds texture
  47482. */
  47483. sphericalPolynomial?: SphericalPolynomial;
  47484. }
  47485. /**
  47486. * Class used to provide DDS decompression tools
  47487. */
  47488. export class DDSTools {
  47489. /**
  47490. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47491. */
  47492. static StoreLODInAlphaChannel: boolean;
  47493. /**
  47494. * Gets DDS information from an array buffer
  47495. * @param arrayBuffer defines the array buffer to read data from
  47496. * @returns the DDS information
  47497. */
  47498. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47499. private static _FloatView;
  47500. private static _Int32View;
  47501. private static _ToHalfFloat;
  47502. private static _FromHalfFloat;
  47503. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47504. private static _GetHalfFloatRGBAArrayBuffer;
  47505. private static _GetFloatRGBAArrayBuffer;
  47506. private static _GetFloatAsUIntRGBAArrayBuffer;
  47507. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47508. private static _GetRGBAArrayBuffer;
  47509. private static _ExtractLongWordOrder;
  47510. private static _GetRGBArrayBuffer;
  47511. private static _GetLuminanceArrayBuffer;
  47512. /**
  47513. * Uploads DDS Levels to a Babylon Texture
  47514. * @hidden
  47515. */
  47516. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47517. }
  47518. module "babylonjs/Engines/engine" {
  47519. interface Engine {
  47520. /**
  47521. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47522. * @param rootUrl defines the url where the file to load is located
  47523. * @param scene defines the current scene
  47524. * @param lodScale defines scale to apply to the mip map selection
  47525. * @param lodOffset defines offset to apply to the mip map selection
  47526. * @param onLoad defines an optional callback raised when the texture is loaded
  47527. * @param onError defines an optional callback raised if there is an issue to load the texture
  47528. * @param format defines the format of the data
  47529. * @param forcedExtension defines the extension to use to pick the right loader
  47530. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47531. * @returns the cube texture as an InternalTexture
  47532. */
  47533. 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;
  47534. }
  47535. }
  47536. }
  47537. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47538. import { Nullable } from "babylonjs/types";
  47539. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47540. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47541. /**
  47542. * Implementation of the DDS Texture Loader.
  47543. * @hidden
  47544. */
  47545. export class _DDSTextureLoader implements IInternalTextureLoader {
  47546. /**
  47547. * Defines wether the loader supports cascade loading the different faces.
  47548. */
  47549. readonly supportCascades: boolean;
  47550. /**
  47551. * This returns if the loader support the current file information.
  47552. * @param extension defines the file extension of the file being loaded
  47553. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47554. * @param fallback defines the fallback internal texture if any
  47555. * @param isBase64 defines whether the texture is encoded as a base64
  47556. * @param isBuffer defines whether the texture data are stored as a buffer
  47557. * @returns true if the loader can load the specified file
  47558. */
  47559. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47560. /**
  47561. * Transform the url before loading if required.
  47562. * @param rootUrl the url of the texture
  47563. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47564. * @returns the transformed texture
  47565. */
  47566. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47567. /**
  47568. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47569. * @param rootUrl the url of the texture
  47570. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47571. * @returns the fallback texture
  47572. */
  47573. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47574. /**
  47575. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47576. * @param data contains the texture data
  47577. * @param texture defines the BabylonJS internal texture
  47578. * @param createPolynomials will be true if polynomials have been requested
  47579. * @param onLoad defines the callback to trigger once the texture is ready
  47580. * @param onError defines the callback to trigger in case of error
  47581. */
  47582. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47583. /**
  47584. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47585. * @param data contains the texture data
  47586. * @param texture defines the BabylonJS internal texture
  47587. * @param callback defines the method to call once ready to upload
  47588. */
  47589. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47590. }
  47591. }
  47592. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47593. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47594. /** @hidden */
  47595. export var rgbdEncodePixelShader: {
  47596. name: string;
  47597. shader: string;
  47598. };
  47599. }
  47600. declare module "babylonjs/Misc/environmentTextureTools" {
  47601. import { Nullable } from "babylonjs/types";
  47602. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47603. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47604. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47605. import "babylonjs/Shaders/rgbdEncode.fragment";
  47606. import "babylonjs/Shaders/rgbdDecode.fragment";
  47607. /**
  47608. * Raw texture data and descriptor sufficient for WebGL texture upload
  47609. */
  47610. export interface EnvironmentTextureInfo {
  47611. /**
  47612. * Version of the environment map
  47613. */
  47614. version: number;
  47615. /**
  47616. * Width of image
  47617. */
  47618. width: number;
  47619. /**
  47620. * Irradiance information stored in the file.
  47621. */
  47622. irradiance: any;
  47623. /**
  47624. * Specular information stored in the file.
  47625. */
  47626. specular: any;
  47627. }
  47628. /**
  47629. * Sets of helpers addressing the serialization and deserialization of environment texture
  47630. * stored in a BabylonJS env file.
  47631. * Those files are usually stored as .env files.
  47632. */
  47633. export class EnvironmentTextureTools {
  47634. /**
  47635. * Magic number identifying the env file.
  47636. */
  47637. private static _MagicBytes;
  47638. /**
  47639. * Gets the environment info from an env file.
  47640. * @param data The array buffer containing the .env bytes.
  47641. * @returns the environment file info (the json header) if successfully parsed.
  47642. */
  47643. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47644. /**
  47645. * Creates an environment texture from a loaded cube texture.
  47646. * @param texture defines the cube texture to convert in env file
  47647. * @return a promise containing the environment data if succesfull.
  47648. */
  47649. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47650. /**
  47651. * Creates a JSON representation of the spherical data.
  47652. * @param texture defines the texture containing the polynomials
  47653. * @return the JSON representation of the spherical info
  47654. */
  47655. private static _CreateEnvTextureIrradiance;
  47656. /**
  47657. * Uploads the texture info contained in the env file to the GPU.
  47658. * @param texture defines the internal texture to upload to
  47659. * @param arrayBuffer defines the buffer cotaining the data to load
  47660. * @param info defines the texture info retrieved through the GetEnvInfo method
  47661. * @returns a promise
  47662. */
  47663. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47664. /**
  47665. * Uploads the levels of image data to the GPU.
  47666. * @param texture defines the internal texture to upload to
  47667. * @param imageData defines the array buffer views of image data [mipmap][face]
  47668. * @returns a promise
  47669. */
  47670. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47671. /**
  47672. * Uploads spherical polynomials information to the texture.
  47673. * @param texture defines the texture we are trying to upload the information to
  47674. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47675. */
  47676. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47677. /** @hidden */
  47678. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47679. }
  47680. }
  47681. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47682. import { Nullable } from "babylonjs/types";
  47683. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47684. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47685. /**
  47686. * Implementation of the ENV Texture Loader.
  47687. * @hidden
  47688. */
  47689. export class _ENVTextureLoader implements IInternalTextureLoader {
  47690. /**
  47691. * Defines wether the loader supports cascade loading the different faces.
  47692. */
  47693. readonly supportCascades: boolean;
  47694. /**
  47695. * This returns if the loader support the current file information.
  47696. * @param extension defines the file extension of the file being loaded
  47697. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47698. * @param fallback defines the fallback internal texture if any
  47699. * @param isBase64 defines whether the texture is encoded as a base64
  47700. * @param isBuffer defines whether the texture data are stored as a buffer
  47701. * @returns true if the loader can load the specified file
  47702. */
  47703. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47704. /**
  47705. * Transform the url before loading if required.
  47706. * @param rootUrl the url of the texture
  47707. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47708. * @returns the transformed texture
  47709. */
  47710. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47711. /**
  47712. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47713. * @param rootUrl the url of the texture
  47714. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47715. * @returns the fallback texture
  47716. */
  47717. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47718. /**
  47719. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47720. * @param data contains the texture data
  47721. * @param texture defines the BabylonJS internal texture
  47722. * @param createPolynomials will be true if polynomials have been requested
  47723. * @param onLoad defines the callback to trigger once the texture is ready
  47724. * @param onError defines the callback to trigger in case of error
  47725. */
  47726. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47727. /**
  47728. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47729. * @param data contains the texture data
  47730. * @param texture defines the BabylonJS internal texture
  47731. * @param callback defines the method to call once ready to upload
  47732. */
  47733. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47734. }
  47735. }
  47736. declare module "babylonjs/Misc/khronosTextureContainer" {
  47737. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47738. /**
  47739. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47740. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47741. */
  47742. export class KhronosTextureContainer {
  47743. /** contents of the KTX container file */
  47744. arrayBuffer: any;
  47745. private static HEADER_LEN;
  47746. private static COMPRESSED_2D;
  47747. private static COMPRESSED_3D;
  47748. private static TEX_2D;
  47749. private static TEX_3D;
  47750. /**
  47751. * Gets the openGL type
  47752. */
  47753. glType: number;
  47754. /**
  47755. * Gets the openGL type size
  47756. */
  47757. glTypeSize: number;
  47758. /**
  47759. * Gets the openGL format
  47760. */
  47761. glFormat: number;
  47762. /**
  47763. * Gets the openGL internal format
  47764. */
  47765. glInternalFormat: number;
  47766. /**
  47767. * Gets the base internal format
  47768. */
  47769. glBaseInternalFormat: number;
  47770. /**
  47771. * Gets image width in pixel
  47772. */
  47773. pixelWidth: number;
  47774. /**
  47775. * Gets image height in pixel
  47776. */
  47777. pixelHeight: number;
  47778. /**
  47779. * Gets image depth in pixels
  47780. */
  47781. pixelDepth: number;
  47782. /**
  47783. * Gets the number of array elements
  47784. */
  47785. numberOfArrayElements: number;
  47786. /**
  47787. * Gets the number of faces
  47788. */
  47789. numberOfFaces: number;
  47790. /**
  47791. * Gets the number of mipmap levels
  47792. */
  47793. numberOfMipmapLevels: number;
  47794. /**
  47795. * Gets the bytes of key value data
  47796. */
  47797. bytesOfKeyValueData: number;
  47798. /**
  47799. * Gets the load type
  47800. */
  47801. loadType: number;
  47802. /**
  47803. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47804. */
  47805. isInvalid: boolean;
  47806. /**
  47807. * Creates a new KhronosTextureContainer
  47808. * @param arrayBuffer contents of the KTX container file
  47809. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47810. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47811. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47812. */
  47813. constructor(
  47814. /** contents of the KTX container file */
  47815. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47816. /**
  47817. * Uploads KTX content to a Babylon Texture.
  47818. * It is assumed that the texture has already been created & is currently bound
  47819. * @hidden
  47820. */
  47821. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47822. private _upload2DCompressedLevels;
  47823. }
  47824. }
  47825. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47826. import { Nullable } from "babylonjs/types";
  47827. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47828. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47829. /**
  47830. * Implementation of the KTX Texture Loader.
  47831. * @hidden
  47832. */
  47833. export class _KTXTextureLoader implements IInternalTextureLoader {
  47834. /**
  47835. * Defines wether the loader supports cascade loading the different faces.
  47836. */
  47837. readonly supportCascades: boolean;
  47838. /**
  47839. * This returns if the loader support the current file information.
  47840. * @param extension defines the file extension of the file being loaded
  47841. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47842. * @param fallback defines the fallback internal texture if any
  47843. * @param isBase64 defines whether the texture is encoded as a base64
  47844. * @param isBuffer defines whether the texture data are stored as a buffer
  47845. * @returns true if the loader can load the specified file
  47846. */
  47847. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47848. /**
  47849. * Transform the url before loading if required.
  47850. * @param rootUrl the url of the texture
  47851. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47852. * @returns the transformed texture
  47853. */
  47854. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47855. /**
  47856. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47857. * @param rootUrl the url of the texture
  47858. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47859. * @returns the fallback texture
  47860. */
  47861. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47862. /**
  47863. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47864. * @param data contains the texture data
  47865. * @param texture defines the BabylonJS internal texture
  47866. * @param createPolynomials will be true if polynomials have been requested
  47867. * @param onLoad defines the callback to trigger once the texture is ready
  47868. * @param onError defines the callback to trigger in case of error
  47869. */
  47870. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47871. /**
  47872. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47873. * @param data contains the texture data
  47874. * @param texture defines the BabylonJS internal texture
  47875. * @param callback defines the method to call once ready to upload
  47876. */
  47877. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47878. }
  47879. }
  47880. declare module "babylonjs/Helpers/sceneHelpers" {
  47881. import { Nullable } from "babylonjs/types";
  47882. import { Mesh } from "babylonjs/Meshes/mesh";
  47883. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47884. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  47885. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47886. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  47887. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  47888. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  47889. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  47890. import "babylonjs/Meshes/Builders/boxBuilder";
  47891. /** @hidden */
  47892. export var _forceSceneHelpersToBundle: boolean;
  47893. module "babylonjs/scene" {
  47894. interface Scene {
  47895. /**
  47896. * Creates a default light for the scene.
  47897. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47898. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47899. */
  47900. createDefaultLight(replace?: boolean): void;
  47901. /**
  47902. * Creates a default camera for the scene.
  47903. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47904. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47905. * @param replace has default false, when true replaces the active camera in the scene
  47906. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47907. */
  47908. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47909. /**
  47910. * Creates a default camera and a default light.
  47911. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47912. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47913. * @param replace has the default false, when true replaces the active camera/light in the scene
  47914. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47915. */
  47916. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47917. /**
  47918. * Creates a new sky box
  47919. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47920. * @param environmentTexture defines the texture to use as environment texture
  47921. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47922. * @param scale defines the overall scale of the skybox
  47923. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47924. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47925. * @returns a new mesh holding the sky box
  47926. */
  47927. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47928. /**
  47929. * Creates a new environment
  47930. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47931. * @param options defines the options you can use to configure the environment
  47932. * @returns the new EnvironmentHelper
  47933. */
  47934. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47935. /**
  47936. * Creates a new VREXperienceHelper
  47937. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47938. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47939. * @returns a new VREXperienceHelper
  47940. */
  47941. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47942. /**
  47943. * Creates a new XREXperienceHelper
  47944. * @see http://doc.babylonjs.com/how_to/webxr
  47945. * @returns a promise for a new XREXperienceHelper
  47946. */
  47947. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47948. }
  47949. }
  47950. }
  47951. declare module "babylonjs/Helpers/videoDome" {
  47952. import { Scene } from "babylonjs/scene";
  47953. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47954. import { Mesh } from "babylonjs/Meshes/mesh";
  47955. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  47956. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47957. import "babylonjs/Meshes/Builders/sphereBuilder";
  47958. /**
  47959. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47960. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47961. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47962. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47963. */
  47964. export class VideoDome extends TransformNode {
  47965. /**
  47966. * Define the video source as a Monoscopic panoramic 360 video.
  47967. */
  47968. static readonly MODE_MONOSCOPIC: number;
  47969. /**
  47970. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47971. */
  47972. static readonly MODE_TOPBOTTOM: number;
  47973. /**
  47974. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47975. */
  47976. static readonly MODE_SIDEBYSIDE: number;
  47977. private _useDirectMapping;
  47978. /**
  47979. * The video texture being displayed on the sphere
  47980. */
  47981. protected _videoTexture: VideoTexture;
  47982. /**
  47983. * Gets the video texture being displayed on the sphere
  47984. */
  47985. readonly videoTexture: VideoTexture;
  47986. /**
  47987. * The skybox material
  47988. */
  47989. protected _material: BackgroundMaterial;
  47990. /**
  47991. * The surface used for the skybox
  47992. */
  47993. protected _mesh: Mesh;
  47994. /**
  47995. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47996. * Also see the options.resolution property.
  47997. */
  47998. fovMultiplier: number;
  47999. private _videoMode;
  48000. /**
  48001. * Gets or set the current video mode for the video. It can be:
  48002. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48003. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48004. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48005. */
  48006. videoMode: number;
  48007. /**
  48008. * Oberserver used in Stereoscopic VR Mode.
  48009. */
  48010. private _onBeforeCameraRenderObserver;
  48011. /**
  48012. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48013. * @param name Element's name, child elements will append suffixes for their own names.
  48014. * @param urlsOrVideo defines the url(s) or the video element to use
  48015. * @param options An object containing optional or exposed sub element properties
  48016. */
  48017. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48018. resolution?: number;
  48019. clickToPlay?: boolean;
  48020. autoPlay?: boolean;
  48021. loop?: boolean;
  48022. size?: number;
  48023. poster?: string;
  48024. faceForward?: boolean;
  48025. useDirectMapping?: boolean;
  48026. }, scene: Scene);
  48027. private _changeVideoMode;
  48028. /**
  48029. * Releases resources associated with this node.
  48030. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48031. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48032. */
  48033. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48034. }
  48035. }
  48036. declare module "babylonjs/Helpers/index" {
  48037. export * from "babylonjs/Helpers/environmentHelper";
  48038. export * from "babylonjs/Helpers/photoDome";
  48039. export * from "babylonjs/Helpers/sceneHelpers";
  48040. export * from "babylonjs/Helpers/videoDome";
  48041. }
  48042. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48043. import { PerfCounter } from "babylonjs/Misc/tools";
  48044. import { IDisposable } from "babylonjs/scene";
  48045. import { Engine } from "babylonjs/Engines/engine";
  48046. /**
  48047. * This class can be used to get instrumentation data from a Babylon engine
  48048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48049. */
  48050. export class EngineInstrumentation implements IDisposable {
  48051. /**
  48052. * Define the instrumented engine.
  48053. */
  48054. engine: Engine;
  48055. private _captureGPUFrameTime;
  48056. private _gpuFrameTimeToken;
  48057. private _gpuFrameTime;
  48058. private _captureShaderCompilationTime;
  48059. private _shaderCompilationTime;
  48060. private _onBeginFrameObserver;
  48061. private _onEndFrameObserver;
  48062. private _onBeforeShaderCompilationObserver;
  48063. private _onAfterShaderCompilationObserver;
  48064. /**
  48065. * Gets the perf counter used for GPU frame time
  48066. */
  48067. readonly gpuFrameTimeCounter: PerfCounter;
  48068. /**
  48069. * Gets the GPU frame time capture status
  48070. */
  48071. /**
  48072. * Enable or disable the GPU frame time capture
  48073. */
  48074. captureGPUFrameTime: boolean;
  48075. /**
  48076. * Gets the perf counter used for shader compilation time
  48077. */
  48078. readonly shaderCompilationTimeCounter: PerfCounter;
  48079. /**
  48080. * Gets the shader compilation time capture status
  48081. */
  48082. /**
  48083. * Enable or disable the shader compilation time capture
  48084. */
  48085. captureShaderCompilationTime: boolean;
  48086. /**
  48087. * Instantiates a new engine instrumentation.
  48088. * This class can be used to get instrumentation data from a Babylon engine
  48089. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48090. * @param engine Defines the engine to instrument
  48091. */
  48092. constructor(
  48093. /**
  48094. * Define the instrumented engine.
  48095. */
  48096. engine: Engine);
  48097. /**
  48098. * Dispose and release associated resources.
  48099. */
  48100. dispose(): void;
  48101. }
  48102. }
  48103. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48104. import { PerfCounter } from "babylonjs/Misc/tools";
  48105. import { Scene, IDisposable } from "babylonjs/scene";
  48106. /**
  48107. * This class can be used to get instrumentation data from a Babylon engine
  48108. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48109. */
  48110. export class SceneInstrumentation implements IDisposable {
  48111. /**
  48112. * Defines the scene to instrument
  48113. */
  48114. scene: Scene;
  48115. private _captureActiveMeshesEvaluationTime;
  48116. private _activeMeshesEvaluationTime;
  48117. private _captureRenderTargetsRenderTime;
  48118. private _renderTargetsRenderTime;
  48119. private _captureFrameTime;
  48120. private _frameTime;
  48121. private _captureRenderTime;
  48122. private _renderTime;
  48123. private _captureInterFrameTime;
  48124. private _interFrameTime;
  48125. private _captureParticlesRenderTime;
  48126. private _particlesRenderTime;
  48127. private _captureSpritesRenderTime;
  48128. private _spritesRenderTime;
  48129. private _capturePhysicsTime;
  48130. private _physicsTime;
  48131. private _captureAnimationsTime;
  48132. private _animationsTime;
  48133. private _captureCameraRenderTime;
  48134. private _cameraRenderTime;
  48135. private _onBeforeActiveMeshesEvaluationObserver;
  48136. private _onAfterActiveMeshesEvaluationObserver;
  48137. private _onBeforeRenderTargetsRenderObserver;
  48138. private _onAfterRenderTargetsRenderObserver;
  48139. private _onAfterRenderObserver;
  48140. private _onBeforeDrawPhaseObserver;
  48141. private _onAfterDrawPhaseObserver;
  48142. private _onBeforeAnimationsObserver;
  48143. private _onBeforeParticlesRenderingObserver;
  48144. private _onAfterParticlesRenderingObserver;
  48145. private _onBeforeSpritesRenderingObserver;
  48146. private _onAfterSpritesRenderingObserver;
  48147. private _onBeforePhysicsObserver;
  48148. private _onAfterPhysicsObserver;
  48149. private _onAfterAnimationsObserver;
  48150. private _onBeforeCameraRenderObserver;
  48151. private _onAfterCameraRenderObserver;
  48152. /**
  48153. * Gets the perf counter used for active meshes evaluation time
  48154. */
  48155. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48156. /**
  48157. * Gets the active meshes evaluation time capture status
  48158. */
  48159. /**
  48160. * Enable or disable the active meshes evaluation time capture
  48161. */
  48162. captureActiveMeshesEvaluationTime: boolean;
  48163. /**
  48164. * Gets the perf counter used for render targets render time
  48165. */
  48166. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48167. /**
  48168. * Gets the render targets render time capture status
  48169. */
  48170. /**
  48171. * Enable or disable the render targets render time capture
  48172. */
  48173. captureRenderTargetsRenderTime: boolean;
  48174. /**
  48175. * Gets the perf counter used for particles render time
  48176. */
  48177. readonly particlesRenderTimeCounter: PerfCounter;
  48178. /**
  48179. * Gets the particles render time capture status
  48180. */
  48181. /**
  48182. * Enable or disable the particles render time capture
  48183. */
  48184. captureParticlesRenderTime: boolean;
  48185. /**
  48186. * Gets the perf counter used for sprites render time
  48187. */
  48188. readonly spritesRenderTimeCounter: PerfCounter;
  48189. /**
  48190. * Gets the sprites render time capture status
  48191. */
  48192. /**
  48193. * Enable or disable the sprites render time capture
  48194. */
  48195. captureSpritesRenderTime: boolean;
  48196. /**
  48197. * Gets the perf counter used for physics time
  48198. */
  48199. readonly physicsTimeCounter: PerfCounter;
  48200. /**
  48201. * Gets the physics time capture status
  48202. */
  48203. /**
  48204. * Enable or disable the physics time capture
  48205. */
  48206. capturePhysicsTime: boolean;
  48207. /**
  48208. * Gets the perf counter used for animations time
  48209. */
  48210. readonly animationsTimeCounter: PerfCounter;
  48211. /**
  48212. * Gets the animations time capture status
  48213. */
  48214. /**
  48215. * Enable or disable the animations time capture
  48216. */
  48217. captureAnimationsTime: boolean;
  48218. /**
  48219. * Gets the perf counter used for frame time capture
  48220. */
  48221. readonly frameTimeCounter: PerfCounter;
  48222. /**
  48223. * Gets the frame time capture status
  48224. */
  48225. /**
  48226. * Enable or disable the frame time capture
  48227. */
  48228. captureFrameTime: boolean;
  48229. /**
  48230. * Gets the perf counter used for inter-frames time capture
  48231. */
  48232. readonly interFrameTimeCounter: PerfCounter;
  48233. /**
  48234. * Gets the inter-frames time capture status
  48235. */
  48236. /**
  48237. * Enable or disable the inter-frames time capture
  48238. */
  48239. captureInterFrameTime: boolean;
  48240. /**
  48241. * Gets the perf counter used for render time capture
  48242. */
  48243. readonly renderTimeCounter: PerfCounter;
  48244. /**
  48245. * Gets the render time capture status
  48246. */
  48247. /**
  48248. * Enable or disable the render time capture
  48249. */
  48250. captureRenderTime: boolean;
  48251. /**
  48252. * Gets the perf counter used for camera render time capture
  48253. */
  48254. readonly cameraRenderTimeCounter: PerfCounter;
  48255. /**
  48256. * Gets the camera render time capture status
  48257. */
  48258. /**
  48259. * Enable or disable the camera render time capture
  48260. */
  48261. captureCameraRenderTime: boolean;
  48262. /**
  48263. * Gets the perf counter used for draw calls
  48264. */
  48265. readonly drawCallsCounter: PerfCounter;
  48266. /**
  48267. * Instantiates a new scene instrumentation.
  48268. * This class can be used to get instrumentation data from a Babylon engine
  48269. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48270. * @param scene Defines the scene to instrument
  48271. */
  48272. constructor(
  48273. /**
  48274. * Defines the scene to instrument
  48275. */
  48276. scene: Scene);
  48277. /**
  48278. * Dispose and release associated resources.
  48279. */
  48280. dispose(): void;
  48281. }
  48282. }
  48283. declare module "babylonjs/Instrumentation/index" {
  48284. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48285. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48286. export * from "babylonjs/Instrumentation/timeToken";
  48287. }
  48288. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48289. /** @hidden */
  48290. export var glowMapGenerationPixelShader: {
  48291. name: string;
  48292. shader: string;
  48293. };
  48294. }
  48295. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48296. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48297. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48298. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48299. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48300. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48301. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48302. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48303. /** @hidden */
  48304. export var glowMapGenerationVertexShader: {
  48305. name: string;
  48306. shader: string;
  48307. };
  48308. }
  48309. declare module "babylonjs/Layers/effectLayer" {
  48310. import { Observable } from "babylonjs/Misc/observable";
  48311. import { Nullable } from "babylonjs/types";
  48312. import { Camera } from "babylonjs/Cameras/camera";
  48313. import { Scene } from "babylonjs/scene";
  48314. import { Color4, ISize } from "babylonjs/Maths/math";
  48315. import { Engine } from "babylonjs/Engines/engine";
  48316. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48318. import { Mesh } from "babylonjs/Meshes/mesh";
  48319. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48321. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48322. import { Effect } from "babylonjs/Materials/effect";
  48323. import { Material } from "babylonjs/Materials/material";
  48324. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48325. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48326. /**
  48327. * Effect layer options. This helps customizing the behaviour
  48328. * of the effect layer.
  48329. */
  48330. export interface IEffectLayerOptions {
  48331. /**
  48332. * Multiplication factor apply to the canvas size to compute the render target size
  48333. * used to generated the objects (the smaller the faster).
  48334. */
  48335. mainTextureRatio: number;
  48336. /**
  48337. * Enforces a fixed size texture to ensure effect stability across devices.
  48338. */
  48339. mainTextureFixedSize?: number;
  48340. /**
  48341. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48342. */
  48343. alphaBlendingMode: number;
  48344. /**
  48345. * The camera attached to the layer.
  48346. */
  48347. camera: Nullable<Camera>;
  48348. /**
  48349. * The rendering group to draw the layer in.
  48350. */
  48351. renderingGroupId: number;
  48352. }
  48353. /**
  48354. * The effect layer Helps adding post process effect blended with the main pass.
  48355. *
  48356. * This can be for instance use to generate glow or higlight effects on the scene.
  48357. *
  48358. * The effect layer class can not be used directly and is intented to inherited from to be
  48359. * customized per effects.
  48360. */
  48361. export abstract class EffectLayer {
  48362. private _vertexBuffers;
  48363. private _indexBuffer;
  48364. private _cachedDefines;
  48365. private _effectLayerMapGenerationEffect;
  48366. private _effectLayerOptions;
  48367. private _mergeEffect;
  48368. protected _scene: Scene;
  48369. protected _engine: Engine;
  48370. protected _maxSize: number;
  48371. protected _mainTextureDesiredSize: ISize;
  48372. protected _mainTexture: RenderTargetTexture;
  48373. protected _shouldRender: boolean;
  48374. protected _postProcesses: PostProcess[];
  48375. protected _textures: BaseTexture[];
  48376. protected _emissiveTextureAndColor: {
  48377. texture: Nullable<BaseTexture>;
  48378. color: Color4;
  48379. };
  48380. /**
  48381. * The name of the layer
  48382. */
  48383. name: string;
  48384. /**
  48385. * The clear color of the texture used to generate the glow map.
  48386. */
  48387. neutralColor: Color4;
  48388. /**
  48389. * Specifies wether the highlight layer is enabled or not.
  48390. */
  48391. isEnabled: boolean;
  48392. /**
  48393. * Gets the camera attached to the layer.
  48394. */
  48395. readonly camera: Nullable<Camera>;
  48396. /**
  48397. * Gets the rendering group id the layer should render in.
  48398. */
  48399. readonly renderingGroupId: number;
  48400. /**
  48401. * An event triggered when the effect layer has been disposed.
  48402. */
  48403. onDisposeObservable: Observable<EffectLayer>;
  48404. /**
  48405. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48406. */
  48407. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48408. /**
  48409. * An event triggered when the generated texture is being merged in the scene.
  48410. */
  48411. onBeforeComposeObservable: Observable<EffectLayer>;
  48412. /**
  48413. * An event triggered when the generated texture has been merged in the scene.
  48414. */
  48415. onAfterComposeObservable: Observable<EffectLayer>;
  48416. /**
  48417. * An event triggered when the efffect layer changes its size.
  48418. */
  48419. onSizeChangedObservable: Observable<EffectLayer>;
  48420. /** @hidden */
  48421. static _SceneComponentInitialization: (scene: Scene) => void;
  48422. /**
  48423. * Instantiates a new effect Layer and references it in the scene.
  48424. * @param name The name of the layer
  48425. * @param scene The scene to use the layer in
  48426. */
  48427. constructor(
  48428. /** The Friendly of the effect in the scene */
  48429. name: string, scene: Scene);
  48430. /**
  48431. * Get the effect name of the layer.
  48432. * @return The effect name
  48433. */
  48434. abstract getEffectName(): string;
  48435. /**
  48436. * Checks for the readiness of the element composing the layer.
  48437. * @param subMesh the mesh to check for
  48438. * @param useInstances specify wether or not to use instances to render the mesh
  48439. * @return true if ready otherwise, false
  48440. */
  48441. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48442. /**
  48443. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48444. * @returns true if the effect requires stencil during the main canvas render pass.
  48445. */
  48446. abstract needStencil(): boolean;
  48447. /**
  48448. * Create the merge effect. This is the shader use to blit the information back
  48449. * to the main canvas at the end of the scene rendering.
  48450. * @returns The effect containing the shader used to merge the effect on the main canvas
  48451. */
  48452. protected abstract _createMergeEffect(): Effect;
  48453. /**
  48454. * Creates the render target textures and post processes used in the effect layer.
  48455. */
  48456. protected abstract _createTextureAndPostProcesses(): void;
  48457. /**
  48458. * Implementation specific of rendering the generating effect on the main canvas.
  48459. * @param effect The effect used to render through
  48460. */
  48461. protected abstract _internalRender(effect: Effect): void;
  48462. /**
  48463. * Sets the required values for both the emissive texture and and the main color.
  48464. */
  48465. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48466. /**
  48467. * Free any resources and references associated to a mesh.
  48468. * Internal use
  48469. * @param mesh The mesh to free.
  48470. */
  48471. abstract _disposeMesh(mesh: Mesh): void;
  48472. /**
  48473. * Serializes this layer (Glow or Highlight for example)
  48474. * @returns a serialized layer object
  48475. */
  48476. abstract serialize?(): any;
  48477. /**
  48478. * Initializes the effect layer with the required options.
  48479. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48480. */
  48481. protected _init(options: Partial<IEffectLayerOptions>): void;
  48482. /**
  48483. * Generates the index buffer of the full screen quad blending to the main canvas.
  48484. */
  48485. private _generateIndexBuffer;
  48486. /**
  48487. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48488. */
  48489. private _genrateVertexBuffer;
  48490. /**
  48491. * Sets the main texture desired size which is the closest power of two
  48492. * of the engine canvas size.
  48493. */
  48494. private _setMainTextureSize;
  48495. /**
  48496. * Creates the main texture for the effect layer.
  48497. */
  48498. protected _createMainTexture(): void;
  48499. /**
  48500. * Adds specific effects defines.
  48501. * @param defines The defines to add specifics to.
  48502. */
  48503. protected _addCustomEffectDefines(defines: string[]): void;
  48504. /**
  48505. * Checks for the readiness of the element composing the layer.
  48506. * @param subMesh the mesh to check for
  48507. * @param useInstances specify wether or not to use instances to render the mesh
  48508. * @param emissiveTexture the associated emissive texture used to generate the glow
  48509. * @return true if ready otherwise, false
  48510. */
  48511. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48512. /**
  48513. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48514. */
  48515. render(): void;
  48516. /**
  48517. * Determine if a given mesh will be used in the current effect.
  48518. * @param mesh mesh to test
  48519. * @returns true if the mesh will be used
  48520. */
  48521. hasMesh(mesh: AbstractMesh): boolean;
  48522. /**
  48523. * Returns true if the layer contains information to display, otherwise false.
  48524. * @returns true if the glow layer should be rendered
  48525. */
  48526. shouldRender(): boolean;
  48527. /**
  48528. * Returns true if the mesh should render, otherwise false.
  48529. * @param mesh The mesh to render
  48530. * @returns true if it should render otherwise false
  48531. */
  48532. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48533. /**
  48534. * Returns true if the mesh can be rendered, otherwise false.
  48535. * @param mesh The mesh to render
  48536. * @param material The material used on the mesh
  48537. * @returns true if it can be rendered otherwise false
  48538. */
  48539. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48540. /**
  48541. * Returns true if the mesh should render, otherwise false.
  48542. * @param mesh The mesh to render
  48543. * @returns true if it should render otherwise false
  48544. */
  48545. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48546. /**
  48547. * Renders the submesh passed in parameter to the generation map.
  48548. */
  48549. protected _renderSubMesh(subMesh: SubMesh): void;
  48550. /**
  48551. * Rebuild the required buffers.
  48552. * @hidden Internal use only.
  48553. */
  48554. _rebuild(): void;
  48555. /**
  48556. * Dispose only the render target textures and post process.
  48557. */
  48558. private _disposeTextureAndPostProcesses;
  48559. /**
  48560. * Dispose the highlight layer and free resources.
  48561. */
  48562. dispose(): void;
  48563. /**
  48564. * Gets the class name of the effect layer
  48565. * @returns the string with the class name of the effect layer
  48566. */
  48567. getClassName(): string;
  48568. /**
  48569. * Creates an effect layer from parsed effect layer data
  48570. * @param parsedEffectLayer defines effect layer data
  48571. * @param scene defines the current scene
  48572. * @param rootUrl defines the root URL containing the effect layer information
  48573. * @returns a parsed effect Layer
  48574. */
  48575. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48576. }
  48577. }
  48578. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48579. import { Scene } from "babylonjs/scene";
  48580. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48581. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48582. import { AbstractScene } from "babylonjs/abstractScene";
  48583. module "babylonjs/abstractScene" {
  48584. interface AbstractScene {
  48585. /**
  48586. * The list of effect layers (highlights/glow) added to the scene
  48587. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48588. * @see http://doc.babylonjs.com/how_to/glow_layer
  48589. */
  48590. effectLayers: Array<EffectLayer>;
  48591. /**
  48592. * Removes the given effect layer from this scene.
  48593. * @param toRemove defines the effect layer to remove
  48594. * @returns the index of the removed effect layer
  48595. */
  48596. removeEffectLayer(toRemove: EffectLayer): number;
  48597. /**
  48598. * Adds the given effect layer to this scene
  48599. * @param newEffectLayer defines the effect layer to add
  48600. */
  48601. addEffectLayer(newEffectLayer: EffectLayer): void;
  48602. }
  48603. }
  48604. /**
  48605. * Defines the layer scene component responsible to manage any effect layers
  48606. * in a given scene.
  48607. */
  48608. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48609. /**
  48610. * The component name helpfull to identify the component in the list of scene components.
  48611. */
  48612. readonly name: string;
  48613. /**
  48614. * The scene the component belongs to.
  48615. */
  48616. scene: Scene;
  48617. private _engine;
  48618. private _renderEffects;
  48619. private _needStencil;
  48620. private _previousStencilState;
  48621. /**
  48622. * Creates a new instance of the component for the given scene
  48623. * @param scene Defines the scene to register the component in
  48624. */
  48625. constructor(scene: Scene);
  48626. /**
  48627. * Registers the component in a given scene
  48628. */
  48629. register(): void;
  48630. /**
  48631. * Rebuilds the elements related to this component in case of
  48632. * context lost for instance.
  48633. */
  48634. rebuild(): void;
  48635. /**
  48636. * Serializes the component data to the specified json object
  48637. * @param serializationObject The object to serialize to
  48638. */
  48639. serialize(serializationObject: any): void;
  48640. /**
  48641. * Adds all the element from the container to the scene
  48642. * @param container the container holding the elements
  48643. */
  48644. addFromContainer(container: AbstractScene): void;
  48645. /**
  48646. * Removes all the elements in the container from the scene
  48647. * @param container contains the elements to remove
  48648. * @param dispose if the removed element should be disposed (default: false)
  48649. */
  48650. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48651. /**
  48652. * Disposes the component and the associated ressources.
  48653. */
  48654. dispose(): void;
  48655. private _isReadyForMesh;
  48656. private _renderMainTexture;
  48657. private _setStencil;
  48658. private _setStencilBack;
  48659. private _draw;
  48660. private _drawCamera;
  48661. private _drawRenderingGroup;
  48662. }
  48663. }
  48664. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48665. /** @hidden */
  48666. export var glowMapMergePixelShader: {
  48667. name: string;
  48668. shader: string;
  48669. };
  48670. }
  48671. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48672. /** @hidden */
  48673. export var glowMapMergeVertexShader: {
  48674. name: string;
  48675. shader: string;
  48676. };
  48677. }
  48678. declare module "babylonjs/Layers/glowLayer" {
  48679. import { Nullable } from "babylonjs/types";
  48680. import { Camera } from "babylonjs/Cameras/camera";
  48681. import { Scene } from "babylonjs/scene";
  48682. import { Color4 } from "babylonjs/Maths/math";
  48683. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48685. import { Mesh } from "babylonjs/Meshes/mesh";
  48686. import { Texture } from "babylonjs/Materials/Textures/texture";
  48687. import { Effect } from "babylonjs/Materials/effect";
  48688. import { Material } from "babylonjs/Materials/material";
  48689. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48690. import "babylonjs/Shaders/glowMapMerge.fragment";
  48691. import "babylonjs/Shaders/glowMapMerge.vertex";
  48692. import "babylonjs/Layers/effectLayerSceneComponent";
  48693. module "babylonjs/abstractScene" {
  48694. interface AbstractScene {
  48695. /**
  48696. * Return a the first highlight layer of the scene with a given name.
  48697. * @param name The name of the highlight layer to look for.
  48698. * @return The highlight layer if found otherwise null.
  48699. */
  48700. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48701. }
  48702. }
  48703. /**
  48704. * Glow layer options. This helps customizing the behaviour
  48705. * of the glow layer.
  48706. */
  48707. export interface IGlowLayerOptions {
  48708. /**
  48709. * Multiplication factor apply to the canvas size to compute the render target size
  48710. * used to generated the glowing objects (the smaller the faster).
  48711. */
  48712. mainTextureRatio: number;
  48713. /**
  48714. * Enforces a fixed size texture to ensure resize independant blur.
  48715. */
  48716. mainTextureFixedSize?: number;
  48717. /**
  48718. * How big is the kernel of the blur texture.
  48719. */
  48720. blurKernelSize: number;
  48721. /**
  48722. * The camera attached to the layer.
  48723. */
  48724. camera: Nullable<Camera>;
  48725. /**
  48726. * Enable MSAA by chosing the number of samples.
  48727. */
  48728. mainTextureSamples?: number;
  48729. /**
  48730. * The rendering group to draw the layer in.
  48731. */
  48732. renderingGroupId: number;
  48733. }
  48734. /**
  48735. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48736. *
  48737. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48738. * glowy meshes to your scene.
  48739. *
  48740. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48741. */
  48742. export class GlowLayer extends EffectLayer {
  48743. /**
  48744. * Effect Name of the layer.
  48745. */
  48746. static readonly EffectName: string;
  48747. /**
  48748. * The default blur kernel size used for the glow.
  48749. */
  48750. static DefaultBlurKernelSize: number;
  48751. /**
  48752. * The default texture size ratio used for the glow.
  48753. */
  48754. static DefaultTextureRatio: number;
  48755. /**
  48756. * Sets the kernel size of the blur.
  48757. */
  48758. /**
  48759. * Gets the kernel size of the blur.
  48760. */
  48761. blurKernelSize: number;
  48762. /**
  48763. * Sets the glow intensity.
  48764. */
  48765. /**
  48766. * Gets the glow intensity.
  48767. */
  48768. intensity: number;
  48769. private _options;
  48770. private _intensity;
  48771. private _horizontalBlurPostprocess1;
  48772. private _verticalBlurPostprocess1;
  48773. private _horizontalBlurPostprocess2;
  48774. private _verticalBlurPostprocess2;
  48775. private _blurTexture1;
  48776. private _blurTexture2;
  48777. private _postProcesses1;
  48778. private _postProcesses2;
  48779. private _includedOnlyMeshes;
  48780. private _excludedMeshes;
  48781. /**
  48782. * Callback used to let the user override the color selection on a per mesh basis
  48783. */
  48784. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48785. /**
  48786. * Callback used to let the user override the texture selection on a per mesh basis
  48787. */
  48788. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48789. /**
  48790. * Instantiates a new glow Layer and references it to the scene.
  48791. * @param name The name of the layer
  48792. * @param scene The scene to use the layer in
  48793. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48794. */
  48795. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48796. /**
  48797. * Get the effect name of the layer.
  48798. * @return The effect name
  48799. */
  48800. getEffectName(): string;
  48801. /**
  48802. * Create the merge effect. This is the shader use to blit the information back
  48803. * to the main canvas at the end of the scene rendering.
  48804. */
  48805. protected _createMergeEffect(): Effect;
  48806. /**
  48807. * Creates the render target textures and post processes used in the glow layer.
  48808. */
  48809. protected _createTextureAndPostProcesses(): void;
  48810. /**
  48811. * Checks for the readiness of the element composing the layer.
  48812. * @param subMesh the mesh to check for
  48813. * @param useInstances specify wether or not to use instances to render the mesh
  48814. * @param emissiveTexture the associated emissive texture used to generate the glow
  48815. * @return true if ready otherwise, false
  48816. */
  48817. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48818. /**
  48819. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48820. */
  48821. needStencil(): boolean;
  48822. /**
  48823. * Returns true if the mesh can be rendered, otherwise false.
  48824. * @param mesh The mesh to render
  48825. * @param material The material used on the mesh
  48826. * @returns true if it can be rendered otherwise false
  48827. */
  48828. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48829. /**
  48830. * Implementation specific of rendering the generating effect on the main canvas.
  48831. * @param effect The effect used to render through
  48832. */
  48833. protected _internalRender(effect: Effect): void;
  48834. /**
  48835. * Sets the required values for both the emissive texture and and the main color.
  48836. */
  48837. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48838. /**
  48839. * Returns true if the mesh should render, otherwise false.
  48840. * @param mesh The mesh to render
  48841. * @returns true if it should render otherwise false
  48842. */
  48843. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48844. /**
  48845. * Adds specific effects defines.
  48846. * @param defines The defines to add specifics to.
  48847. */
  48848. protected _addCustomEffectDefines(defines: string[]): void;
  48849. /**
  48850. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48851. * @param mesh The mesh to exclude from the glow layer
  48852. */
  48853. addExcludedMesh(mesh: Mesh): void;
  48854. /**
  48855. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48856. * @param mesh The mesh to remove
  48857. */
  48858. removeExcludedMesh(mesh: Mesh): void;
  48859. /**
  48860. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48861. * @param mesh The mesh to include in the glow layer
  48862. */
  48863. addIncludedOnlyMesh(mesh: Mesh): void;
  48864. /**
  48865. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48866. * @param mesh The mesh to remove
  48867. */
  48868. removeIncludedOnlyMesh(mesh: Mesh): void;
  48869. /**
  48870. * Determine if a given mesh will be used in the glow layer
  48871. * @param mesh The mesh to test
  48872. * @returns true if the mesh will be highlighted by the current glow layer
  48873. */
  48874. hasMesh(mesh: AbstractMesh): boolean;
  48875. /**
  48876. * Free any resources and references associated to a mesh.
  48877. * Internal use
  48878. * @param mesh The mesh to free.
  48879. * @hidden
  48880. */
  48881. _disposeMesh(mesh: Mesh): void;
  48882. /**
  48883. * Gets the class name of the effect layer
  48884. * @returns the string with the class name of the effect layer
  48885. */
  48886. getClassName(): string;
  48887. /**
  48888. * Serializes this glow layer
  48889. * @returns a serialized glow layer object
  48890. */
  48891. serialize(): any;
  48892. /**
  48893. * Creates a Glow Layer from parsed glow layer data
  48894. * @param parsedGlowLayer defines glow layer data
  48895. * @param scene defines the current scene
  48896. * @param rootUrl defines the root URL containing the glow layer information
  48897. * @returns a parsed Glow Layer
  48898. */
  48899. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48900. }
  48901. }
  48902. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48903. /** @hidden */
  48904. export var glowBlurPostProcessPixelShader: {
  48905. name: string;
  48906. shader: string;
  48907. };
  48908. }
  48909. declare module "babylonjs/Layers/highlightLayer" {
  48910. import { Observable } from "babylonjs/Misc/observable";
  48911. import { Nullable } from "babylonjs/types";
  48912. import { Camera } from "babylonjs/Cameras/camera";
  48913. import { Scene } from "babylonjs/scene";
  48914. import { Color3, Color4 } from "babylonjs/Maths/math";
  48915. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48917. import { Mesh } from "babylonjs/Meshes/mesh";
  48918. import { Effect } from "babylonjs/Materials/effect";
  48919. import { Material } from "babylonjs/Materials/material";
  48920. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48921. import "babylonjs/Shaders/glowMapMerge.fragment";
  48922. import "babylonjs/Shaders/glowMapMerge.vertex";
  48923. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  48924. module "babylonjs/abstractScene" {
  48925. interface AbstractScene {
  48926. /**
  48927. * Return a the first highlight layer of the scene with a given name.
  48928. * @param name The name of the highlight layer to look for.
  48929. * @return The highlight layer if found otherwise null.
  48930. */
  48931. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48932. }
  48933. }
  48934. /**
  48935. * Highlight layer options. This helps customizing the behaviour
  48936. * of the highlight layer.
  48937. */
  48938. export interface IHighlightLayerOptions {
  48939. /**
  48940. * Multiplication factor apply to the canvas size to compute the render target size
  48941. * used to generated the glowing objects (the smaller the faster).
  48942. */
  48943. mainTextureRatio: number;
  48944. /**
  48945. * Enforces a fixed size texture to ensure resize independant blur.
  48946. */
  48947. mainTextureFixedSize?: number;
  48948. /**
  48949. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48950. * of the picture to blur (the smaller the faster).
  48951. */
  48952. blurTextureSizeRatio: number;
  48953. /**
  48954. * How big in texel of the blur texture is the vertical blur.
  48955. */
  48956. blurVerticalSize: number;
  48957. /**
  48958. * How big in texel of the blur texture is the horizontal blur.
  48959. */
  48960. blurHorizontalSize: number;
  48961. /**
  48962. * Alpha blending mode used to apply the blur. Default is combine.
  48963. */
  48964. alphaBlendingMode: number;
  48965. /**
  48966. * The camera attached to the layer.
  48967. */
  48968. camera: Nullable<Camera>;
  48969. /**
  48970. * Should we display highlight as a solid stroke?
  48971. */
  48972. isStroke?: boolean;
  48973. /**
  48974. * The rendering group to draw the layer in.
  48975. */
  48976. renderingGroupId: number;
  48977. }
  48978. /**
  48979. * The highlight layer Helps adding a glow effect around a mesh.
  48980. *
  48981. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48982. * glowy meshes to your scene.
  48983. *
  48984. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48985. */
  48986. export class HighlightLayer extends EffectLayer {
  48987. name: string;
  48988. /**
  48989. * Effect Name of the highlight layer.
  48990. */
  48991. static readonly EffectName: string;
  48992. /**
  48993. * The neutral color used during the preparation of the glow effect.
  48994. * This is black by default as the blend operation is a blend operation.
  48995. */
  48996. static NeutralColor: Color4;
  48997. /**
  48998. * Stencil value used for glowing meshes.
  48999. */
  49000. static GlowingMeshStencilReference: number;
  49001. /**
  49002. * Stencil value used for the other meshes in the scene.
  49003. */
  49004. static NormalMeshStencilReference: number;
  49005. /**
  49006. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49007. */
  49008. innerGlow: boolean;
  49009. /**
  49010. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49011. */
  49012. outerGlow: boolean;
  49013. /**
  49014. * Specifies the horizontal size of the blur.
  49015. */
  49016. /**
  49017. * Gets the horizontal size of the blur.
  49018. */
  49019. blurHorizontalSize: number;
  49020. /**
  49021. * Specifies the vertical size of the blur.
  49022. */
  49023. /**
  49024. * Gets the vertical size of the blur.
  49025. */
  49026. blurVerticalSize: number;
  49027. /**
  49028. * An event triggered when the highlight layer is being blurred.
  49029. */
  49030. onBeforeBlurObservable: Observable<HighlightLayer>;
  49031. /**
  49032. * An event triggered when the highlight layer has been blurred.
  49033. */
  49034. onAfterBlurObservable: Observable<HighlightLayer>;
  49035. private _instanceGlowingMeshStencilReference;
  49036. private _options;
  49037. private _downSamplePostprocess;
  49038. private _horizontalBlurPostprocess;
  49039. private _verticalBlurPostprocess;
  49040. private _blurTexture;
  49041. private _meshes;
  49042. private _excludedMeshes;
  49043. /**
  49044. * Instantiates a new highlight Layer and references it to the scene..
  49045. * @param name The name of the layer
  49046. * @param scene The scene to use the layer in
  49047. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49048. */
  49049. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49050. /**
  49051. * Get the effect name of the layer.
  49052. * @return The effect name
  49053. */
  49054. getEffectName(): string;
  49055. /**
  49056. * Create the merge effect. This is the shader use to blit the information back
  49057. * to the main canvas at the end of the scene rendering.
  49058. */
  49059. protected _createMergeEffect(): Effect;
  49060. /**
  49061. * Creates the render target textures and post processes used in the highlight layer.
  49062. */
  49063. protected _createTextureAndPostProcesses(): void;
  49064. /**
  49065. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49066. */
  49067. needStencil(): boolean;
  49068. /**
  49069. * Checks for the readiness of the element composing the layer.
  49070. * @param subMesh the mesh to check for
  49071. * @param useInstances specify wether or not to use instances to render the mesh
  49072. * @param emissiveTexture the associated emissive texture used to generate the glow
  49073. * @return true if ready otherwise, false
  49074. */
  49075. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49076. /**
  49077. * Implementation specific of rendering the generating effect on the main canvas.
  49078. * @param effect The effect used to render through
  49079. */
  49080. protected _internalRender(effect: Effect): void;
  49081. /**
  49082. * Returns true if the layer contains information to display, otherwise false.
  49083. */
  49084. shouldRender(): boolean;
  49085. /**
  49086. * Returns true if the mesh should render, otherwise false.
  49087. * @param mesh The mesh to render
  49088. * @returns true if it should render otherwise false
  49089. */
  49090. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49091. /**
  49092. * Sets the required values for both the emissive texture and and the main color.
  49093. */
  49094. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49095. /**
  49096. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49097. * @param mesh The mesh to exclude from the highlight layer
  49098. */
  49099. addExcludedMesh(mesh: Mesh): void;
  49100. /**
  49101. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49102. * @param mesh The mesh to highlight
  49103. */
  49104. removeExcludedMesh(mesh: Mesh): void;
  49105. /**
  49106. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49107. * @param mesh mesh to test
  49108. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49109. */
  49110. hasMesh(mesh: AbstractMesh): boolean;
  49111. /**
  49112. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49113. * @param mesh The mesh to highlight
  49114. * @param color The color of the highlight
  49115. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49116. */
  49117. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49118. /**
  49119. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49120. * @param mesh The mesh to highlight
  49121. */
  49122. removeMesh(mesh: Mesh): void;
  49123. /**
  49124. * Force the stencil to the normal expected value for none glowing parts
  49125. */
  49126. private _defaultStencilReference;
  49127. /**
  49128. * Free any resources and references associated to a mesh.
  49129. * Internal use
  49130. * @param mesh The mesh to free.
  49131. * @hidden
  49132. */
  49133. _disposeMesh(mesh: Mesh): void;
  49134. /**
  49135. * Dispose the highlight layer and free resources.
  49136. */
  49137. dispose(): void;
  49138. /**
  49139. * Gets the class name of the effect layer
  49140. * @returns the string with the class name of the effect layer
  49141. */
  49142. getClassName(): string;
  49143. /**
  49144. * Serializes this Highlight layer
  49145. * @returns a serialized Highlight layer object
  49146. */
  49147. serialize(): any;
  49148. /**
  49149. * Creates a Highlight layer from parsed Highlight layer data
  49150. * @param parsedHightlightLayer defines the Highlight layer data
  49151. * @param scene defines the current scene
  49152. * @param rootUrl defines the root URL containing the Highlight layer information
  49153. * @returns a parsed Highlight layer
  49154. */
  49155. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49156. }
  49157. }
  49158. declare module "babylonjs/Layers/index" {
  49159. export * from "babylonjs/Layers/effectLayer";
  49160. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49161. export * from "babylonjs/Layers/glowLayer";
  49162. export * from "babylonjs/Layers/highlightLayer";
  49163. export * from "babylonjs/Layers/layer";
  49164. export * from "babylonjs/Layers/layerSceneComponent";
  49165. }
  49166. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49167. /** @hidden */
  49168. export var lensFlarePixelShader: {
  49169. name: string;
  49170. shader: string;
  49171. };
  49172. }
  49173. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49174. /** @hidden */
  49175. export var lensFlareVertexShader: {
  49176. name: string;
  49177. shader: string;
  49178. };
  49179. }
  49180. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49181. import { Scene } from "babylonjs/scene";
  49182. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49184. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49185. import "babylonjs/Shaders/lensFlare.fragment";
  49186. import "babylonjs/Shaders/lensFlare.vertex";
  49187. /**
  49188. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49189. * It is usually composed of several `lensFlare`.
  49190. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49191. */
  49192. export class LensFlareSystem {
  49193. /**
  49194. * Define the name of the lens flare system
  49195. */
  49196. name: string;
  49197. /**
  49198. * List of lens flares used in this system.
  49199. */
  49200. lensFlares: LensFlare[];
  49201. /**
  49202. * Define a limit from the border the lens flare can be visible.
  49203. */
  49204. borderLimit: number;
  49205. /**
  49206. * Define a viewport border we do not want to see the lens flare in.
  49207. */
  49208. viewportBorder: number;
  49209. /**
  49210. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49211. */
  49212. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49213. /**
  49214. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49215. */
  49216. layerMask: number;
  49217. /**
  49218. * Define the id of the lens flare system in the scene.
  49219. * (equal to name by default)
  49220. */
  49221. id: string;
  49222. private _scene;
  49223. private _emitter;
  49224. private _vertexBuffers;
  49225. private _indexBuffer;
  49226. private _effect;
  49227. private _positionX;
  49228. private _positionY;
  49229. private _isEnabled;
  49230. /** @hidden */
  49231. static _SceneComponentInitialization: (scene: Scene) => void;
  49232. /**
  49233. * Instantiates a lens flare system.
  49234. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49235. * It is usually composed of several `lensFlare`.
  49236. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49237. * @param name Define the name of the lens flare system in the scene
  49238. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49239. * @param scene Define the scene the lens flare system belongs to
  49240. */
  49241. constructor(
  49242. /**
  49243. * Define the name of the lens flare system
  49244. */
  49245. name: string, emitter: any, scene: Scene);
  49246. /**
  49247. * Define if the lens flare system is enabled.
  49248. */
  49249. isEnabled: boolean;
  49250. /**
  49251. * Get the scene the effects belongs to.
  49252. * @returns the scene holding the lens flare system
  49253. */
  49254. getScene(): Scene;
  49255. /**
  49256. * Get the emitter of the lens flare system.
  49257. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49258. * @returns the emitter of the lens flare system
  49259. */
  49260. getEmitter(): any;
  49261. /**
  49262. * Set the emitter of the lens flare system.
  49263. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49264. * @param newEmitter Define the new emitter of the system
  49265. */
  49266. setEmitter(newEmitter: any): void;
  49267. /**
  49268. * Get the lens flare system emitter position.
  49269. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49270. * @returns the position
  49271. */
  49272. getEmitterPosition(): Vector3;
  49273. /**
  49274. * @hidden
  49275. */
  49276. computeEffectivePosition(globalViewport: Viewport): boolean;
  49277. /** @hidden */
  49278. _isVisible(): boolean;
  49279. /**
  49280. * @hidden
  49281. */
  49282. render(): boolean;
  49283. /**
  49284. * Dispose and release the lens flare with its associated resources.
  49285. */
  49286. dispose(): void;
  49287. /**
  49288. * Parse a lens flare system from a JSON repressentation
  49289. * @param parsedLensFlareSystem Define the JSON to parse
  49290. * @param scene Define the scene the parsed system should be instantiated in
  49291. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49292. * @returns the parsed system
  49293. */
  49294. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49295. /**
  49296. * Serialize the current Lens Flare System into a JSON representation.
  49297. * @returns the serialized JSON
  49298. */
  49299. serialize(): any;
  49300. }
  49301. }
  49302. declare module "babylonjs/LensFlares/lensFlare" {
  49303. import { Nullable } from "babylonjs/types";
  49304. import { Color3 } from "babylonjs/Maths/math";
  49305. import { Texture } from "babylonjs/Materials/Textures/texture";
  49306. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49307. /**
  49308. * This represents one of the lens effect in a `lensFlareSystem`.
  49309. * It controls one of the indiviual texture used in the effect.
  49310. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49311. */
  49312. export class LensFlare {
  49313. /**
  49314. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49315. */
  49316. size: number;
  49317. /**
  49318. * 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.
  49319. */
  49320. position: number;
  49321. /**
  49322. * Define the lens color.
  49323. */
  49324. color: Color3;
  49325. /**
  49326. * Define the lens texture.
  49327. */
  49328. texture: Nullable<Texture>;
  49329. /**
  49330. * Define the alpha mode to render this particular lens.
  49331. */
  49332. alphaMode: number;
  49333. private _system;
  49334. /**
  49335. * Creates a new Lens Flare.
  49336. * This represents one of the lens effect in a `lensFlareSystem`.
  49337. * It controls one of the indiviual texture used in the effect.
  49338. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49339. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49340. * @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.
  49341. * @param color Define the lens color
  49342. * @param imgUrl Define the lens texture url
  49343. * @param system Define the `lensFlareSystem` this flare is part of
  49344. * @returns The newly created Lens Flare
  49345. */
  49346. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49347. /**
  49348. * Instantiates a new Lens Flare.
  49349. * This represents one of the lens effect in a `lensFlareSystem`.
  49350. * It controls one of the indiviual texture used in the effect.
  49351. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49352. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49353. * @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.
  49354. * @param color Define the lens color
  49355. * @param imgUrl Define the lens texture url
  49356. * @param system Define the `lensFlareSystem` this flare is part of
  49357. */
  49358. constructor(
  49359. /**
  49360. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49361. */
  49362. size: number,
  49363. /**
  49364. * 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.
  49365. */
  49366. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49367. /**
  49368. * Dispose and release the lens flare with its associated resources.
  49369. */
  49370. dispose(): void;
  49371. }
  49372. }
  49373. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49374. import { Nullable } from "babylonjs/types";
  49375. import { Scene } from "babylonjs/scene";
  49376. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49377. import { AbstractScene } from "babylonjs/abstractScene";
  49378. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49379. module "babylonjs/abstractScene" {
  49380. interface AbstractScene {
  49381. /**
  49382. * The list of lens flare system added to the scene
  49383. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49384. */
  49385. lensFlareSystems: Array<LensFlareSystem>;
  49386. /**
  49387. * Removes the given lens flare system from this scene.
  49388. * @param toRemove The lens flare system to remove
  49389. * @returns The index of the removed lens flare system
  49390. */
  49391. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49392. /**
  49393. * Adds the given lens flare system to this scene
  49394. * @param newLensFlareSystem The lens flare system to add
  49395. */
  49396. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49397. /**
  49398. * Gets a lens flare system using its name
  49399. * @param name defines the name to look for
  49400. * @returns the lens flare system or null if not found
  49401. */
  49402. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49403. /**
  49404. * Gets a lens flare system using its id
  49405. * @param id defines the id to look for
  49406. * @returns the lens flare system or null if not found
  49407. */
  49408. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49409. }
  49410. }
  49411. /**
  49412. * Defines the lens flare scene component responsible to manage any lens flares
  49413. * in a given scene.
  49414. */
  49415. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49416. /**
  49417. * The component name helpfull to identify the component in the list of scene components.
  49418. */
  49419. readonly name: string;
  49420. /**
  49421. * The scene the component belongs to.
  49422. */
  49423. scene: Scene;
  49424. /**
  49425. * Creates a new instance of the component for the given scene
  49426. * @param scene Defines the scene to register the component in
  49427. */
  49428. constructor(scene: Scene);
  49429. /**
  49430. * Registers the component in a given scene
  49431. */
  49432. register(): void;
  49433. /**
  49434. * Rebuilds the elements related to this component in case of
  49435. * context lost for instance.
  49436. */
  49437. rebuild(): void;
  49438. /**
  49439. * Adds all the element from the container to the scene
  49440. * @param container the container holding the elements
  49441. */
  49442. addFromContainer(container: AbstractScene): void;
  49443. /**
  49444. * Removes all the elements in the container from the scene
  49445. * @param container contains the elements to remove
  49446. * @param dispose if the removed element should be disposed (default: false)
  49447. */
  49448. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49449. /**
  49450. * Serializes the component data to the specified json object
  49451. * @param serializationObject The object to serialize to
  49452. */
  49453. serialize(serializationObject: any): void;
  49454. /**
  49455. * Disposes the component and the associated ressources.
  49456. */
  49457. dispose(): void;
  49458. private _draw;
  49459. }
  49460. }
  49461. declare module "babylonjs/LensFlares/index" {
  49462. export * from "babylonjs/LensFlares/lensFlare";
  49463. export * from "babylonjs/LensFlares/lensFlareSystem";
  49464. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49465. }
  49466. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49467. import { Scene } from "babylonjs/scene";
  49468. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49469. import { AbstractScene } from "babylonjs/abstractScene";
  49470. /**
  49471. * Defines the shadow generator component responsible to manage any shadow generators
  49472. * in a given scene.
  49473. */
  49474. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49475. /**
  49476. * The component name helpfull to identify the component in the list of scene components.
  49477. */
  49478. readonly name: string;
  49479. /**
  49480. * The scene the component belongs to.
  49481. */
  49482. scene: Scene;
  49483. /**
  49484. * Creates a new instance of the component for the given scene
  49485. * @param scene Defines the scene to register the component in
  49486. */
  49487. constructor(scene: Scene);
  49488. /**
  49489. * Registers the component in a given scene
  49490. */
  49491. register(): void;
  49492. /**
  49493. * Rebuilds the elements related to this component in case of
  49494. * context lost for instance.
  49495. */
  49496. rebuild(): void;
  49497. /**
  49498. * Serializes the component data to the specified json object
  49499. * @param serializationObject The object to serialize to
  49500. */
  49501. serialize(serializationObject: any): void;
  49502. /**
  49503. * Adds all the element from the container to the scene
  49504. * @param container the container holding the elements
  49505. */
  49506. addFromContainer(container: AbstractScene): void;
  49507. /**
  49508. * Removes all the elements in the container from the scene
  49509. * @param container contains the elements to remove
  49510. * @param dispose if the removed element should be disposed (default: false)
  49511. */
  49512. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49513. /**
  49514. * Rebuilds the elements related to this component in case of
  49515. * context lost for instance.
  49516. */
  49517. dispose(): void;
  49518. private _gatherRenderTargets;
  49519. }
  49520. }
  49521. declare module "babylonjs/Lights/Shadows/index" {
  49522. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49523. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49524. }
  49525. declare module "babylonjs/Lights/pointLight" {
  49526. import { Scene } from "babylonjs/scene";
  49527. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49529. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49530. import { Effect } from "babylonjs/Materials/effect";
  49531. /**
  49532. * A point light is a light defined by an unique point in world space.
  49533. * The light is emitted in every direction from this point.
  49534. * A good example of a point light is a standard light bulb.
  49535. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49536. */
  49537. export class PointLight extends ShadowLight {
  49538. private _shadowAngle;
  49539. /**
  49540. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49541. * This specifies what angle the shadow will use to be created.
  49542. *
  49543. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49544. */
  49545. /**
  49546. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49547. * This specifies what angle the shadow will use to be created.
  49548. *
  49549. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49550. */
  49551. shadowAngle: number;
  49552. /**
  49553. * Gets the direction if it has been set.
  49554. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49555. */
  49556. /**
  49557. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49558. */
  49559. direction: Vector3;
  49560. /**
  49561. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49562. * A PointLight emits the light in every direction.
  49563. * It can cast shadows.
  49564. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49565. * ```javascript
  49566. * var pointLight = new PointLight("pl", camera.position, scene);
  49567. * ```
  49568. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49569. * @param name The light friendly name
  49570. * @param position The position of the point light in the scene
  49571. * @param scene The scene the lights belongs to
  49572. */
  49573. constructor(name: string, position: Vector3, scene: Scene);
  49574. /**
  49575. * Returns the string "PointLight"
  49576. * @returns the class name
  49577. */
  49578. getClassName(): string;
  49579. /**
  49580. * Returns the integer 0.
  49581. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49582. */
  49583. getTypeID(): number;
  49584. /**
  49585. * Specifies wether or not the shadowmap should be a cube texture.
  49586. * @returns true if the shadowmap needs to be a cube texture.
  49587. */
  49588. needCube(): boolean;
  49589. /**
  49590. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49591. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49592. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49593. */
  49594. getShadowDirection(faceIndex?: number): Vector3;
  49595. /**
  49596. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49597. * - fov = PI / 2
  49598. * - aspect ratio : 1.0
  49599. * - z-near and far equal to the active camera minZ and maxZ.
  49600. * Returns the PointLight.
  49601. */
  49602. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49603. protected _buildUniformLayout(): void;
  49604. /**
  49605. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49606. * @param effect The effect to update
  49607. * @param lightIndex The index of the light in the effect to update
  49608. * @returns The point light
  49609. */
  49610. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49611. /**
  49612. * Prepares the list of defines specific to the light type.
  49613. * @param defines the list of defines
  49614. * @param lightIndex defines the index of the light for the effect
  49615. */
  49616. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49617. }
  49618. }
  49619. declare module "babylonjs/Lights/index" {
  49620. export * from "babylonjs/Lights/light";
  49621. export * from "babylonjs/Lights/shadowLight";
  49622. export * from "babylonjs/Lights/Shadows/index";
  49623. export * from "babylonjs/Lights/directionalLight";
  49624. export * from "babylonjs/Lights/hemisphericLight";
  49625. export * from "babylonjs/Lights/pointLight";
  49626. export * from "babylonjs/Lights/spotLight";
  49627. }
  49628. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49629. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49630. /**
  49631. * Header information of HDR texture files.
  49632. */
  49633. export interface HDRInfo {
  49634. /**
  49635. * The height of the texture in pixels.
  49636. */
  49637. height: number;
  49638. /**
  49639. * The width of the texture in pixels.
  49640. */
  49641. width: number;
  49642. /**
  49643. * The index of the beginning of the data in the binary file.
  49644. */
  49645. dataPosition: number;
  49646. }
  49647. /**
  49648. * This groups tools to convert HDR texture to native colors array.
  49649. */
  49650. export class HDRTools {
  49651. private static Ldexp;
  49652. private static Rgbe2float;
  49653. private static readStringLine;
  49654. /**
  49655. * Reads header information from an RGBE texture stored in a native array.
  49656. * More information on this format are available here:
  49657. * https://en.wikipedia.org/wiki/RGBE_image_format
  49658. *
  49659. * @param uint8array The binary file stored in native array.
  49660. * @return The header information.
  49661. */
  49662. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49663. /**
  49664. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49665. * This RGBE texture needs to store the information as a panorama.
  49666. *
  49667. * More information on this format are available here:
  49668. * https://en.wikipedia.org/wiki/RGBE_image_format
  49669. *
  49670. * @param buffer The binary file stored in an array buffer.
  49671. * @param size The expected size of the extracted cubemap.
  49672. * @return The Cube Map information.
  49673. */
  49674. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49675. /**
  49676. * Returns the pixels data extracted from an RGBE texture.
  49677. * This pixels will be stored left to right up to down in the R G B order in one array.
  49678. *
  49679. * More information on this format are available here:
  49680. * https://en.wikipedia.org/wiki/RGBE_image_format
  49681. *
  49682. * @param uint8array The binary file stored in an array buffer.
  49683. * @param hdrInfo The header information of the file.
  49684. * @return The pixels data in RGB right to left up to down order.
  49685. */
  49686. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49687. private static RGBE_ReadPixels_RLE;
  49688. }
  49689. }
  49690. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49691. import { Nullable } from "babylonjs/types";
  49692. import { Scene } from "babylonjs/scene";
  49693. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49694. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49695. /**
  49696. * This represents a texture coming from an HDR input.
  49697. *
  49698. * The only supported format is currently panorama picture stored in RGBE format.
  49699. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49700. */
  49701. export class HDRCubeTexture extends BaseTexture {
  49702. private static _facesMapping;
  49703. private _generateHarmonics;
  49704. private _noMipmap;
  49705. private _textureMatrix;
  49706. private _size;
  49707. private _onLoad;
  49708. private _onError;
  49709. /**
  49710. * The texture URL.
  49711. */
  49712. url: string;
  49713. /**
  49714. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49715. */
  49716. coordinatesMode: number;
  49717. protected _isBlocking: boolean;
  49718. /**
  49719. * Sets wether or not the texture is blocking during loading.
  49720. */
  49721. /**
  49722. * Gets wether or not the texture is blocking during loading.
  49723. */
  49724. isBlocking: boolean;
  49725. protected _rotationY: number;
  49726. /**
  49727. * Sets texture matrix rotation angle around Y axis in radians.
  49728. */
  49729. /**
  49730. * Gets texture matrix rotation angle around Y axis radians.
  49731. */
  49732. rotationY: number;
  49733. /**
  49734. * Gets or sets the center of the bounding box associated with the cube texture
  49735. * It must define where the camera used to render the texture was set
  49736. */
  49737. boundingBoxPosition: Vector3;
  49738. private _boundingBoxSize;
  49739. /**
  49740. * Gets or sets the size of the bounding box associated with the cube texture
  49741. * When defined, the cubemap will switch to local mode
  49742. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49743. * @example https://www.babylonjs-playground.com/#RNASML
  49744. */
  49745. boundingBoxSize: Vector3;
  49746. /**
  49747. * Instantiates an HDRTexture from the following parameters.
  49748. *
  49749. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49750. * @param scene The scene the texture will be used in
  49751. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49752. * @param noMipmap Forces to not generate the mipmap if true
  49753. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49754. * @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)
  49755. * @param reserved Reserved flag for internal use.
  49756. */
  49757. 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>);
  49758. /**
  49759. * Get the current class name of the texture useful for serialization or dynamic coding.
  49760. * @returns "HDRCubeTexture"
  49761. */
  49762. getClassName(): string;
  49763. /**
  49764. * Occurs when the file is raw .hdr file.
  49765. */
  49766. private loadTexture;
  49767. clone(): HDRCubeTexture;
  49768. delayLoad(): void;
  49769. /**
  49770. * Get the texture reflection matrix used to rotate/transform the reflection.
  49771. * @returns the reflection matrix
  49772. */
  49773. getReflectionTextureMatrix(): Matrix;
  49774. /**
  49775. * Set the texture reflection matrix used to rotate/transform the reflection.
  49776. * @param value Define the reflection matrix to set
  49777. */
  49778. setReflectionTextureMatrix(value: Matrix): void;
  49779. /**
  49780. * Parses a JSON representation of an HDR Texture in order to create the texture
  49781. * @param parsedTexture Define the JSON representation
  49782. * @param scene Define the scene the texture should be created in
  49783. * @param rootUrl Define the root url in case we need to load relative dependencies
  49784. * @returns the newly created texture after parsing
  49785. */
  49786. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49787. serialize(): any;
  49788. }
  49789. }
  49790. declare module "babylonjs/Physics/physicsEngine" {
  49791. import { Nullable } from "babylonjs/types";
  49792. import { Vector3 } from "babylonjs/Maths/math";
  49793. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49794. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49795. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49796. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49797. /**
  49798. * Class used to control physics engine
  49799. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49800. */
  49801. export class PhysicsEngine implements IPhysicsEngine {
  49802. private _physicsPlugin;
  49803. /**
  49804. * Global value used to control the smallest number supported by the simulation
  49805. */
  49806. static Epsilon: number;
  49807. private _impostors;
  49808. private _joints;
  49809. /**
  49810. * Gets the gravity vector used by the simulation
  49811. */
  49812. gravity: Vector3;
  49813. /**
  49814. * Factory used to create the default physics plugin.
  49815. * @returns The default physics plugin
  49816. */
  49817. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49818. /**
  49819. * Creates a new Physics Engine
  49820. * @param gravity defines the gravity vector used by the simulation
  49821. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49822. */
  49823. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49824. /**
  49825. * Sets the gravity vector used by the simulation
  49826. * @param gravity defines the gravity vector to use
  49827. */
  49828. setGravity(gravity: Vector3): void;
  49829. /**
  49830. * Set the time step of the physics engine.
  49831. * Default is 1/60.
  49832. * To slow it down, enter 1/600 for example.
  49833. * To speed it up, 1/30
  49834. * @param newTimeStep defines the new timestep to apply to this world.
  49835. */
  49836. setTimeStep(newTimeStep?: number): void;
  49837. /**
  49838. * Get the time step of the physics engine.
  49839. * @returns the current time step
  49840. */
  49841. getTimeStep(): number;
  49842. /**
  49843. * Release all resources
  49844. */
  49845. dispose(): void;
  49846. /**
  49847. * Gets the name of the current physics plugin
  49848. * @returns the name of the plugin
  49849. */
  49850. getPhysicsPluginName(): string;
  49851. /**
  49852. * Adding a new impostor for the impostor tracking.
  49853. * This will be done by the impostor itself.
  49854. * @param impostor the impostor to add
  49855. */
  49856. addImpostor(impostor: PhysicsImpostor): void;
  49857. /**
  49858. * Remove an impostor from the engine.
  49859. * This impostor and its mesh will not longer be updated by the physics engine.
  49860. * @param impostor the impostor to remove
  49861. */
  49862. removeImpostor(impostor: PhysicsImpostor): void;
  49863. /**
  49864. * Add a joint to the physics engine
  49865. * @param mainImpostor defines the main impostor to which the joint is added.
  49866. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49867. * @param joint defines the joint that will connect both impostors.
  49868. */
  49869. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49870. /**
  49871. * Removes a joint from the simulation
  49872. * @param mainImpostor defines the impostor used with the joint
  49873. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49874. * @param joint defines the joint to remove
  49875. */
  49876. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49877. /**
  49878. * Called by the scene. No need to call it.
  49879. * @param delta defines the timespam between frames
  49880. */
  49881. _step(delta: number): void;
  49882. /**
  49883. * Gets the current plugin used to run the simulation
  49884. * @returns current plugin
  49885. */
  49886. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49887. /**
  49888. * Gets the list of physic impostors
  49889. * @returns an array of PhysicsImpostor
  49890. */
  49891. getImpostors(): Array<PhysicsImpostor>;
  49892. /**
  49893. * Gets the impostor for a physics enabled object
  49894. * @param object defines the object impersonated by the impostor
  49895. * @returns the PhysicsImpostor or null if not found
  49896. */
  49897. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49898. /**
  49899. * Gets the impostor for a physics body object
  49900. * @param body defines physics body used by the impostor
  49901. * @returns the PhysicsImpostor or null if not found
  49902. */
  49903. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49904. /**
  49905. * Does a raycast in the physics world
  49906. * @param from when should the ray start?
  49907. * @param to when should the ray end?
  49908. * @returns PhysicsRaycastResult
  49909. */
  49910. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49911. }
  49912. }
  49913. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49914. import { Nullable } from "babylonjs/types";
  49915. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49917. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49918. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49919. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49920. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49921. /** @hidden */
  49922. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49923. private _useDeltaForWorldStep;
  49924. world: any;
  49925. name: string;
  49926. private _physicsMaterials;
  49927. private _fixedTimeStep;
  49928. private _cannonRaycastResult;
  49929. private _raycastResult;
  49930. private _removeAfterStep;
  49931. BJSCANNON: any;
  49932. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49933. setGravity(gravity: Vector3): void;
  49934. setTimeStep(timeStep: number): void;
  49935. getTimeStep(): number;
  49936. executeStep(delta: number): void;
  49937. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49938. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49939. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49940. private _processChildMeshes;
  49941. removePhysicsBody(impostor: PhysicsImpostor): void;
  49942. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49943. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49944. private _addMaterial;
  49945. private _checkWithEpsilon;
  49946. private _createShape;
  49947. private _createHeightmap;
  49948. private _minus90X;
  49949. private _plus90X;
  49950. private _tmpPosition;
  49951. private _tmpDeltaPosition;
  49952. private _tmpUnityRotation;
  49953. private _updatePhysicsBodyTransformation;
  49954. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49955. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49956. isSupported(): boolean;
  49957. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49958. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49959. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49960. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49961. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49962. getBodyMass(impostor: PhysicsImpostor): number;
  49963. getBodyFriction(impostor: PhysicsImpostor): number;
  49964. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49965. getBodyRestitution(impostor: PhysicsImpostor): number;
  49966. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49967. sleepBody(impostor: PhysicsImpostor): void;
  49968. wakeUpBody(impostor: PhysicsImpostor): void;
  49969. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49970. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49971. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49972. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49973. getRadius(impostor: PhysicsImpostor): number;
  49974. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49975. dispose(): void;
  49976. private _extendNamespace;
  49977. /**
  49978. * Does a raycast in the physics world
  49979. * @param from when should the ray start?
  49980. * @param to when should the ray end?
  49981. * @returns PhysicsRaycastResult
  49982. */
  49983. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49984. }
  49985. }
  49986. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49987. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49988. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49989. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49991. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49992. import { Nullable } from "babylonjs/types";
  49993. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49994. /** @hidden */
  49995. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49996. world: any;
  49997. name: string;
  49998. BJSOIMO: any;
  49999. private _raycastResult;
  50000. constructor(iterations?: number, oimoInjection?: any);
  50001. setGravity(gravity: Vector3): void;
  50002. setTimeStep(timeStep: number): void;
  50003. getTimeStep(): number;
  50004. private _tmpImpostorsArray;
  50005. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50006. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50007. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50008. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50009. private _tmpPositionVector;
  50010. removePhysicsBody(impostor: PhysicsImpostor): void;
  50011. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50012. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50013. isSupported(): boolean;
  50014. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50015. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50016. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50017. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50018. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50019. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50020. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50021. getBodyMass(impostor: PhysicsImpostor): number;
  50022. getBodyFriction(impostor: PhysicsImpostor): number;
  50023. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50024. getBodyRestitution(impostor: PhysicsImpostor): number;
  50025. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50026. sleepBody(impostor: PhysicsImpostor): void;
  50027. wakeUpBody(impostor: PhysicsImpostor): void;
  50028. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50029. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50030. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50031. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50032. getRadius(impostor: PhysicsImpostor): number;
  50033. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50034. dispose(): void;
  50035. /**
  50036. * Does a raycast in the physics world
  50037. * @param from when should the ray start?
  50038. * @param to when should the ray end?
  50039. * @returns PhysicsRaycastResult
  50040. */
  50041. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50042. }
  50043. }
  50044. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50045. import { Nullable } from "babylonjs/types";
  50046. import { Scene } from "babylonjs/scene";
  50047. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50048. import { Mesh } from "babylonjs/Meshes/mesh";
  50049. /**
  50050. * Class containing static functions to help procedurally build meshes
  50051. */
  50052. export class RibbonBuilder {
  50053. /**
  50054. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50055. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50056. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50057. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50058. * * 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
  50059. * * 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
  50060. * * 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
  50061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50064. * * 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
  50065. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50066. * * 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
  50067. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50069. * @param name defines the name of the mesh
  50070. * @param options defines the options used to create the mesh
  50071. * @param scene defines the hosting scene
  50072. * @returns the ribbon mesh
  50073. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50074. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50075. */
  50076. static CreateRibbon(name: string, options: {
  50077. pathArray: Vector3[][];
  50078. closeArray?: boolean;
  50079. closePath?: boolean;
  50080. offset?: number;
  50081. updatable?: boolean;
  50082. sideOrientation?: number;
  50083. frontUVs?: Vector4;
  50084. backUVs?: Vector4;
  50085. instance?: Mesh;
  50086. invertUV?: boolean;
  50087. uvs?: Vector2[];
  50088. colors?: Color4[];
  50089. }, scene?: Nullable<Scene>): Mesh;
  50090. }
  50091. }
  50092. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50093. import { Nullable } from "babylonjs/types";
  50094. import { Scene } from "babylonjs/scene";
  50095. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50096. import { Mesh } from "babylonjs/Meshes/mesh";
  50097. /**
  50098. * Class containing static functions to help procedurally build meshes
  50099. */
  50100. export class ShapeBuilder {
  50101. /**
  50102. * 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.
  50103. * * 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.
  50104. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50105. * * 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.
  50106. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50107. * * 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
  50108. * * 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
  50109. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50112. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50114. * @param name defines the name of the mesh
  50115. * @param options defines the options used to create the mesh
  50116. * @param scene defines the hosting scene
  50117. * @returns the extruded shape mesh
  50118. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50120. */
  50121. static ExtrudeShape(name: string, options: {
  50122. shape: Vector3[];
  50123. path: Vector3[];
  50124. scale?: number;
  50125. rotation?: number;
  50126. cap?: number;
  50127. updatable?: boolean;
  50128. sideOrientation?: number;
  50129. frontUVs?: Vector4;
  50130. backUVs?: Vector4;
  50131. instance?: Mesh;
  50132. invertUV?: boolean;
  50133. }, scene?: Nullable<Scene>): Mesh;
  50134. /**
  50135. * Creates an custom extruded shape mesh.
  50136. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50137. * * 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.
  50138. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50139. * * 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
  50140. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50141. * * 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
  50142. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50143. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50144. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50145. * * 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
  50146. * * 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
  50147. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50152. * @param name defines the name of the mesh
  50153. * @param options defines the options used to create the mesh
  50154. * @param scene defines the hosting scene
  50155. * @returns the custom extruded shape mesh
  50156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50157. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50159. */
  50160. static ExtrudeShapeCustom(name: string, options: {
  50161. shape: Vector3[];
  50162. path: Vector3[];
  50163. scaleFunction?: any;
  50164. rotationFunction?: any;
  50165. ribbonCloseArray?: boolean;
  50166. ribbonClosePath?: boolean;
  50167. cap?: number;
  50168. updatable?: boolean;
  50169. sideOrientation?: number;
  50170. frontUVs?: Vector4;
  50171. backUVs?: Vector4;
  50172. instance?: Mesh;
  50173. invertUV?: boolean;
  50174. }, scene?: Nullable<Scene>): Mesh;
  50175. private static _ExtrudeShapeGeneric;
  50176. }
  50177. }
  50178. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50179. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50180. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50181. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50182. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50183. import { Nullable } from "babylonjs/types";
  50184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50185. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50186. /**
  50187. * AmmoJS Physics plugin
  50188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50189. * @see https://github.com/kripken/ammo.js/
  50190. */
  50191. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50192. private _useDeltaForWorldStep;
  50193. /**
  50194. * Reference to the Ammo library
  50195. */
  50196. bjsAMMO: any;
  50197. /**
  50198. * Created ammoJS world which physics bodies are added to
  50199. */
  50200. world: any;
  50201. /**
  50202. * Name of the plugin
  50203. */
  50204. name: string;
  50205. private _timeStep;
  50206. private _fixedTimeStep;
  50207. private _maxSteps;
  50208. private _tmpQuaternion;
  50209. private _tmpAmmoTransform;
  50210. private _tmpAmmoQuaternion;
  50211. private _tmpAmmoConcreteContactResultCallback;
  50212. private _collisionConfiguration;
  50213. private _dispatcher;
  50214. private _overlappingPairCache;
  50215. private _solver;
  50216. private _softBodySolver;
  50217. private _tmpAmmoVectorA;
  50218. private _tmpAmmoVectorB;
  50219. private _tmpAmmoVectorC;
  50220. private _tmpAmmoVectorD;
  50221. private _tmpContactCallbackResult;
  50222. private _tmpAmmoVectorRCA;
  50223. private _tmpAmmoVectorRCB;
  50224. private _raycastResult;
  50225. private static readonly DISABLE_COLLISION_FLAG;
  50226. private static readonly KINEMATIC_FLAG;
  50227. private static readonly DISABLE_DEACTIVATION_FLAG;
  50228. /**
  50229. * Initializes the ammoJS plugin
  50230. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50231. * @param ammoInjection can be used to inject your own ammo reference
  50232. */
  50233. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50234. /**
  50235. * Sets the gravity of the physics world (m/(s^2))
  50236. * @param gravity Gravity to set
  50237. */
  50238. setGravity(gravity: Vector3): void;
  50239. /**
  50240. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50241. * @param timeStep timestep to use in seconds
  50242. */
  50243. setTimeStep(timeStep: number): void;
  50244. /**
  50245. * 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)
  50246. * @param fixedTimeStep fixedTimeStep to use in seconds
  50247. */
  50248. setFixedTimeStep(fixedTimeStep: number): void;
  50249. /**
  50250. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50251. * @param maxSteps the maximum number of steps by the physics engine per frame
  50252. */
  50253. setMaxSteps(maxSteps: number): void;
  50254. /**
  50255. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50256. * @returns the current timestep in seconds
  50257. */
  50258. getTimeStep(): number;
  50259. private _isImpostorInContact;
  50260. private _isImpostorPairInContact;
  50261. private _stepSimulation;
  50262. /**
  50263. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50264. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50265. * After the step the babylon meshes are set to the position of the physics imposters
  50266. * @param delta amount of time to step forward
  50267. * @param impostors array of imposters to update before/after the step
  50268. */
  50269. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50270. /**
  50271. * Update babylon mesh to match physics world object
  50272. * @param impostor imposter to match
  50273. */
  50274. private _afterSoftStep;
  50275. /**
  50276. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50277. * @param impostor imposter to match
  50278. */
  50279. private _ropeStep;
  50280. /**
  50281. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50282. * @param impostor imposter to match
  50283. */
  50284. private _softbodyOrClothStep;
  50285. private _tmpVector;
  50286. private _tmpMatrix;
  50287. /**
  50288. * Applies an impulse on the imposter
  50289. * @param impostor imposter to apply impulse to
  50290. * @param force amount of force to be applied to the imposter
  50291. * @param contactPoint the location to apply the impulse on the imposter
  50292. */
  50293. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50294. /**
  50295. * Applies a force on the imposter
  50296. * @param impostor imposter to apply force
  50297. * @param force amount of force to be applied to the imposter
  50298. * @param contactPoint the location to apply the force on the imposter
  50299. */
  50300. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50301. /**
  50302. * Creates a physics body using the plugin
  50303. * @param impostor the imposter to create the physics body on
  50304. */
  50305. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50306. /**
  50307. * Removes the physics body from the imposter and disposes of the body's memory
  50308. * @param impostor imposter to remove the physics body from
  50309. */
  50310. removePhysicsBody(impostor: PhysicsImpostor): void;
  50311. /**
  50312. * Generates a joint
  50313. * @param impostorJoint the imposter joint to create the joint with
  50314. */
  50315. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50316. /**
  50317. * Removes a joint
  50318. * @param impostorJoint the imposter joint to remove the joint from
  50319. */
  50320. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50321. private _addMeshVerts;
  50322. /**
  50323. * Initialise the soft body vertices to match its object's (mesh) vertices
  50324. * Softbody vertices (nodes) are in world space and to match this
  50325. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50326. * @param impostor to create the softbody for
  50327. */
  50328. private _softVertexData;
  50329. /**
  50330. * Create an impostor's soft body
  50331. * @param impostor to create the softbody for
  50332. */
  50333. private _createSoftbody;
  50334. /**
  50335. * Create cloth for an impostor
  50336. * @param impostor to create the softbody for
  50337. */
  50338. private _createCloth;
  50339. /**
  50340. * Create rope for an impostor
  50341. * @param impostor to create the softbody for
  50342. */
  50343. private _createRope;
  50344. private _addHullVerts;
  50345. private _createShape;
  50346. /**
  50347. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50348. * @param impostor imposter containing the physics body and babylon object
  50349. */
  50350. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50351. /**
  50352. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50353. * @param impostor imposter containing the physics body and babylon object
  50354. * @param newPosition new position
  50355. * @param newRotation new rotation
  50356. */
  50357. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50358. /**
  50359. * If this plugin is supported
  50360. * @returns true if its supported
  50361. */
  50362. isSupported(): boolean;
  50363. /**
  50364. * Sets the linear velocity of the physics body
  50365. * @param impostor imposter to set the velocity on
  50366. * @param velocity velocity to set
  50367. */
  50368. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50369. /**
  50370. * Sets the angular velocity of the physics body
  50371. * @param impostor imposter to set the velocity on
  50372. * @param velocity velocity to set
  50373. */
  50374. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50375. /**
  50376. * gets the linear velocity
  50377. * @param impostor imposter to get linear velocity from
  50378. * @returns linear velocity
  50379. */
  50380. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50381. /**
  50382. * gets the angular velocity
  50383. * @param impostor imposter to get angular velocity from
  50384. * @returns angular velocity
  50385. */
  50386. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50387. /**
  50388. * Sets the mass of physics body
  50389. * @param impostor imposter to set the mass on
  50390. * @param mass mass to set
  50391. */
  50392. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50393. /**
  50394. * Gets the mass of the physics body
  50395. * @param impostor imposter to get the mass from
  50396. * @returns mass
  50397. */
  50398. getBodyMass(impostor: PhysicsImpostor): number;
  50399. /**
  50400. * Gets friction of the impostor
  50401. * @param impostor impostor to get friction from
  50402. * @returns friction value
  50403. */
  50404. getBodyFriction(impostor: PhysicsImpostor): number;
  50405. /**
  50406. * Sets friction of the impostor
  50407. * @param impostor impostor to set friction on
  50408. * @param friction friction value
  50409. */
  50410. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50411. /**
  50412. * Gets restitution of the impostor
  50413. * @param impostor impostor to get restitution from
  50414. * @returns restitution value
  50415. */
  50416. getBodyRestitution(impostor: PhysicsImpostor): number;
  50417. /**
  50418. * Sets resitution of the impostor
  50419. * @param impostor impostor to set resitution on
  50420. * @param restitution resitution value
  50421. */
  50422. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50423. /**
  50424. * Gets pressure inside the impostor
  50425. * @param impostor impostor to get pressure from
  50426. * @returns pressure value
  50427. */
  50428. getBodyPressure(impostor: PhysicsImpostor): number;
  50429. /**
  50430. * Sets pressure inside a soft body impostor
  50431. * Cloth and rope must remain 0 pressure
  50432. * @param impostor impostor to set pressure on
  50433. * @param pressure pressure value
  50434. */
  50435. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50436. /**
  50437. * Gets stiffness of the impostor
  50438. * @param impostor impostor to get stiffness from
  50439. * @returns pressure value
  50440. */
  50441. getBodyStiffness(impostor: PhysicsImpostor): number;
  50442. /**
  50443. * Sets stiffness of the impostor
  50444. * @param impostor impostor to set stiffness on
  50445. * @param stiffness stiffness value from 0 to 1
  50446. */
  50447. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50448. /**
  50449. * Gets velocityIterations of the impostor
  50450. * @param impostor impostor to get velocity iterations from
  50451. * @returns velocityIterations value
  50452. */
  50453. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50454. /**
  50455. * Sets velocityIterations of the impostor
  50456. * @param impostor impostor to set velocity iterations on
  50457. * @param velocityIterations velocityIterations value
  50458. */
  50459. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50460. /**
  50461. * Gets positionIterations of the impostor
  50462. * @param impostor impostor to get position iterations from
  50463. * @returns positionIterations value
  50464. */
  50465. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50466. /**
  50467. * Sets positionIterations of the impostor
  50468. * @param impostor impostor to set position on
  50469. * @param positionIterations positionIterations value
  50470. */
  50471. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50472. /**
  50473. * Append an anchor to a cloth object
  50474. * @param impostor is the cloth impostor to add anchor to
  50475. * @param otherImpostor is the rigid impostor to anchor to
  50476. * @param width ratio across width from 0 to 1
  50477. * @param height ratio up height from 0 to 1
  50478. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50479. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50480. */
  50481. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50482. /**
  50483. * Append an hook to a rope object
  50484. * @param impostor is the rope impostor to add hook to
  50485. * @param otherImpostor is the rigid impostor to hook to
  50486. * @param length ratio along the rope from 0 to 1
  50487. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50488. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50489. */
  50490. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50491. /**
  50492. * Sleeps the physics body and stops it from being active
  50493. * @param impostor impostor to sleep
  50494. */
  50495. sleepBody(impostor: PhysicsImpostor): void;
  50496. /**
  50497. * Activates the physics body
  50498. * @param impostor impostor to activate
  50499. */
  50500. wakeUpBody(impostor: PhysicsImpostor): void;
  50501. /**
  50502. * Updates the distance parameters of the joint
  50503. * @param joint joint to update
  50504. * @param maxDistance maximum distance of the joint
  50505. * @param minDistance minimum distance of the joint
  50506. */
  50507. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50508. /**
  50509. * Sets a motor on the joint
  50510. * @param joint joint to set motor on
  50511. * @param speed speed of the motor
  50512. * @param maxForce maximum force of the motor
  50513. * @param motorIndex index of the motor
  50514. */
  50515. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50516. /**
  50517. * Sets the motors limit
  50518. * @param joint joint to set limit on
  50519. * @param upperLimit upper limit
  50520. * @param lowerLimit lower limit
  50521. */
  50522. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50523. /**
  50524. * Syncs the position and rotation of a mesh with the impostor
  50525. * @param mesh mesh to sync
  50526. * @param impostor impostor to update the mesh with
  50527. */
  50528. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50529. /**
  50530. * Gets the radius of the impostor
  50531. * @param impostor impostor to get radius from
  50532. * @returns the radius
  50533. */
  50534. getRadius(impostor: PhysicsImpostor): number;
  50535. /**
  50536. * Gets the box size of the impostor
  50537. * @param impostor impostor to get box size from
  50538. * @param result the resulting box size
  50539. */
  50540. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50541. /**
  50542. * Disposes of the impostor
  50543. */
  50544. dispose(): void;
  50545. /**
  50546. * Does a raycast in the physics world
  50547. * @param from when should the ray start?
  50548. * @param to when should the ray end?
  50549. * @returns PhysicsRaycastResult
  50550. */
  50551. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50552. }
  50553. }
  50554. declare module "babylonjs/Probes/reflectionProbe" {
  50555. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50556. import { Vector3 } from "babylonjs/Maths/math";
  50557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50558. import { Nullable } from "babylonjs/types";
  50559. import { Scene } from "babylonjs/scene";
  50560. module "babylonjs/abstractScene" {
  50561. interface AbstractScene {
  50562. /**
  50563. * The list of reflection probes added to the scene
  50564. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50565. */
  50566. reflectionProbes: Array<ReflectionProbe>;
  50567. /**
  50568. * Removes the given reflection probe from this scene.
  50569. * @param toRemove The reflection probe to remove
  50570. * @returns The index of the removed reflection probe
  50571. */
  50572. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50573. /**
  50574. * Adds the given reflection probe to this scene.
  50575. * @param newReflectionProbe The reflection probe to add
  50576. */
  50577. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50578. }
  50579. }
  50580. /**
  50581. * Class used to generate realtime reflection / refraction cube textures
  50582. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50583. */
  50584. export class ReflectionProbe {
  50585. /** defines the name of the probe */
  50586. name: string;
  50587. private _scene;
  50588. private _renderTargetTexture;
  50589. private _projectionMatrix;
  50590. private _viewMatrix;
  50591. private _target;
  50592. private _add;
  50593. private _attachedMesh;
  50594. private _invertYAxis;
  50595. /** Gets or sets probe position (center of the cube map) */
  50596. position: Vector3;
  50597. /**
  50598. * Creates a new reflection probe
  50599. * @param name defines the name of the probe
  50600. * @param size defines the texture resolution (for each face)
  50601. * @param scene defines the hosting scene
  50602. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50603. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50604. */
  50605. constructor(
  50606. /** defines the name of the probe */
  50607. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50608. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50609. samples: number;
  50610. /** Gets or sets the refresh rate to use (on every frame by default) */
  50611. refreshRate: number;
  50612. /**
  50613. * Gets the hosting scene
  50614. * @returns a Scene
  50615. */
  50616. getScene(): Scene;
  50617. /** Gets the internal CubeTexture used to render to */
  50618. readonly cubeTexture: RenderTargetTexture;
  50619. /** Gets the list of meshes to render */
  50620. readonly renderList: Nullable<AbstractMesh[]>;
  50621. /**
  50622. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50623. * @param mesh defines the mesh to attach to
  50624. */
  50625. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50626. /**
  50627. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50628. * @param renderingGroupId The rendering group id corresponding to its index
  50629. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50630. */
  50631. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50632. /**
  50633. * Clean all associated resources
  50634. */
  50635. dispose(): void;
  50636. /**
  50637. * Converts the reflection probe information to a readable string for debug purpose.
  50638. * @param fullDetails Supports for multiple levels of logging within scene loading
  50639. * @returns the human readable reflection probe info
  50640. */
  50641. toString(fullDetails?: boolean): string;
  50642. /**
  50643. * Get the class name of the relfection probe.
  50644. * @returns "ReflectionProbe"
  50645. */
  50646. getClassName(): string;
  50647. /**
  50648. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50649. * @returns The JSON representation of the texture
  50650. */
  50651. serialize(): any;
  50652. /**
  50653. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50654. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50655. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50656. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50657. * @returns The parsed reflection probe if successful
  50658. */
  50659. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50660. }
  50661. }
  50662. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50663. /** @hidden */
  50664. export var _BabylonLoaderRegistered: boolean;
  50665. }
  50666. declare module "babylonjs/Loading/Plugins/index" {
  50667. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50668. }
  50669. declare module "babylonjs/Loading/index" {
  50670. export * from "babylonjs/Loading/loadingScreen";
  50671. export * from "babylonjs/Loading/Plugins/index";
  50672. export * from "babylonjs/Loading/sceneLoader";
  50673. export * from "babylonjs/Loading/sceneLoaderFlags";
  50674. }
  50675. declare module "babylonjs/Materials/Background/index" {
  50676. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50677. }
  50678. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50679. import { Scene } from "babylonjs/scene";
  50680. import { Color3 } from "babylonjs/Maths/math";
  50681. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50682. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50683. /**
  50684. * The Physically based simple base material of BJS.
  50685. *
  50686. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50687. * It is used as the base class for both the specGloss and metalRough conventions.
  50688. */
  50689. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50690. /**
  50691. * Number of Simultaneous lights allowed on the material.
  50692. */
  50693. maxSimultaneousLights: number;
  50694. /**
  50695. * If sets to true, disables all the lights affecting the material.
  50696. */
  50697. disableLighting: boolean;
  50698. /**
  50699. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50700. */
  50701. environmentTexture: BaseTexture;
  50702. /**
  50703. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50704. */
  50705. invertNormalMapX: boolean;
  50706. /**
  50707. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50708. */
  50709. invertNormalMapY: boolean;
  50710. /**
  50711. * Normal map used in the model.
  50712. */
  50713. normalTexture: BaseTexture;
  50714. /**
  50715. * Emissivie color used to self-illuminate the model.
  50716. */
  50717. emissiveColor: Color3;
  50718. /**
  50719. * Emissivie texture used to self-illuminate the model.
  50720. */
  50721. emissiveTexture: BaseTexture;
  50722. /**
  50723. * Occlusion Channel Strenght.
  50724. */
  50725. occlusionStrength: number;
  50726. /**
  50727. * Occlusion Texture of the material (adding extra occlusion effects).
  50728. */
  50729. occlusionTexture: BaseTexture;
  50730. /**
  50731. * Defines the alpha limits in alpha test mode.
  50732. */
  50733. alphaCutOff: number;
  50734. /**
  50735. * Gets the current double sided mode.
  50736. */
  50737. /**
  50738. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50739. */
  50740. doubleSided: boolean;
  50741. /**
  50742. * Stores the pre-calculated light information of a mesh in a texture.
  50743. */
  50744. lightmapTexture: BaseTexture;
  50745. /**
  50746. * If true, the light map contains occlusion information instead of lighting info.
  50747. */
  50748. useLightmapAsShadowmap: boolean;
  50749. /**
  50750. * Instantiates a new PBRMaterial instance.
  50751. *
  50752. * @param name The material name
  50753. * @param scene The scene the material will be use in.
  50754. */
  50755. constructor(name: string, scene: Scene);
  50756. getClassName(): string;
  50757. }
  50758. }
  50759. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50760. import { Scene } from "babylonjs/scene";
  50761. import { Color3 } from "babylonjs/Maths/math";
  50762. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50763. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50764. /**
  50765. * The PBR material of BJS following the metal roughness convention.
  50766. *
  50767. * This fits to the PBR convention in the GLTF definition:
  50768. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50769. */
  50770. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50771. /**
  50772. * The base color has two different interpretations depending on the value of metalness.
  50773. * When the material is a metal, the base color is the specific measured reflectance value
  50774. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50775. * of the material.
  50776. */
  50777. baseColor: Color3;
  50778. /**
  50779. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50780. * well as opacity information in the alpha channel.
  50781. */
  50782. baseTexture: BaseTexture;
  50783. /**
  50784. * Specifies the metallic scalar value of the material.
  50785. * Can also be used to scale the metalness values of the metallic texture.
  50786. */
  50787. metallic: number;
  50788. /**
  50789. * Specifies the roughness scalar value of the material.
  50790. * Can also be used to scale the roughness values of the metallic texture.
  50791. */
  50792. roughness: number;
  50793. /**
  50794. * Texture containing both the metallic value in the B channel and the
  50795. * roughness value in the G channel to keep better precision.
  50796. */
  50797. metallicRoughnessTexture: BaseTexture;
  50798. /**
  50799. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50800. *
  50801. * @param name The material name
  50802. * @param scene The scene the material will be use in.
  50803. */
  50804. constructor(name: string, scene: Scene);
  50805. /**
  50806. * Return the currrent class name of the material.
  50807. */
  50808. getClassName(): string;
  50809. /**
  50810. * Makes a duplicate of the current material.
  50811. * @param name - name to use for the new material.
  50812. */
  50813. clone(name: string): PBRMetallicRoughnessMaterial;
  50814. /**
  50815. * Serialize the material to a parsable JSON object.
  50816. */
  50817. serialize(): any;
  50818. /**
  50819. * Parses a JSON object correponding to the serialize function.
  50820. */
  50821. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50822. }
  50823. }
  50824. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  50825. import { Scene } from "babylonjs/scene";
  50826. import { Color3 } from "babylonjs/Maths/math";
  50827. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50828. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50829. /**
  50830. * The PBR material of BJS following the specular glossiness convention.
  50831. *
  50832. * This fits to the PBR convention in the GLTF definition:
  50833. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50834. */
  50835. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50836. /**
  50837. * Specifies the diffuse color of the material.
  50838. */
  50839. diffuseColor: Color3;
  50840. /**
  50841. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50842. * channel.
  50843. */
  50844. diffuseTexture: BaseTexture;
  50845. /**
  50846. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50847. */
  50848. specularColor: Color3;
  50849. /**
  50850. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50851. */
  50852. glossiness: number;
  50853. /**
  50854. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50855. */
  50856. specularGlossinessTexture: BaseTexture;
  50857. /**
  50858. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50859. *
  50860. * @param name The material name
  50861. * @param scene The scene the material will be use in.
  50862. */
  50863. constructor(name: string, scene: Scene);
  50864. /**
  50865. * Return the currrent class name of the material.
  50866. */
  50867. getClassName(): string;
  50868. /**
  50869. * Makes a duplicate of the current material.
  50870. * @param name - name to use for the new material.
  50871. */
  50872. clone(name: string): PBRSpecularGlossinessMaterial;
  50873. /**
  50874. * Serialize the material to a parsable JSON object.
  50875. */
  50876. serialize(): any;
  50877. /**
  50878. * Parses a JSON object correponding to the serialize function.
  50879. */
  50880. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50881. }
  50882. }
  50883. declare module "babylonjs/Materials/PBR/index" {
  50884. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50885. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50886. export * from "babylonjs/Materials/PBR/pbrMaterial";
  50887. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  50888. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  50889. }
  50890. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  50891. import { Nullable } from "babylonjs/types";
  50892. import { Scene } from "babylonjs/scene";
  50893. import { Matrix } from "babylonjs/Maths/math";
  50894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50895. /**
  50896. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50897. * It can help converting any input color in a desired output one. This can then be used to create effects
  50898. * from sepia, black and white to sixties or futuristic rendering...
  50899. *
  50900. * The only supported format is currently 3dl.
  50901. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50902. */
  50903. export class ColorGradingTexture extends BaseTexture {
  50904. /**
  50905. * The current texture matrix. (will always be identity in color grading texture)
  50906. */
  50907. private _textureMatrix;
  50908. /**
  50909. * The texture URL.
  50910. */
  50911. url: string;
  50912. /**
  50913. * Empty line regex stored for GC.
  50914. */
  50915. private static _noneEmptyLineRegex;
  50916. private _engine;
  50917. /**
  50918. * Instantiates a ColorGradingTexture from the following parameters.
  50919. *
  50920. * @param url The location of the color gradind data (currently only supporting 3dl)
  50921. * @param scene The scene the texture will be used in
  50922. */
  50923. constructor(url: string, scene: Scene);
  50924. /**
  50925. * Returns the texture matrix used in most of the material.
  50926. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50927. */
  50928. getTextureMatrix(): Matrix;
  50929. /**
  50930. * Occurs when the file being loaded is a .3dl LUT file.
  50931. */
  50932. private load3dlTexture;
  50933. /**
  50934. * Starts the loading process of the texture.
  50935. */
  50936. private loadTexture;
  50937. /**
  50938. * Clones the color gradind texture.
  50939. */
  50940. clone(): ColorGradingTexture;
  50941. /**
  50942. * Called during delayed load for textures.
  50943. */
  50944. delayLoad(): void;
  50945. /**
  50946. * Parses a color grading texture serialized by Babylon.
  50947. * @param parsedTexture The texture information being parsedTexture
  50948. * @param scene The scene to load the texture in
  50949. * @param rootUrl The root url of the data assets to load
  50950. * @return A color gradind texture
  50951. */
  50952. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50953. /**
  50954. * Serializes the LUT texture to json format.
  50955. */
  50956. serialize(): any;
  50957. }
  50958. }
  50959. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  50960. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50961. import { Scene } from "babylonjs/scene";
  50962. import { Nullable } from "babylonjs/types";
  50963. /**
  50964. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50965. */
  50966. export class EquiRectangularCubeTexture extends BaseTexture {
  50967. /** The six faces of the cube. */
  50968. private static _FacesMapping;
  50969. private _noMipmap;
  50970. private _onLoad;
  50971. private _onError;
  50972. /** The size of the cubemap. */
  50973. private _size;
  50974. /** The buffer of the image. */
  50975. private _buffer;
  50976. /** The width of the input image. */
  50977. private _width;
  50978. /** The height of the input image. */
  50979. private _height;
  50980. /** The URL to the image. */
  50981. url: string;
  50982. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50983. coordinatesMode: number;
  50984. /**
  50985. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50986. * @param url The location of the image
  50987. * @param scene The scene the texture will be used in
  50988. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50989. * @param noMipmap Forces to not generate the mipmap if true
  50990. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50991. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50992. * @param onLoad — defines a callback called when texture is loaded
  50993. * @param onError — defines a callback called if there is an error
  50994. */
  50995. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50996. /**
  50997. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50998. */
  50999. private loadImage;
  51000. /**
  51001. * Convert the image buffer into a cubemap and create a CubeTexture.
  51002. */
  51003. private loadTexture;
  51004. /**
  51005. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51006. * @param buffer The ArrayBuffer that should be converted.
  51007. * @returns The buffer as Float32Array.
  51008. */
  51009. private getFloat32ArrayFromArrayBuffer;
  51010. /**
  51011. * Get the current class name of the texture useful for serialization or dynamic coding.
  51012. * @returns "EquiRectangularCubeTexture"
  51013. */
  51014. getClassName(): string;
  51015. /**
  51016. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51017. * @returns A clone of the current EquiRectangularCubeTexture.
  51018. */
  51019. clone(): EquiRectangularCubeTexture;
  51020. }
  51021. }
  51022. declare module "babylonjs/Misc/tga" {
  51023. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51024. /**
  51025. * Based on jsTGALoader - Javascript loader for TGA file
  51026. * By Vincent Thibault
  51027. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51028. */
  51029. export class TGATools {
  51030. private static _TYPE_INDEXED;
  51031. private static _TYPE_RGB;
  51032. private static _TYPE_GREY;
  51033. private static _TYPE_RLE_INDEXED;
  51034. private static _TYPE_RLE_RGB;
  51035. private static _TYPE_RLE_GREY;
  51036. private static _ORIGIN_MASK;
  51037. private static _ORIGIN_SHIFT;
  51038. private static _ORIGIN_BL;
  51039. private static _ORIGIN_BR;
  51040. private static _ORIGIN_UL;
  51041. private static _ORIGIN_UR;
  51042. /**
  51043. * Gets the header of a TGA file
  51044. * @param data defines the TGA data
  51045. * @returns the header
  51046. */
  51047. static GetTGAHeader(data: Uint8Array): any;
  51048. /**
  51049. * Uploads TGA content to a Babylon Texture
  51050. * @hidden
  51051. */
  51052. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51053. /** @hidden */
  51054. 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;
  51055. /** @hidden */
  51056. 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;
  51057. /** @hidden */
  51058. 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;
  51059. /** @hidden */
  51060. 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;
  51061. /** @hidden */
  51062. 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;
  51063. /** @hidden */
  51064. 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;
  51065. }
  51066. }
  51067. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51068. import { Nullable } from "babylonjs/types";
  51069. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51070. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51071. /**
  51072. * Implementation of the TGA Texture Loader.
  51073. * @hidden
  51074. */
  51075. export class _TGATextureLoader implements IInternalTextureLoader {
  51076. /**
  51077. * Defines wether the loader supports cascade loading the different faces.
  51078. */
  51079. readonly supportCascades: boolean;
  51080. /**
  51081. * This returns if the loader support the current file information.
  51082. * @param extension defines the file extension of the file being loaded
  51083. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51084. * @param fallback defines the fallback internal texture if any
  51085. * @param isBase64 defines whether the texture is encoded as a base64
  51086. * @param isBuffer defines whether the texture data are stored as a buffer
  51087. * @returns true if the loader can load the specified file
  51088. */
  51089. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51090. /**
  51091. * Transform the url before loading if required.
  51092. * @param rootUrl the url of the texture
  51093. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51094. * @returns the transformed texture
  51095. */
  51096. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51097. /**
  51098. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51099. * @param rootUrl the url of the texture
  51100. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51101. * @returns the fallback texture
  51102. */
  51103. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51104. /**
  51105. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51106. * @param data contains the texture data
  51107. * @param texture defines the BabylonJS internal texture
  51108. * @param createPolynomials will be true if polynomials have been requested
  51109. * @param onLoad defines the callback to trigger once the texture is ready
  51110. * @param onError defines the callback to trigger in case of error
  51111. */
  51112. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51113. /**
  51114. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51115. * @param data contains the texture data
  51116. * @param texture defines the BabylonJS internal texture
  51117. * @param callback defines the method to call once ready to upload
  51118. */
  51119. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51120. }
  51121. }
  51122. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51123. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51124. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51125. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51126. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51127. }
  51128. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51129. import { Scene } from "babylonjs/scene";
  51130. import { Texture } from "babylonjs/Materials/Textures/texture";
  51131. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51132. /**
  51133. * 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.
  51134. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51135. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51136. */
  51137. export class CustomProceduralTexture extends ProceduralTexture {
  51138. private _animate;
  51139. private _time;
  51140. private _config;
  51141. private _texturePath;
  51142. /**
  51143. * Instantiates a new Custom Procedural Texture.
  51144. * 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.
  51145. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51146. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51147. * @param name Define the name of the texture
  51148. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51149. * @param size Define the size of the texture to create
  51150. * @param scene Define the scene the texture belongs to
  51151. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51152. * @param generateMipMaps Define if the texture should creates mip maps or not
  51153. */
  51154. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51155. private _loadJson;
  51156. /**
  51157. * Is the texture ready to be used ? (rendered at least once)
  51158. * @returns true if ready, otherwise, false.
  51159. */
  51160. isReady(): boolean;
  51161. /**
  51162. * Render the texture to its associated render target.
  51163. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51164. */
  51165. render(useCameraPostProcess?: boolean): void;
  51166. /**
  51167. * Update the list of dependant textures samplers in the shader.
  51168. */
  51169. updateTextures(): void;
  51170. /**
  51171. * Update the uniform values of the procedural texture in the shader.
  51172. */
  51173. updateShaderUniforms(): void;
  51174. /**
  51175. * Define if the texture animates or not.
  51176. */
  51177. animate: boolean;
  51178. }
  51179. }
  51180. declare module "babylonjs/Shaders/noise.fragment" {
  51181. /** @hidden */
  51182. export var noisePixelShader: {
  51183. name: string;
  51184. shader: string;
  51185. };
  51186. }
  51187. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51188. import { Nullable } from "babylonjs/types";
  51189. import { Scene } from "babylonjs/scene";
  51190. import { Texture } from "babylonjs/Materials/Textures/texture";
  51191. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51192. import "babylonjs/Shaders/noise.fragment";
  51193. /**
  51194. * Class used to generate noise procedural textures
  51195. */
  51196. export class NoiseProceduralTexture extends ProceduralTexture {
  51197. private _time;
  51198. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51199. brightness: number;
  51200. /** Defines the number of octaves to process */
  51201. octaves: number;
  51202. /** Defines the level of persistence (0.8 by default) */
  51203. persistence: number;
  51204. /** Gets or sets animation speed factor (default is 1) */
  51205. animationSpeedFactor: number;
  51206. /**
  51207. * Creates a new NoiseProceduralTexture
  51208. * @param name defines the name fo the texture
  51209. * @param size defines the size of the texture (default is 256)
  51210. * @param scene defines the hosting scene
  51211. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51212. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51213. */
  51214. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51215. private _updateShaderUniforms;
  51216. protected _getDefines(): string;
  51217. /** Generate the current state of the procedural texture */
  51218. render(useCameraPostProcess?: boolean): void;
  51219. /**
  51220. * Serializes this noise procedural texture
  51221. * @returns a serialized noise procedural texture object
  51222. */
  51223. serialize(): any;
  51224. /**
  51225. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51226. * @param parsedTexture defines parsed texture data
  51227. * @param scene defines the current scene
  51228. * @param rootUrl defines the root URL containing noise procedural texture information
  51229. * @returns a parsed NoiseProceduralTexture
  51230. */
  51231. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51232. }
  51233. }
  51234. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51235. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51236. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51237. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51238. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51239. }
  51240. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51241. import { Nullable } from "babylonjs/types";
  51242. import { Scene } from "babylonjs/scene";
  51243. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51244. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51245. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51246. /**
  51247. * Raw cube texture where the raw buffers are passed in
  51248. */
  51249. export class RawCubeTexture extends CubeTexture {
  51250. /**
  51251. * Creates a cube texture where the raw buffers are passed in.
  51252. * @param scene defines the scene the texture is attached to
  51253. * @param data defines the array of data to use to create each face
  51254. * @param size defines the size of the textures
  51255. * @param format defines the format of the data
  51256. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51257. * @param generateMipMaps defines if the engine should generate the mip levels
  51258. * @param invertY defines if data must be stored with Y axis inverted
  51259. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51260. * @param compression defines the compression used (null by default)
  51261. */
  51262. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51263. /**
  51264. * Updates the raw cube texture.
  51265. * @param data defines the data to store
  51266. * @param format defines the data format
  51267. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51268. * @param invertY defines if data must be stored with Y axis inverted
  51269. * @param compression defines the compression used (null by default)
  51270. * @param level defines which level of the texture to update
  51271. */
  51272. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51273. /**
  51274. * Updates a raw cube texture with RGBD encoded data.
  51275. * @param data defines the array of data [mipmap][face] to use to create each face
  51276. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51277. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51278. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51279. * @returns a promsie that resolves when the operation is complete
  51280. */
  51281. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51282. /**
  51283. * Clones the raw cube texture.
  51284. * @return a new cube texture
  51285. */
  51286. clone(): CubeTexture;
  51287. /** @hidden */
  51288. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51289. }
  51290. }
  51291. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51292. import { Scene } from "babylonjs/scene";
  51293. import { Texture } from "babylonjs/Materials/Textures/texture";
  51294. /**
  51295. * Class used to store 3D textures containing user data
  51296. */
  51297. export class RawTexture3D extends Texture {
  51298. /** Gets or sets the texture format to use */
  51299. format: number;
  51300. private _engine;
  51301. /**
  51302. * Create a new RawTexture3D
  51303. * @param data defines the data of the texture
  51304. * @param width defines the width of the texture
  51305. * @param height defines the height of the texture
  51306. * @param depth defines the depth of the texture
  51307. * @param format defines the texture format to use
  51308. * @param scene defines the hosting scene
  51309. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51310. * @param invertY defines if texture must be stored with Y axis inverted
  51311. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51312. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51313. */
  51314. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51315. /** Gets or sets the texture format to use */
  51316. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51317. /**
  51318. * Update the texture with new data
  51319. * @param data defines the data to store in the texture
  51320. */
  51321. update(data: ArrayBufferView): void;
  51322. }
  51323. }
  51324. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51325. import { Scene } from "babylonjs/scene";
  51326. import { Plane } from "babylonjs/Maths/math";
  51327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51328. /**
  51329. * Creates a refraction texture used by refraction channel of the standard material.
  51330. * It is like a mirror but to see through a material.
  51331. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51332. */
  51333. export class RefractionTexture extends RenderTargetTexture {
  51334. /**
  51335. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51336. * 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.
  51337. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51338. */
  51339. refractionPlane: Plane;
  51340. /**
  51341. * Define how deep under the surface we should see.
  51342. */
  51343. depth: number;
  51344. /**
  51345. * Creates a refraction texture used by refraction channel of the standard material.
  51346. * It is like a mirror but to see through a material.
  51347. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51348. * @param name Define the texture name
  51349. * @param size Define the size of the underlying texture
  51350. * @param scene Define the scene the refraction belongs to
  51351. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51352. */
  51353. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51354. /**
  51355. * Clone the refraction texture.
  51356. * @returns the cloned texture
  51357. */
  51358. clone(): RefractionTexture;
  51359. /**
  51360. * Serialize the texture to a JSON representation you could use in Parse later on
  51361. * @returns the serialized JSON representation
  51362. */
  51363. serialize(): any;
  51364. }
  51365. }
  51366. declare module "babylonjs/Materials/Textures/index" {
  51367. export * from "babylonjs/Materials/Textures/baseTexture";
  51368. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51369. export * from "babylonjs/Materials/Textures/cubeTexture";
  51370. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51371. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51372. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51373. export * from "babylonjs/Materials/Textures/internalTexture";
  51374. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51375. export * from "babylonjs/Materials/Textures/Loaders/index";
  51376. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51377. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51378. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51379. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51380. export * from "babylonjs/Materials/Textures/rawTexture";
  51381. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51382. export * from "babylonjs/Materials/Textures/refractionTexture";
  51383. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51384. export * from "babylonjs/Materials/Textures/texture";
  51385. export * from "babylonjs/Materials/Textures/videoTexture";
  51386. }
  51387. declare module "babylonjs/Materials/index" {
  51388. export * from "babylonjs/Materials/Background/index";
  51389. export * from "babylonjs/Materials/colorCurves";
  51390. export * from "babylonjs/Materials/effect";
  51391. export * from "babylonjs/Materials/fresnelParameters";
  51392. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51393. export * from "babylonjs/Materials/material";
  51394. export * from "babylonjs/Materials/materialDefines";
  51395. export * from "babylonjs/Materials/materialHelper";
  51396. export * from "babylonjs/Materials/multiMaterial";
  51397. export * from "babylonjs/Materials/PBR/index";
  51398. export * from "babylonjs/Materials/pushMaterial";
  51399. export * from "babylonjs/Materials/shaderMaterial";
  51400. export * from "babylonjs/Materials/standardMaterial";
  51401. export * from "babylonjs/Materials/Textures/index";
  51402. export * from "babylonjs/Materials/uniformBuffer";
  51403. export * from "babylonjs/Materials/materialFlags";
  51404. }
  51405. declare module "babylonjs/Maths/index" {
  51406. export * from "babylonjs/Maths/math.scalar";
  51407. export * from "babylonjs/Maths/math";
  51408. export * from "babylonjs/Maths/sphericalPolynomial";
  51409. }
  51410. declare module "babylonjs/Misc/workerPool" {
  51411. import { IDisposable } from "babylonjs/scene";
  51412. /**
  51413. * Helper class to push actions to a pool of workers.
  51414. */
  51415. export class WorkerPool implements IDisposable {
  51416. private _workerInfos;
  51417. private _pendingActions;
  51418. /**
  51419. * Constructor
  51420. * @param workers Array of workers to use for actions
  51421. */
  51422. constructor(workers: Array<Worker>);
  51423. /**
  51424. * Terminates all workers and clears any pending actions.
  51425. */
  51426. dispose(): void;
  51427. /**
  51428. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51429. * pended until a worker has completed its action.
  51430. * @param action The action to perform. Call onComplete when the action is complete.
  51431. */
  51432. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51433. private _execute;
  51434. }
  51435. }
  51436. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51437. import { IDisposable } from "babylonjs/scene";
  51438. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51439. /**
  51440. * Configuration for Draco compression
  51441. */
  51442. export interface IDracoCompressionConfiguration {
  51443. /**
  51444. * Configuration for the decoder.
  51445. */
  51446. decoder?: {
  51447. /**
  51448. * The url to the WebAssembly module.
  51449. */
  51450. wasmUrl?: string;
  51451. /**
  51452. * The url to the WebAssembly binary.
  51453. */
  51454. wasmBinaryUrl?: string;
  51455. /**
  51456. * The url to the fallback JavaScript module.
  51457. */
  51458. fallbackUrl?: string;
  51459. };
  51460. }
  51461. /**
  51462. * Draco compression (https://google.github.io/draco/)
  51463. *
  51464. * This class wraps the Draco module.
  51465. *
  51466. * **Encoder**
  51467. *
  51468. * The encoder is not currently implemented.
  51469. *
  51470. * **Decoder**
  51471. *
  51472. * 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.
  51473. *
  51474. * To update the configuration, use the following code:
  51475. * ```javascript
  51476. * DracoCompression.Configuration = {
  51477. * decoder: {
  51478. * wasmUrl: "<url to the WebAssembly library>",
  51479. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51480. * fallbackUrl: "<url to the fallback JavaScript library>",
  51481. * }
  51482. * };
  51483. * ```
  51484. *
  51485. * 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.
  51486. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51487. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51488. *
  51489. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51490. * ```javascript
  51491. * var dracoCompression = new DracoCompression();
  51492. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51493. * [VertexBuffer.PositionKind]: 0
  51494. * });
  51495. * ```
  51496. *
  51497. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51498. */
  51499. export class DracoCompression implements IDisposable {
  51500. private _workerPoolPromise;
  51501. /**
  51502. * The configuration. Defaults to the following urls:
  51503. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51504. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51505. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51506. */
  51507. static Configuration: IDracoCompressionConfiguration;
  51508. /**
  51509. * Returns true if the decoder is available.
  51510. */
  51511. static readonly DecoderAvailable: boolean;
  51512. /**
  51513. * Default number of workers to create when creating the draco compression object.
  51514. */
  51515. static DefaultNumWorkers: number;
  51516. private static GetDefaultNumWorkers;
  51517. /**
  51518. * Constructor
  51519. * @param numWorkers The number of workers for async operations
  51520. */
  51521. constructor(numWorkers?: number);
  51522. /**
  51523. * Stop all async operations and release resources.
  51524. */
  51525. dispose(): void;
  51526. /**
  51527. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51528. * @returns a promise that resolves when ready
  51529. */
  51530. whenReadyAsync(): Promise<void>;
  51531. /**
  51532. * Decode Draco compressed mesh data to vertex data.
  51533. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51534. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51535. * @returns A promise that resolves with the decoded vertex data
  51536. */
  51537. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51538. [kind: string]: number;
  51539. }): Promise<VertexData>;
  51540. /**
  51541. * The worker function that gets converted to a blob url to pass into a worker.
  51542. */
  51543. private static _Worker;
  51544. private _loadDecoderWasmBinaryAsync;
  51545. }
  51546. }
  51547. declare module "babylonjs/Meshes/Compression/index" {
  51548. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51549. }
  51550. declare module "babylonjs/Meshes/csg" {
  51551. import { Nullable } from "babylonjs/types";
  51552. import { Scene } from "babylonjs/scene";
  51553. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51554. import { Mesh } from "babylonjs/Meshes/mesh";
  51555. import { Material } from "babylonjs/Materials/material";
  51556. /**
  51557. * Class for building Constructive Solid Geometry
  51558. */
  51559. export class CSG {
  51560. private polygons;
  51561. /**
  51562. * The world matrix
  51563. */
  51564. matrix: Matrix;
  51565. /**
  51566. * Stores the position
  51567. */
  51568. position: Vector3;
  51569. /**
  51570. * Stores the rotation
  51571. */
  51572. rotation: Vector3;
  51573. /**
  51574. * Stores the rotation quaternion
  51575. */
  51576. rotationQuaternion: Nullable<Quaternion>;
  51577. /**
  51578. * Stores the scaling vector
  51579. */
  51580. scaling: Vector3;
  51581. /**
  51582. * Convert the Mesh to CSG
  51583. * @param mesh The Mesh to convert to CSG
  51584. * @returns A new CSG from the Mesh
  51585. */
  51586. static FromMesh(mesh: Mesh): CSG;
  51587. /**
  51588. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51589. * @param polygons Polygons used to construct a CSG solid
  51590. */
  51591. private static FromPolygons;
  51592. /**
  51593. * Clones, or makes a deep copy, of the CSG
  51594. * @returns A new CSG
  51595. */
  51596. clone(): CSG;
  51597. /**
  51598. * Unions this CSG with another CSG
  51599. * @param csg The CSG to union against this CSG
  51600. * @returns The unioned CSG
  51601. */
  51602. union(csg: CSG): CSG;
  51603. /**
  51604. * Unions this CSG with another CSG in place
  51605. * @param csg The CSG to union against this CSG
  51606. */
  51607. unionInPlace(csg: CSG): void;
  51608. /**
  51609. * Subtracts this CSG with another CSG
  51610. * @param csg The CSG to subtract against this CSG
  51611. * @returns A new CSG
  51612. */
  51613. subtract(csg: CSG): CSG;
  51614. /**
  51615. * Subtracts this CSG with another CSG in place
  51616. * @param csg The CSG to subtact against this CSG
  51617. */
  51618. subtractInPlace(csg: CSG): void;
  51619. /**
  51620. * Intersect this CSG with another CSG
  51621. * @param csg The CSG to intersect against this CSG
  51622. * @returns A new CSG
  51623. */
  51624. intersect(csg: CSG): CSG;
  51625. /**
  51626. * Intersects this CSG with another CSG in place
  51627. * @param csg The CSG to intersect against this CSG
  51628. */
  51629. intersectInPlace(csg: CSG): void;
  51630. /**
  51631. * Return a new CSG solid with solid and empty space switched. This solid is
  51632. * not modified.
  51633. * @returns A new CSG solid with solid and empty space switched
  51634. */
  51635. inverse(): CSG;
  51636. /**
  51637. * Inverses the CSG in place
  51638. */
  51639. inverseInPlace(): void;
  51640. /**
  51641. * This is used to keep meshes transformations so they can be restored
  51642. * when we build back a Babylon Mesh
  51643. * NB : All CSG operations are performed in world coordinates
  51644. * @param csg The CSG to copy the transform attributes from
  51645. * @returns This CSG
  51646. */
  51647. copyTransformAttributes(csg: CSG): CSG;
  51648. /**
  51649. * Build Raw mesh from CSG
  51650. * Coordinates here are in world space
  51651. * @param name The name of the mesh geometry
  51652. * @param scene The Scene
  51653. * @param keepSubMeshes Specifies if the submeshes should be kept
  51654. * @returns A new Mesh
  51655. */
  51656. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51657. /**
  51658. * Build Mesh from CSG taking material and transforms into account
  51659. * @param name The name of the Mesh
  51660. * @param material The material of the Mesh
  51661. * @param scene The Scene
  51662. * @param keepSubMeshes Specifies if submeshes should be kept
  51663. * @returns The new Mesh
  51664. */
  51665. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51666. }
  51667. }
  51668. declare module "babylonjs/Meshes/trailMesh" {
  51669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51670. import { Mesh } from "babylonjs/Meshes/mesh";
  51671. import { Scene } from "babylonjs/scene";
  51672. /**
  51673. * Class used to create a trail following a mesh
  51674. */
  51675. export class TrailMesh extends Mesh {
  51676. private _generator;
  51677. private _autoStart;
  51678. private _running;
  51679. private _diameter;
  51680. private _length;
  51681. private _sectionPolygonPointsCount;
  51682. private _sectionVectors;
  51683. private _sectionNormalVectors;
  51684. private _beforeRenderObserver;
  51685. /**
  51686. * @constructor
  51687. * @param name The value used by scene.getMeshByName() to do a lookup.
  51688. * @param generator The mesh to generate a trail.
  51689. * @param scene The scene to add this mesh to.
  51690. * @param diameter Diameter of trailing mesh. Default is 1.
  51691. * @param length Length of trailing mesh. Default is 60.
  51692. * @param autoStart Automatically start trailing mesh. Default true.
  51693. */
  51694. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51695. /**
  51696. * "TrailMesh"
  51697. * @returns "TrailMesh"
  51698. */
  51699. getClassName(): string;
  51700. private _createMesh;
  51701. /**
  51702. * Start trailing mesh.
  51703. */
  51704. start(): void;
  51705. /**
  51706. * Stop trailing mesh.
  51707. */
  51708. stop(): void;
  51709. /**
  51710. * Update trailing mesh geometry.
  51711. */
  51712. update(): void;
  51713. /**
  51714. * Returns a new TrailMesh object.
  51715. * @param name is a string, the name given to the new mesh
  51716. * @param newGenerator use new generator object for cloned trail mesh
  51717. * @returns a new mesh
  51718. */
  51719. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51720. /**
  51721. * Serializes this trail mesh
  51722. * @param serializationObject object to write serialization to
  51723. */
  51724. serialize(serializationObject: any): void;
  51725. /**
  51726. * Parses a serialized trail mesh
  51727. * @param parsedMesh the serialized mesh
  51728. * @param scene the scene to create the trail mesh in
  51729. * @returns the created trail mesh
  51730. */
  51731. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51732. }
  51733. }
  51734. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  51735. import { Vector4 } from "babylonjs/Maths/math";
  51736. import { Mesh } from "babylonjs/Meshes/mesh";
  51737. /**
  51738. * Class containing static functions to help procedurally build meshes
  51739. */
  51740. export class TorusKnotBuilder {
  51741. /**
  51742. * Creates a torus knot mesh
  51743. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51744. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51745. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51746. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51750. * @param name defines the name of the mesh
  51751. * @param options defines the options used to create the mesh
  51752. * @param scene defines the hosting scene
  51753. * @returns the torus knot mesh
  51754. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51755. */
  51756. static CreateTorusKnot(name: string, options: {
  51757. radius?: number;
  51758. tube?: number;
  51759. radialSegments?: number;
  51760. tubularSegments?: number;
  51761. p?: number;
  51762. q?: number;
  51763. updatable?: boolean;
  51764. sideOrientation?: number;
  51765. frontUVs?: Vector4;
  51766. backUVs?: Vector4;
  51767. }, scene: any): Mesh;
  51768. }
  51769. }
  51770. declare module "babylonjs/Meshes/polygonMesh" {
  51771. import { Scene } from "babylonjs/scene";
  51772. import { Vector2, Path2 } from "babylonjs/Maths/math";
  51773. import { Mesh } from "babylonjs/Meshes/mesh";
  51774. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51775. /**
  51776. * Polygon
  51777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51778. */
  51779. export class Polygon {
  51780. /**
  51781. * Creates a rectangle
  51782. * @param xmin bottom X coord
  51783. * @param ymin bottom Y coord
  51784. * @param xmax top X coord
  51785. * @param ymax top Y coord
  51786. * @returns points that make the resulting rectation
  51787. */
  51788. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51789. /**
  51790. * Creates a circle
  51791. * @param radius radius of circle
  51792. * @param cx scale in x
  51793. * @param cy scale in y
  51794. * @param numberOfSides number of sides that make up the circle
  51795. * @returns points that make the resulting circle
  51796. */
  51797. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51798. /**
  51799. * Creates a polygon from input string
  51800. * @param input Input polygon data
  51801. * @returns the parsed points
  51802. */
  51803. static Parse(input: string): Vector2[];
  51804. /**
  51805. * Starts building a polygon from x and y coordinates
  51806. * @param x x coordinate
  51807. * @param y y coordinate
  51808. * @returns the started path2
  51809. */
  51810. static StartingAt(x: number, y: number): Path2;
  51811. }
  51812. /**
  51813. * Builds a polygon
  51814. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51815. */
  51816. export class PolygonMeshBuilder {
  51817. private _points;
  51818. private _outlinepoints;
  51819. private _holes;
  51820. private _name;
  51821. private _scene;
  51822. private _epoints;
  51823. private _eholes;
  51824. private _addToepoint;
  51825. /**
  51826. * Babylon reference to the earcut plugin.
  51827. */
  51828. bjsEarcut: any;
  51829. /**
  51830. * Creates a PolygonMeshBuilder
  51831. * @param name name of the builder
  51832. * @param contours Path of the polygon
  51833. * @param scene scene to add to when creating the mesh
  51834. * @param earcutInjection can be used to inject your own earcut reference
  51835. */
  51836. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51837. /**
  51838. * Adds a whole within the polygon
  51839. * @param hole Array of points defining the hole
  51840. * @returns this
  51841. */
  51842. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51843. /**
  51844. * Creates the polygon
  51845. * @param updatable If the mesh should be updatable
  51846. * @param depth The depth of the mesh created
  51847. * @returns the created mesh
  51848. */
  51849. build(updatable?: boolean, depth?: number): Mesh;
  51850. /**
  51851. * Creates the polygon
  51852. * @param depth The depth of the mesh created
  51853. * @returns the created VertexData
  51854. */
  51855. buildVertexData(depth?: number): VertexData;
  51856. /**
  51857. * Adds a side to the polygon
  51858. * @param positions points that make the polygon
  51859. * @param normals normals of the polygon
  51860. * @param uvs uvs of the polygon
  51861. * @param indices indices of the polygon
  51862. * @param bounds bounds of the polygon
  51863. * @param points points of the polygon
  51864. * @param depth depth of the polygon
  51865. * @param flip flip of the polygon
  51866. */
  51867. private addSide;
  51868. }
  51869. }
  51870. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  51871. import { Scene } from "babylonjs/scene";
  51872. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  51873. import { Mesh } from "babylonjs/Meshes/mesh";
  51874. import { Nullable } from "babylonjs/types";
  51875. /**
  51876. * Class containing static functions to help procedurally build meshes
  51877. */
  51878. export class PolygonBuilder {
  51879. /**
  51880. * Creates a polygon mesh
  51881. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51882. * * 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
  51883. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51886. * * Remember you can only change the shape positions, not their number when updating a polygon
  51887. * @param name defines the name of the mesh
  51888. * @param options defines the options used to create the mesh
  51889. * @param scene defines the hosting scene
  51890. * @param earcutInjection can be used to inject your own earcut reference
  51891. * @returns the polygon mesh
  51892. */
  51893. static CreatePolygon(name: string, options: {
  51894. shape: Vector3[];
  51895. holes?: Vector3[][];
  51896. depth?: number;
  51897. faceUV?: Vector4[];
  51898. faceColors?: Color4[];
  51899. updatable?: boolean;
  51900. sideOrientation?: number;
  51901. frontUVs?: Vector4;
  51902. backUVs?: Vector4;
  51903. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51904. /**
  51905. * Creates an extruded polygon mesh, with depth in the Y direction.
  51906. * * 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)
  51907. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51908. * @param name defines the name of the mesh
  51909. * @param options defines the options used to create the mesh
  51910. * @param scene defines the hosting scene
  51911. * @param earcutInjection can be used to inject your own earcut reference
  51912. * @returns the polygon mesh
  51913. */
  51914. static ExtrudePolygon(name: string, options: {
  51915. shape: Vector3[];
  51916. holes?: Vector3[][];
  51917. depth?: number;
  51918. faceUV?: Vector4[];
  51919. faceColors?: Color4[];
  51920. updatable?: boolean;
  51921. sideOrientation?: number;
  51922. frontUVs?: Vector4;
  51923. backUVs?: Vector4;
  51924. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51925. }
  51926. }
  51927. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  51928. import { Scene } from "babylonjs/scene";
  51929. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51930. import { Mesh } from "babylonjs/Meshes/mesh";
  51931. import { Nullable } from "babylonjs/types";
  51932. /**
  51933. * Class containing static functions to help procedurally build meshes
  51934. */
  51935. export class LatheBuilder {
  51936. /**
  51937. * Creates lathe mesh.
  51938. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51939. * * 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
  51940. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51941. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51942. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51943. * * 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
  51944. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51945. * * 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
  51946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51950. * @param name defines the name of the mesh
  51951. * @param options defines the options used to create the mesh
  51952. * @param scene defines the hosting scene
  51953. * @returns the lathe mesh
  51954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51955. */
  51956. static CreateLathe(name: string, options: {
  51957. shape: Vector3[];
  51958. radius?: number;
  51959. tessellation?: number;
  51960. clip?: number;
  51961. arc?: number;
  51962. closed?: boolean;
  51963. updatable?: boolean;
  51964. sideOrientation?: number;
  51965. frontUVs?: Vector4;
  51966. backUVs?: Vector4;
  51967. cap?: number;
  51968. invertUV?: boolean;
  51969. }, scene?: Nullable<Scene>): Mesh;
  51970. }
  51971. }
  51972. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  51973. import { Nullable } from "babylonjs/types";
  51974. import { Scene } from "babylonjs/scene";
  51975. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51976. import { Mesh } from "babylonjs/Meshes/mesh";
  51977. /**
  51978. * Class containing static functions to help procedurally build meshes
  51979. */
  51980. export class TubeBuilder {
  51981. /**
  51982. * Creates a tube mesh.
  51983. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51984. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51985. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51986. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51987. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51988. * * 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)
  51989. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51990. * * 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
  51991. * * 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
  51992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51994. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51996. * @param name defines the name of the mesh
  51997. * @param options defines the options used to create the mesh
  51998. * @param scene defines the hosting scene
  51999. * @returns the tube mesh
  52000. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52001. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52002. */
  52003. static CreateTube(name: string, options: {
  52004. path: Vector3[];
  52005. radius?: number;
  52006. tessellation?: number;
  52007. radiusFunction?: {
  52008. (i: number, distance: number): number;
  52009. };
  52010. cap?: number;
  52011. arc?: number;
  52012. updatable?: boolean;
  52013. sideOrientation?: number;
  52014. frontUVs?: Vector4;
  52015. backUVs?: Vector4;
  52016. instance?: Mesh;
  52017. invertUV?: boolean;
  52018. }, scene?: Nullable<Scene>): Mesh;
  52019. }
  52020. }
  52021. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52022. import { Scene } from "babylonjs/scene";
  52023. import { Vector4 } from "babylonjs/Maths/math";
  52024. import { Mesh } from "babylonjs/Meshes/mesh";
  52025. import { Nullable } from "babylonjs/types";
  52026. /**
  52027. * Class containing static functions to help procedurally build meshes
  52028. */
  52029. export class IcoSphereBuilder {
  52030. /**
  52031. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52032. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52033. * * 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`)
  52034. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52035. * * 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
  52036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52039. * @param name defines the name of the mesh
  52040. * @param options defines the options used to create the mesh
  52041. * @param scene defines the hosting scene
  52042. * @returns the icosahedron mesh
  52043. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52044. */
  52045. static CreateIcoSphere(name: string, options: {
  52046. radius?: number;
  52047. radiusX?: number;
  52048. radiusY?: number;
  52049. radiusZ?: number;
  52050. flat?: boolean;
  52051. subdivisions?: number;
  52052. sideOrientation?: number;
  52053. frontUVs?: Vector4;
  52054. backUVs?: Vector4;
  52055. updatable?: boolean;
  52056. }, scene?: Nullable<Scene>): Mesh;
  52057. }
  52058. }
  52059. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52060. import { Vector3 } from "babylonjs/Maths/math";
  52061. import { Mesh } from "babylonjs/Meshes/mesh";
  52062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52063. /**
  52064. * Class containing static functions to help procedurally build meshes
  52065. */
  52066. export class DecalBuilder {
  52067. /**
  52068. * Creates a decal mesh.
  52069. * 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
  52070. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52071. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52072. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52073. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52074. * @param name defines the name of the mesh
  52075. * @param sourceMesh defines the mesh where the decal must be applied
  52076. * @param options defines the options used to create the mesh
  52077. * @param scene defines the hosting scene
  52078. * @returns the decal mesh
  52079. * @see https://doc.babylonjs.com/how_to/decals
  52080. */
  52081. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52082. position?: Vector3;
  52083. normal?: Vector3;
  52084. size?: Vector3;
  52085. angle?: number;
  52086. }): Mesh;
  52087. }
  52088. }
  52089. declare module "babylonjs/Meshes/meshBuilder" {
  52090. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52091. import { Nullable } from "babylonjs/types";
  52092. import { Scene } from "babylonjs/scene";
  52093. import { Mesh } from "babylonjs/Meshes/mesh";
  52094. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52095. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52097. /**
  52098. * Class containing static functions to help procedurally build meshes
  52099. */
  52100. export class MeshBuilder {
  52101. /**
  52102. * Creates a box mesh
  52103. * * The parameter `size` sets the size (float) of each box side (default 1)
  52104. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52105. * * 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)
  52106. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52110. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52111. * @param name defines the name of the mesh
  52112. * @param options defines the options used to create the mesh
  52113. * @param scene defines the hosting scene
  52114. * @returns the box mesh
  52115. */
  52116. static CreateBox(name: string, options: {
  52117. size?: number;
  52118. width?: number;
  52119. height?: number;
  52120. depth?: number;
  52121. faceUV?: Vector4[];
  52122. faceColors?: Color4[];
  52123. sideOrientation?: number;
  52124. frontUVs?: Vector4;
  52125. backUVs?: Vector4;
  52126. updatable?: boolean;
  52127. }, scene?: Nullable<Scene>): Mesh;
  52128. /**
  52129. * Creates a sphere mesh
  52130. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52131. * * 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`)
  52132. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52133. * * 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
  52134. * * 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)
  52135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52138. * @param name defines the name of the mesh
  52139. * @param options defines the options used to create the mesh
  52140. * @param scene defines the hosting scene
  52141. * @returns the sphere mesh
  52142. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52143. */
  52144. static CreateSphere(name: string, options: {
  52145. segments?: number;
  52146. diameter?: number;
  52147. diameterX?: number;
  52148. diameterY?: number;
  52149. diameterZ?: number;
  52150. arc?: number;
  52151. slice?: number;
  52152. sideOrientation?: number;
  52153. frontUVs?: Vector4;
  52154. backUVs?: Vector4;
  52155. updatable?: boolean;
  52156. }, scene?: Nullable<Scene>): Mesh;
  52157. /**
  52158. * Creates a plane polygonal mesh. By default, this is a disc
  52159. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52160. * * 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
  52161. * * 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
  52162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52165. * @param name defines the name of the mesh
  52166. * @param options defines the options used to create the mesh
  52167. * @param scene defines the hosting scene
  52168. * @returns the plane polygonal mesh
  52169. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52170. */
  52171. static CreateDisc(name: string, options: {
  52172. radius?: number;
  52173. tessellation?: number;
  52174. arc?: number;
  52175. updatable?: boolean;
  52176. sideOrientation?: number;
  52177. frontUVs?: Vector4;
  52178. backUVs?: Vector4;
  52179. }, scene?: Nullable<Scene>): Mesh;
  52180. /**
  52181. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52182. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52183. * * 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`)
  52184. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52185. * * 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
  52186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52189. * @param name defines the name of the mesh
  52190. * @param options defines the options used to create the mesh
  52191. * @param scene defines the hosting scene
  52192. * @returns the icosahedron mesh
  52193. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52194. */
  52195. static CreateIcoSphere(name: string, options: {
  52196. radius?: number;
  52197. radiusX?: number;
  52198. radiusY?: number;
  52199. radiusZ?: number;
  52200. flat?: boolean;
  52201. subdivisions?: number;
  52202. sideOrientation?: number;
  52203. frontUVs?: Vector4;
  52204. backUVs?: Vector4;
  52205. updatable?: boolean;
  52206. }, scene?: Nullable<Scene>): Mesh;
  52207. /**
  52208. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52209. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52210. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52211. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52212. * * 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
  52213. * * 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
  52214. * * 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
  52215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52217. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52218. * * 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
  52219. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52220. * * 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
  52221. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52223. * @param name defines the name of the mesh
  52224. * @param options defines the options used to create the mesh
  52225. * @param scene defines the hosting scene
  52226. * @returns the ribbon mesh
  52227. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52228. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52229. */
  52230. static CreateRibbon(name: string, options: {
  52231. pathArray: Vector3[][];
  52232. closeArray?: boolean;
  52233. closePath?: boolean;
  52234. offset?: number;
  52235. updatable?: boolean;
  52236. sideOrientation?: number;
  52237. frontUVs?: Vector4;
  52238. backUVs?: Vector4;
  52239. instance?: Mesh;
  52240. invertUV?: boolean;
  52241. uvs?: Vector2[];
  52242. colors?: Color4[];
  52243. }, scene?: Nullable<Scene>): Mesh;
  52244. /**
  52245. * Creates a cylinder or a cone mesh
  52246. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52247. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52248. * * 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.
  52249. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52250. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52251. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52252. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52253. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52254. * * 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).
  52255. * * 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
  52256. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52257. * * 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
  52258. * * 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.
  52259. * * If `enclose` is false, a ring surface is one element.
  52260. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52261. * * 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
  52262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52265. * @param name defines the name of the mesh
  52266. * @param options defines the options used to create the mesh
  52267. * @param scene defines the hosting scene
  52268. * @returns the cylinder mesh
  52269. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52270. */
  52271. static CreateCylinder(name: string, options: {
  52272. height?: number;
  52273. diameterTop?: number;
  52274. diameterBottom?: number;
  52275. diameter?: number;
  52276. tessellation?: number;
  52277. subdivisions?: number;
  52278. arc?: number;
  52279. faceColors?: Color4[];
  52280. faceUV?: Vector4[];
  52281. updatable?: boolean;
  52282. hasRings?: boolean;
  52283. enclose?: boolean;
  52284. sideOrientation?: number;
  52285. frontUVs?: Vector4;
  52286. backUVs?: Vector4;
  52287. }, scene?: Nullable<Scene>): Mesh;
  52288. /**
  52289. * Creates a torus mesh
  52290. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52291. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52292. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52296. * @param name defines the name of the mesh
  52297. * @param options defines the options used to create the mesh
  52298. * @param scene defines the hosting scene
  52299. * @returns the torus mesh
  52300. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52301. */
  52302. static CreateTorus(name: string, options: {
  52303. diameter?: number;
  52304. thickness?: number;
  52305. tessellation?: number;
  52306. updatable?: boolean;
  52307. sideOrientation?: number;
  52308. frontUVs?: Vector4;
  52309. backUVs?: Vector4;
  52310. }, scene?: Nullable<Scene>): Mesh;
  52311. /**
  52312. * Creates a torus knot mesh
  52313. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52314. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52315. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52316. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52320. * @param name defines the name of the mesh
  52321. * @param options defines the options used to create the mesh
  52322. * @param scene defines the hosting scene
  52323. * @returns the torus knot mesh
  52324. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52325. */
  52326. static CreateTorusKnot(name: string, options: {
  52327. radius?: number;
  52328. tube?: number;
  52329. radialSegments?: number;
  52330. tubularSegments?: number;
  52331. p?: number;
  52332. q?: number;
  52333. updatable?: boolean;
  52334. sideOrientation?: number;
  52335. frontUVs?: Vector4;
  52336. backUVs?: Vector4;
  52337. }, scene?: Nullable<Scene>): Mesh;
  52338. /**
  52339. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52340. * * 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
  52341. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52342. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52343. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52344. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52345. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52346. * * 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
  52347. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52349. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52350. * @param name defines the name of the new line system
  52351. * @param options defines the options used to create the line system
  52352. * @param scene defines the hosting scene
  52353. * @returns a new line system mesh
  52354. */
  52355. static CreateLineSystem(name: string, options: {
  52356. lines: Vector3[][];
  52357. updatable?: boolean;
  52358. instance?: Nullable<LinesMesh>;
  52359. colors?: Nullable<Color4[][]>;
  52360. useVertexAlpha?: boolean;
  52361. }, scene: Nullable<Scene>): LinesMesh;
  52362. /**
  52363. * Creates a line mesh
  52364. * 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
  52365. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52366. * * The parameter `points` is an array successive Vector3
  52367. * * 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
  52368. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52369. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52370. * * When updating an instance, remember that only point positions can change, not the number of points
  52371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52372. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52373. * @param name defines the name of the new line system
  52374. * @param options defines the options used to create the line system
  52375. * @param scene defines the hosting scene
  52376. * @returns a new line mesh
  52377. */
  52378. static CreateLines(name: string, options: {
  52379. points: Vector3[];
  52380. updatable?: boolean;
  52381. instance?: Nullable<LinesMesh>;
  52382. colors?: Color4[];
  52383. useVertexAlpha?: boolean;
  52384. }, scene?: Nullable<Scene>): LinesMesh;
  52385. /**
  52386. * Creates a dashed line mesh
  52387. * * 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
  52388. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52389. * * The parameter `points` is an array successive Vector3
  52390. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52391. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52392. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52393. * * 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
  52394. * * When updating an instance, remember that only point positions can change, not the number of points
  52395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52396. * @param name defines the name of the mesh
  52397. * @param options defines the options used to create the mesh
  52398. * @param scene defines the hosting scene
  52399. * @returns the dashed line mesh
  52400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52401. */
  52402. static CreateDashedLines(name: string, options: {
  52403. points: Vector3[];
  52404. dashSize?: number;
  52405. gapSize?: number;
  52406. dashNb?: number;
  52407. updatable?: boolean;
  52408. instance?: LinesMesh;
  52409. }, scene?: Nullable<Scene>): LinesMesh;
  52410. /**
  52411. * 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.
  52412. * * 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.
  52413. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52414. * * 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.
  52415. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52416. * * 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
  52417. * * 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
  52418. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52421. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52423. * @param name defines the name of the mesh
  52424. * @param options defines the options used to create the mesh
  52425. * @param scene defines the hosting scene
  52426. * @returns the extruded shape mesh
  52427. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52428. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52429. */
  52430. static ExtrudeShape(name: string, options: {
  52431. shape: Vector3[];
  52432. path: Vector3[];
  52433. scale?: number;
  52434. rotation?: number;
  52435. cap?: number;
  52436. updatable?: boolean;
  52437. sideOrientation?: number;
  52438. frontUVs?: Vector4;
  52439. backUVs?: Vector4;
  52440. instance?: Mesh;
  52441. invertUV?: boolean;
  52442. }, scene?: Nullable<Scene>): Mesh;
  52443. /**
  52444. * Creates an custom extruded shape mesh.
  52445. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52446. * * 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.
  52447. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52448. * * 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
  52449. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52450. * * 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
  52451. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52452. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52453. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52454. * * 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
  52455. * * 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
  52456. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52461. * @param name defines the name of the mesh
  52462. * @param options defines the options used to create the mesh
  52463. * @param scene defines the hosting scene
  52464. * @returns the custom extruded shape mesh
  52465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52466. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52468. */
  52469. static ExtrudeShapeCustom(name: string, options: {
  52470. shape: Vector3[];
  52471. path: Vector3[];
  52472. scaleFunction?: any;
  52473. rotationFunction?: any;
  52474. ribbonCloseArray?: boolean;
  52475. ribbonClosePath?: boolean;
  52476. cap?: number;
  52477. updatable?: boolean;
  52478. sideOrientation?: number;
  52479. frontUVs?: Vector4;
  52480. backUVs?: Vector4;
  52481. instance?: Mesh;
  52482. invertUV?: boolean;
  52483. }, scene?: Nullable<Scene>): Mesh;
  52484. /**
  52485. * Creates lathe mesh.
  52486. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52487. * * 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
  52488. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52489. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52490. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52491. * * 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
  52492. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52493. * * 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
  52494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52496. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52498. * @param name defines the name of the mesh
  52499. * @param options defines the options used to create the mesh
  52500. * @param scene defines the hosting scene
  52501. * @returns the lathe mesh
  52502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52503. */
  52504. static CreateLathe(name: string, options: {
  52505. shape: Vector3[];
  52506. radius?: number;
  52507. tessellation?: number;
  52508. clip?: number;
  52509. arc?: number;
  52510. closed?: boolean;
  52511. updatable?: boolean;
  52512. sideOrientation?: number;
  52513. frontUVs?: Vector4;
  52514. backUVs?: Vector4;
  52515. cap?: number;
  52516. invertUV?: boolean;
  52517. }, scene?: Nullable<Scene>): Mesh;
  52518. /**
  52519. * Creates a plane mesh
  52520. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52521. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52522. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52526. * @param name defines the name of the mesh
  52527. * @param options defines the options used to create the mesh
  52528. * @param scene defines the hosting scene
  52529. * @returns the plane mesh
  52530. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52531. */
  52532. static CreatePlane(name: string, options: {
  52533. size?: number;
  52534. width?: number;
  52535. height?: number;
  52536. sideOrientation?: number;
  52537. frontUVs?: Vector4;
  52538. backUVs?: Vector4;
  52539. updatable?: boolean;
  52540. sourcePlane?: Plane;
  52541. }, scene?: Nullable<Scene>): Mesh;
  52542. /**
  52543. * Creates a ground mesh
  52544. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52545. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 ground mesh
  52551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52552. */
  52553. static CreateGround(name: string, options: {
  52554. width?: number;
  52555. height?: number;
  52556. subdivisions?: number;
  52557. subdivisionsX?: number;
  52558. subdivisionsY?: number;
  52559. updatable?: boolean;
  52560. }, scene?: Nullable<Scene>): Mesh;
  52561. /**
  52562. * Creates a tiled ground mesh
  52563. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52564. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52565. * * 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
  52566. * * 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
  52567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52568. * @param name defines the name of the mesh
  52569. * @param options defines the options used to create the mesh
  52570. * @param scene defines the hosting scene
  52571. * @returns the tiled ground mesh
  52572. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52573. */
  52574. static CreateTiledGround(name: string, options: {
  52575. xmin: number;
  52576. zmin: number;
  52577. xmax: number;
  52578. zmax: number;
  52579. subdivisions?: {
  52580. w: number;
  52581. h: number;
  52582. };
  52583. precision?: {
  52584. w: number;
  52585. h: number;
  52586. };
  52587. updatable?: boolean;
  52588. }, scene?: Nullable<Scene>): Mesh;
  52589. /**
  52590. * Creates a ground mesh from a height map
  52591. * * The parameter `url` sets the URL of the height map image resource.
  52592. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52593. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52594. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52595. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52596. * * 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.
  52597. * * 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).
  52598. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52600. * @param name defines the name of the mesh
  52601. * @param url defines the url to the height map
  52602. * @param options defines the options used to create the mesh
  52603. * @param scene defines the hosting scene
  52604. * @returns the ground mesh
  52605. * @see https://doc.babylonjs.com/babylon101/height_map
  52606. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52607. */
  52608. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52609. width?: number;
  52610. height?: number;
  52611. subdivisions?: number;
  52612. minHeight?: number;
  52613. maxHeight?: number;
  52614. colorFilter?: Color3;
  52615. alphaFilter?: number;
  52616. updatable?: boolean;
  52617. onReady?: (mesh: GroundMesh) => void;
  52618. }, scene?: Nullable<Scene>): GroundMesh;
  52619. /**
  52620. * Creates a polygon mesh
  52621. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52622. * * 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
  52623. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52626. * * Remember you can only change the shape positions, not their number when updating a polygon
  52627. * @param name defines the name of the mesh
  52628. * @param options defines the options used to create the mesh
  52629. * @param scene defines the hosting scene
  52630. * @param earcutInjection can be used to inject your own earcut reference
  52631. * @returns the polygon mesh
  52632. */
  52633. static CreatePolygon(name: string, options: {
  52634. shape: Vector3[];
  52635. holes?: Vector3[][];
  52636. depth?: number;
  52637. faceUV?: Vector4[];
  52638. faceColors?: Color4[];
  52639. updatable?: boolean;
  52640. sideOrientation?: number;
  52641. frontUVs?: Vector4;
  52642. backUVs?: Vector4;
  52643. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52644. /**
  52645. * Creates an extruded polygon mesh, with depth in the Y direction.
  52646. * * 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)
  52647. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52648. * @param name defines the name of the mesh
  52649. * @param options defines the options used to create the mesh
  52650. * @param scene defines the hosting scene
  52651. * @param earcutInjection can be used to inject your own earcut reference
  52652. * @returns the polygon mesh
  52653. */
  52654. static ExtrudePolygon(name: string, options: {
  52655. shape: Vector3[];
  52656. holes?: Vector3[][];
  52657. depth?: number;
  52658. faceUV?: Vector4[];
  52659. faceColors?: Color4[];
  52660. updatable?: boolean;
  52661. sideOrientation?: number;
  52662. frontUVs?: Vector4;
  52663. backUVs?: Vector4;
  52664. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52665. /**
  52666. * Creates a tube mesh.
  52667. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52668. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52669. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52670. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52671. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52672. * * 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)
  52673. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52674. * * 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
  52675. * * 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
  52676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52678. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52680. * @param name defines the name of the mesh
  52681. * @param options defines the options used to create the mesh
  52682. * @param scene defines the hosting scene
  52683. * @returns the tube mesh
  52684. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52685. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52686. */
  52687. static CreateTube(name: string, options: {
  52688. path: Vector3[];
  52689. radius?: number;
  52690. tessellation?: number;
  52691. radiusFunction?: {
  52692. (i: number, distance: number): number;
  52693. };
  52694. cap?: number;
  52695. arc?: number;
  52696. updatable?: boolean;
  52697. sideOrientation?: number;
  52698. frontUVs?: Vector4;
  52699. backUVs?: Vector4;
  52700. instance?: Mesh;
  52701. invertUV?: boolean;
  52702. }, scene?: Nullable<Scene>): Mesh;
  52703. /**
  52704. * Creates a polyhedron mesh
  52705. * * 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
  52706. * * The parameter `size` (positive float, default 1) sets the polygon size
  52707. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52708. * * 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`
  52709. * * 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
  52710. * * 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)`)
  52711. * * 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
  52712. * * 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
  52713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52716. * @param name defines the name of the mesh
  52717. * @param options defines the options used to create the mesh
  52718. * @param scene defines the hosting scene
  52719. * @returns the polyhedron mesh
  52720. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52721. */
  52722. static CreatePolyhedron(name: string, options: {
  52723. type?: number;
  52724. size?: number;
  52725. sizeX?: number;
  52726. sizeY?: number;
  52727. sizeZ?: number;
  52728. custom?: any;
  52729. faceUV?: Vector4[];
  52730. faceColors?: Color4[];
  52731. flat?: boolean;
  52732. updatable?: boolean;
  52733. sideOrientation?: number;
  52734. frontUVs?: Vector4;
  52735. backUVs?: Vector4;
  52736. }, scene?: Nullable<Scene>): Mesh;
  52737. /**
  52738. * Creates a decal mesh.
  52739. * 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
  52740. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52741. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52742. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52743. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52744. * @param name defines the name of the mesh
  52745. * @param sourceMesh defines the mesh where the decal must be applied
  52746. * @param options defines the options used to create the mesh
  52747. * @param scene defines the hosting scene
  52748. * @returns the decal mesh
  52749. * @see https://doc.babylonjs.com/how_to/decals
  52750. */
  52751. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52752. position?: Vector3;
  52753. normal?: Vector3;
  52754. size?: Vector3;
  52755. angle?: number;
  52756. }): Mesh;
  52757. }
  52758. }
  52759. declare module "babylonjs/Meshes/meshSimplification" {
  52760. import { Mesh } from "babylonjs/Meshes/mesh";
  52761. /**
  52762. * A simplifier interface for future simplification implementations
  52763. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52764. */
  52765. export interface ISimplifier {
  52766. /**
  52767. * Simplification of a given mesh according to the given settings.
  52768. * Since this requires computation, it is assumed that the function runs async.
  52769. * @param settings The settings of the simplification, including quality and distance
  52770. * @param successCallback A callback that will be called after the mesh was simplified.
  52771. * @param errorCallback in case of an error, this callback will be called. optional.
  52772. */
  52773. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52774. }
  52775. /**
  52776. * Expected simplification settings.
  52777. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52778. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52779. */
  52780. export interface ISimplificationSettings {
  52781. /**
  52782. * Gets or sets the expected quality
  52783. */
  52784. quality: number;
  52785. /**
  52786. * Gets or sets the distance when this optimized version should be used
  52787. */
  52788. distance: number;
  52789. /**
  52790. * Gets an already optimized mesh
  52791. */
  52792. optimizeMesh?: boolean;
  52793. }
  52794. /**
  52795. * Class used to specify simplification options
  52796. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52797. */
  52798. export class SimplificationSettings implements ISimplificationSettings {
  52799. /** expected quality */
  52800. quality: number;
  52801. /** distance when this optimized version should be used */
  52802. distance: number;
  52803. /** already optimized mesh */
  52804. optimizeMesh?: boolean | undefined;
  52805. /**
  52806. * Creates a SimplificationSettings
  52807. * @param quality expected quality
  52808. * @param distance distance when this optimized version should be used
  52809. * @param optimizeMesh already optimized mesh
  52810. */
  52811. constructor(
  52812. /** expected quality */
  52813. quality: number,
  52814. /** distance when this optimized version should be used */
  52815. distance: number,
  52816. /** already optimized mesh */
  52817. optimizeMesh?: boolean | undefined);
  52818. }
  52819. /**
  52820. * Interface used to define a simplification task
  52821. */
  52822. export interface ISimplificationTask {
  52823. /**
  52824. * Array of settings
  52825. */
  52826. settings: Array<ISimplificationSettings>;
  52827. /**
  52828. * Simplification type
  52829. */
  52830. simplificationType: SimplificationType;
  52831. /**
  52832. * Mesh to simplify
  52833. */
  52834. mesh: Mesh;
  52835. /**
  52836. * Callback called on success
  52837. */
  52838. successCallback?: () => void;
  52839. /**
  52840. * Defines if parallel processing can be used
  52841. */
  52842. parallelProcessing: boolean;
  52843. }
  52844. /**
  52845. * Queue used to order the simplification tasks
  52846. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52847. */
  52848. export class SimplificationQueue {
  52849. private _simplificationArray;
  52850. /**
  52851. * Gets a boolean indicating that the process is still running
  52852. */
  52853. running: boolean;
  52854. /**
  52855. * Creates a new queue
  52856. */
  52857. constructor();
  52858. /**
  52859. * Adds a new simplification task
  52860. * @param task defines a task to add
  52861. */
  52862. addTask(task: ISimplificationTask): void;
  52863. /**
  52864. * Execute next task
  52865. */
  52866. executeNext(): void;
  52867. /**
  52868. * Execute a simplification task
  52869. * @param task defines the task to run
  52870. */
  52871. runSimplification(task: ISimplificationTask): void;
  52872. private getSimplifier;
  52873. }
  52874. /**
  52875. * The implemented types of simplification
  52876. * At the moment only Quadratic Error Decimation is implemented
  52877. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52878. */
  52879. export enum SimplificationType {
  52880. /** Quadratic error decimation */
  52881. QUADRATIC = 0
  52882. }
  52883. }
  52884. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  52885. import { Scene } from "babylonjs/scene";
  52886. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  52887. import { ISceneComponent } from "babylonjs/sceneComponent";
  52888. module "babylonjs/scene" {
  52889. interface Scene {
  52890. /** @hidden (Backing field) */
  52891. _simplificationQueue: SimplificationQueue;
  52892. /**
  52893. * Gets or sets the simplification queue attached to the scene
  52894. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52895. */
  52896. simplificationQueue: SimplificationQueue;
  52897. }
  52898. }
  52899. module "babylonjs/Meshes/mesh" {
  52900. interface Mesh {
  52901. /**
  52902. * Simplify the mesh according to the given array of settings.
  52903. * Function will return immediately and will simplify async
  52904. * @param settings a collection of simplification settings
  52905. * @param parallelProcessing should all levels calculate parallel or one after the other
  52906. * @param simplificationType the type of simplification to run
  52907. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52908. * @returns the current mesh
  52909. */
  52910. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52911. }
  52912. }
  52913. /**
  52914. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52915. * created in a scene
  52916. */
  52917. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52918. /**
  52919. * The component name helpfull to identify the component in the list of scene components.
  52920. */
  52921. readonly name: string;
  52922. /**
  52923. * The scene the component belongs to.
  52924. */
  52925. scene: Scene;
  52926. /**
  52927. * Creates a new instance of the component for the given scene
  52928. * @param scene Defines the scene to register the component in
  52929. */
  52930. constructor(scene: Scene);
  52931. /**
  52932. * Registers the component in a given scene
  52933. */
  52934. register(): void;
  52935. /**
  52936. * Rebuilds the elements related to this component in case of
  52937. * context lost for instance.
  52938. */
  52939. rebuild(): void;
  52940. /**
  52941. * Disposes the component and the associated ressources
  52942. */
  52943. dispose(): void;
  52944. private _beforeCameraUpdate;
  52945. }
  52946. }
  52947. declare module "babylonjs/Meshes/Builders/index" {
  52948. export * from "babylonjs/Meshes/Builders/boxBuilder";
  52949. export * from "babylonjs/Meshes/Builders/discBuilder";
  52950. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  52951. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  52952. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  52953. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  52954. export * from "babylonjs/Meshes/Builders/torusBuilder";
  52955. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  52956. export * from "babylonjs/Meshes/Builders/linesBuilder";
  52957. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  52958. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  52959. export * from "babylonjs/Meshes/Builders/latheBuilder";
  52960. export * from "babylonjs/Meshes/Builders/planeBuilder";
  52961. export * from "babylonjs/Meshes/Builders/groundBuilder";
  52962. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  52963. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  52964. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  52965. export * from "babylonjs/Meshes/Builders/decalBuilder";
  52966. }
  52967. declare module "babylonjs/Meshes/index" {
  52968. export * from "babylonjs/Meshes/abstractMesh";
  52969. export * from "babylonjs/Meshes/buffer";
  52970. export * from "babylonjs/Meshes/Compression/index";
  52971. export * from "babylonjs/Meshes/csg";
  52972. export * from "babylonjs/Meshes/geometry";
  52973. export * from "babylonjs/Meshes/groundMesh";
  52974. export * from "babylonjs/Meshes/trailMesh";
  52975. export * from "babylonjs/Meshes/instancedMesh";
  52976. export * from "babylonjs/Meshes/linesMesh";
  52977. export * from "babylonjs/Meshes/mesh";
  52978. export * from "babylonjs/Meshes/mesh.vertexData";
  52979. export * from "babylonjs/Meshes/meshBuilder";
  52980. export * from "babylonjs/Meshes/meshSimplification";
  52981. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  52982. export * from "babylonjs/Meshes/polygonMesh";
  52983. export * from "babylonjs/Meshes/subMesh";
  52984. export * from "babylonjs/Meshes/transformNode";
  52985. export * from "babylonjs/Meshes/Builders/index";
  52986. }
  52987. declare module "babylonjs/Morph/index" {
  52988. export * from "babylonjs/Morph/morphTarget";
  52989. export * from "babylonjs/Morph/morphTargetManager";
  52990. }
  52991. declare module "babylonjs/Offline/database" {
  52992. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  52993. /**
  52994. * Class used to enable access to IndexedDB
  52995. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52996. */
  52997. export class Database implements IOfflineProvider {
  52998. private _callbackManifestChecked;
  52999. private _currentSceneUrl;
  53000. private _db;
  53001. private _enableSceneOffline;
  53002. private _enableTexturesOffline;
  53003. private _manifestVersionFound;
  53004. private _mustUpdateRessources;
  53005. private _hasReachedQuota;
  53006. private _isSupported;
  53007. private _idbFactory;
  53008. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53009. private static IsUASupportingBlobStorage;
  53010. /**
  53011. * Gets a boolean indicating if Database storate is enabled (off by default)
  53012. */
  53013. static IDBStorageEnabled: boolean;
  53014. /**
  53015. * Gets a boolean indicating if scene must be saved in the database
  53016. */
  53017. readonly enableSceneOffline: boolean;
  53018. /**
  53019. * Gets a boolean indicating if textures must be saved in the database
  53020. */
  53021. readonly enableTexturesOffline: boolean;
  53022. /**
  53023. * Creates a new Database
  53024. * @param urlToScene defines the url to load the scene
  53025. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53026. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53027. */
  53028. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53029. private static _ParseURL;
  53030. private static _ReturnFullUrlLocation;
  53031. private _checkManifestFile;
  53032. /**
  53033. * Open the database and make it available
  53034. * @param successCallback defines the callback to call on success
  53035. * @param errorCallback defines the callback to call on error
  53036. */
  53037. open(successCallback: () => void, errorCallback: () => void): void;
  53038. /**
  53039. * Loads an image from the database
  53040. * @param url defines the url to load from
  53041. * @param image defines the target DOM image
  53042. */
  53043. loadImage(url: string, image: HTMLImageElement): void;
  53044. private _loadImageFromDBAsync;
  53045. private _saveImageIntoDBAsync;
  53046. private _checkVersionFromDB;
  53047. private _loadVersionFromDBAsync;
  53048. private _saveVersionIntoDBAsync;
  53049. /**
  53050. * Loads a file from database
  53051. * @param url defines the URL to load from
  53052. * @param sceneLoaded defines a callback to call on success
  53053. * @param progressCallBack defines a callback to call when progress changed
  53054. * @param errorCallback defines a callback to call on error
  53055. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53056. */
  53057. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53058. private _loadFileAsync;
  53059. private _saveFileAsync;
  53060. /**
  53061. * Validates if xhr data is correct
  53062. * @param xhr defines the request to validate
  53063. * @param dataType defines the expected data type
  53064. * @returns true if data is correct
  53065. */
  53066. private static _ValidateXHRData;
  53067. }
  53068. }
  53069. declare module "babylonjs/Offline/index" {
  53070. export * from "babylonjs/Offline/database";
  53071. export * from "babylonjs/Offline/IOfflineProvider";
  53072. }
  53073. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53074. /** @hidden */
  53075. export var gpuUpdateParticlesPixelShader: {
  53076. name: string;
  53077. shader: string;
  53078. };
  53079. }
  53080. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53081. /** @hidden */
  53082. export var gpuUpdateParticlesVertexShader: {
  53083. name: string;
  53084. shader: string;
  53085. };
  53086. }
  53087. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53088. /** @hidden */
  53089. export var clipPlaneFragmentDeclaration2: {
  53090. name: string;
  53091. shader: string;
  53092. };
  53093. }
  53094. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53095. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53096. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53097. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53098. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53099. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53100. /** @hidden */
  53101. export var gpuRenderParticlesPixelShader: {
  53102. name: string;
  53103. shader: string;
  53104. };
  53105. }
  53106. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53107. /** @hidden */
  53108. export var clipPlaneVertexDeclaration2: {
  53109. name: string;
  53110. shader: string;
  53111. };
  53112. }
  53113. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53114. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53115. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53116. /** @hidden */
  53117. export var gpuRenderParticlesVertexShader: {
  53118. name: string;
  53119. shader: string;
  53120. };
  53121. }
  53122. declare module "babylonjs/Particles/gpuParticleSystem" {
  53123. import { Nullable } from "babylonjs/types";
  53124. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53125. import { Observable } from "babylonjs/Misc/observable";
  53126. import { Color4, Color3 } from "babylonjs/Maths/math";
  53127. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53128. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53129. import { Scene, IDisposable } from "babylonjs/scene";
  53130. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53131. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53132. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53133. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53134. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53135. /**
  53136. * This represents a GPU particle system in Babylon
  53137. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53138. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53139. */
  53140. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53141. /**
  53142. * The layer mask we are rendering the particles through.
  53143. */
  53144. layerMask: number;
  53145. private _capacity;
  53146. private _activeCount;
  53147. private _currentActiveCount;
  53148. private _accumulatedCount;
  53149. private _renderEffect;
  53150. private _updateEffect;
  53151. private _buffer0;
  53152. private _buffer1;
  53153. private _spriteBuffer;
  53154. private _updateVAO;
  53155. private _renderVAO;
  53156. private _targetIndex;
  53157. private _sourceBuffer;
  53158. private _targetBuffer;
  53159. private _engine;
  53160. private _currentRenderId;
  53161. private _started;
  53162. private _stopped;
  53163. private _timeDelta;
  53164. private _randomTexture;
  53165. private _randomTexture2;
  53166. private _attributesStrideSize;
  53167. private _updateEffectOptions;
  53168. private _randomTextureSize;
  53169. private _actualFrame;
  53170. private readonly _rawTextureWidth;
  53171. /**
  53172. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53173. */
  53174. static readonly IsSupported: boolean;
  53175. /**
  53176. * An event triggered when the system is disposed.
  53177. */
  53178. onDisposeObservable: Observable<GPUParticleSystem>;
  53179. /**
  53180. * Gets the maximum number of particles active at the same time.
  53181. * @returns The max number of active particles.
  53182. */
  53183. getCapacity(): number;
  53184. /**
  53185. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53186. * to override the particles.
  53187. */
  53188. forceDepthWrite: boolean;
  53189. /**
  53190. * Gets or set the number of active particles
  53191. */
  53192. activeParticleCount: number;
  53193. private _preWarmDone;
  53194. /**
  53195. * Is this system ready to be used/rendered
  53196. * @return true if the system is ready
  53197. */
  53198. isReady(): boolean;
  53199. /**
  53200. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53201. * @returns True if it has been started, otherwise false.
  53202. */
  53203. isStarted(): boolean;
  53204. /**
  53205. * Starts the particle system and begins to emit
  53206. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53207. */
  53208. start(delay?: number): void;
  53209. /**
  53210. * Stops the particle system.
  53211. */
  53212. stop(): void;
  53213. /**
  53214. * Remove all active particles
  53215. */
  53216. reset(): void;
  53217. /**
  53218. * Returns the string "GPUParticleSystem"
  53219. * @returns a string containing the class name
  53220. */
  53221. getClassName(): string;
  53222. private _colorGradientsTexture;
  53223. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53224. /**
  53225. * Adds a new color gradient
  53226. * @param gradient defines the gradient to use (between 0 and 1)
  53227. * @param color1 defines the color to affect to the specified gradient
  53228. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53229. * @returns the current particle system
  53230. */
  53231. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53232. /**
  53233. * Remove a specific color gradient
  53234. * @param gradient defines the gradient to remove
  53235. * @returns the current particle system
  53236. */
  53237. removeColorGradient(gradient: number): GPUParticleSystem;
  53238. private _angularSpeedGradientsTexture;
  53239. private _sizeGradientsTexture;
  53240. private _velocityGradientsTexture;
  53241. private _limitVelocityGradientsTexture;
  53242. private _dragGradientsTexture;
  53243. private _addFactorGradient;
  53244. /**
  53245. * Adds a new size gradient
  53246. * @param gradient defines the gradient to use (between 0 and 1)
  53247. * @param factor defines the size factor to affect to the specified gradient
  53248. * @returns the current particle system
  53249. */
  53250. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53251. /**
  53252. * Remove a specific size gradient
  53253. * @param gradient defines the gradient to remove
  53254. * @returns the current particle system
  53255. */
  53256. removeSizeGradient(gradient: number): GPUParticleSystem;
  53257. /**
  53258. * Adds a new angular speed gradient
  53259. * @param gradient defines the gradient to use (between 0 and 1)
  53260. * @param factor defines the angular speed to affect to the specified gradient
  53261. * @returns the current particle system
  53262. */
  53263. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53264. /**
  53265. * Remove a specific angular speed gradient
  53266. * @param gradient defines the gradient to remove
  53267. * @returns the current particle system
  53268. */
  53269. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53270. /**
  53271. * Adds a new velocity gradient
  53272. * @param gradient defines the gradient to use (between 0 and 1)
  53273. * @param factor defines the velocity to affect to the specified gradient
  53274. * @returns the current particle system
  53275. */
  53276. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53277. /**
  53278. * Remove a specific velocity gradient
  53279. * @param gradient defines the gradient to remove
  53280. * @returns the current particle system
  53281. */
  53282. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53283. /**
  53284. * Adds a new limit velocity gradient
  53285. * @param gradient defines the gradient to use (between 0 and 1)
  53286. * @param factor defines the limit velocity value to affect to the specified gradient
  53287. * @returns the current particle system
  53288. */
  53289. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53290. /**
  53291. * Remove a specific limit velocity gradient
  53292. * @param gradient defines the gradient to remove
  53293. * @returns the current particle system
  53294. */
  53295. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53296. /**
  53297. * Adds a new drag gradient
  53298. * @param gradient defines the gradient to use (between 0 and 1)
  53299. * @param factor defines the drag value to affect to the specified gradient
  53300. * @returns the current particle system
  53301. */
  53302. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53303. /**
  53304. * Remove a specific drag gradient
  53305. * @param gradient defines the gradient to remove
  53306. * @returns the current particle system
  53307. */
  53308. removeDragGradient(gradient: number): GPUParticleSystem;
  53309. /**
  53310. * Not supported by GPUParticleSystem
  53311. * @param gradient defines the gradient to use (between 0 and 1)
  53312. * @param factor defines the emit rate value to affect to the specified gradient
  53313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53314. * @returns the current particle system
  53315. */
  53316. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53317. /**
  53318. * Not supported by GPUParticleSystem
  53319. * @param gradient defines the gradient to remove
  53320. * @returns the current particle system
  53321. */
  53322. removeEmitRateGradient(gradient: number): IParticleSystem;
  53323. /**
  53324. * Not supported by GPUParticleSystem
  53325. * @param gradient defines the gradient to use (between 0 and 1)
  53326. * @param factor defines the start size value to affect to the specified gradient
  53327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53328. * @returns the current particle system
  53329. */
  53330. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53331. /**
  53332. * Not supported by GPUParticleSystem
  53333. * @param gradient defines the gradient to remove
  53334. * @returns the current particle system
  53335. */
  53336. removeStartSizeGradient(gradient: number): IParticleSystem;
  53337. /**
  53338. * Not supported by GPUParticleSystem
  53339. * @param gradient defines the gradient to use (between 0 and 1)
  53340. * @param min defines the color remap minimal range
  53341. * @param max defines the color remap maximal range
  53342. * @returns the current particle system
  53343. */
  53344. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53345. /**
  53346. * Not supported by GPUParticleSystem
  53347. * @param gradient defines the gradient to remove
  53348. * @returns the current particle system
  53349. */
  53350. removeColorRemapGradient(): IParticleSystem;
  53351. /**
  53352. * Not supported by GPUParticleSystem
  53353. * @param gradient defines the gradient to use (between 0 and 1)
  53354. * @param min defines the alpha remap minimal range
  53355. * @param max defines the alpha remap maximal range
  53356. * @returns the current particle system
  53357. */
  53358. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53359. /**
  53360. * Not supported by GPUParticleSystem
  53361. * @param gradient defines the gradient to remove
  53362. * @returns the current particle system
  53363. */
  53364. removeAlphaRemapGradient(): IParticleSystem;
  53365. /**
  53366. * Not supported by GPUParticleSystem
  53367. * @param gradient defines the gradient to use (between 0 and 1)
  53368. * @param color defines the color to affect to the specified gradient
  53369. * @returns the current particle system
  53370. */
  53371. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53372. /**
  53373. * Not supported by GPUParticleSystem
  53374. * @param gradient defines the gradient to remove
  53375. * @returns the current particle system
  53376. */
  53377. removeRampGradient(): IParticleSystem;
  53378. /**
  53379. * Not supported by GPUParticleSystem
  53380. * @returns the list of ramp gradients
  53381. */
  53382. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53383. /**
  53384. * Not supported by GPUParticleSystem
  53385. * Gets or sets a boolean indicating that ramp gradients must be used
  53386. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53387. */
  53388. useRampGradients: boolean;
  53389. /**
  53390. * Not supported by GPUParticleSystem
  53391. * @param gradient defines the gradient to use (between 0 and 1)
  53392. * @param factor defines the life time factor to affect to the specified gradient
  53393. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53394. * @returns the current particle system
  53395. */
  53396. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53397. /**
  53398. * Not supported by GPUParticleSystem
  53399. * @param gradient defines the gradient to remove
  53400. * @returns the current particle system
  53401. */
  53402. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53403. /**
  53404. * Instantiates a GPU particle system.
  53405. * 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.
  53406. * @param name The name of the particle system
  53407. * @param options The options used to create the system
  53408. * @param scene The scene the particle system belongs to
  53409. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53410. */
  53411. constructor(name: string, options: Partial<{
  53412. capacity: number;
  53413. randomTextureSize: number;
  53414. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53415. protected _reset(): void;
  53416. private _createUpdateVAO;
  53417. private _createRenderVAO;
  53418. private _initialize;
  53419. /** @hidden */
  53420. _recreateUpdateEffect(): void;
  53421. /** @hidden */
  53422. _recreateRenderEffect(): void;
  53423. /**
  53424. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53425. * @param preWarm defines if we are in the pre-warmimg phase
  53426. */
  53427. animate(preWarm?: boolean): void;
  53428. private _createFactorGradientTexture;
  53429. private _createSizeGradientTexture;
  53430. private _createAngularSpeedGradientTexture;
  53431. private _createVelocityGradientTexture;
  53432. private _createLimitVelocityGradientTexture;
  53433. private _createDragGradientTexture;
  53434. private _createColorGradientTexture;
  53435. /**
  53436. * Renders the particle system in its current state
  53437. * @param preWarm defines if the system should only update the particles but not render them
  53438. * @returns the current number of particles
  53439. */
  53440. render(preWarm?: boolean): number;
  53441. /**
  53442. * Rebuilds the particle system
  53443. */
  53444. rebuild(): void;
  53445. private _releaseBuffers;
  53446. private _releaseVAOs;
  53447. /**
  53448. * Disposes the particle system and free the associated resources
  53449. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53450. */
  53451. dispose(disposeTexture?: boolean): void;
  53452. /**
  53453. * Clones the particle system.
  53454. * @param name The name of the cloned object
  53455. * @param newEmitter The new emitter to use
  53456. * @returns the cloned particle system
  53457. */
  53458. clone(name: string, newEmitter: any): GPUParticleSystem;
  53459. /**
  53460. * Serializes the particle system to a JSON object.
  53461. * @returns the JSON object
  53462. */
  53463. serialize(): any;
  53464. /**
  53465. * Parses a JSON object to create a GPU particle system.
  53466. * @param parsedParticleSystem The JSON object to parse
  53467. * @param scene The scene to create the particle system in
  53468. * @param rootUrl The root url to use to load external dependencies like texture
  53469. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53470. * @returns the parsed GPU particle system
  53471. */
  53472. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53473. }
  53474. }
  53475. declare module "babylonjs/Particles/particleSystemSet" {
  53476. import { Nullable } from "babylonjs/types";
  53477. import { Color3 } from "babylonjs/Maths/math";
  53478. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53480. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53481. import { Scene, IDisposable } from "babylonjs/scene";
  53482. /**
  53483. * Represents a set of particle systems working together to create a specific effect
  53484. */
  53485. export class ParticleSystemSet implements IDisposable {
  53486. private _emitterCreationOptions;
  53487. private _emitterNode;
  53488. /**
  53489. * Gets the particle system list
  53490. */
  53491. systems: IParticleSystem[];
  53492. /**
  53493. * Gets the emitter node used with this set
  53494. */
  53495. readonly emitterNode: Nullable<TransformNode>;
  53496. /**
  53497. * Creates a new emitter mesh as a sphere
  53498. * @param options defines the options used to create the sphere
  53499. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53500. * @param scene defines the hosting scene
  53501. */
  53502. setEmitterAsSphere(options: {
  53503. diameter: number;
  53504. segments: number;
  53505. color: Color3;
  53506. }, renderingGroupId: number, scene: Scene): void;
  53507. /**
  53508. * Starts all particle systems of the set
  53509. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53510. */
  53511. start(emitter?: AbstractMesh): void;
  53512. /**
  53513. * Release all associated resources
  53514. */
  53515. dispose(): void;
  53516. /**
  53517. * Serialize the set into a JSON compatible object
  53518. * @returns a JSON compatible representation of the set
  53519. */
  53520. serialize(): any;
  53521. /**
  53522. * Parse a new ParticleSystemSet from a serialized source
  53523. * @param data defines a JSON compatible representation of the set
  53524. * @param scene defines the hosting scene
  53525. * @param gpu defines if we want GPU particles or CPU particles
  53526. * @returns a new ParticleSystemSet
  53527. */
  53528. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53529. }
  53530. }
  53531. declare module "babylonjs/Particles/particleHelper" {
  53532. import { Nullable } from "babylonjs/types";
  53533. import { Scene } from "babylonjs/scene";
  53534. import { Vector3 } from "babylonjs/Maths/math";
  53535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53536. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53537. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53538. /**
  53539. * This class is made for on one-liner static method to help creating particle system set.
  53540. */
  53541. export class ParticleHelper {
  53542. /**
  53543. * Gets or sets base Assets URL
  53544. */
  53545. static BaseAssetsUrl: string;
  53546. /**
  53547. * Create a default particle system that you can tweak
  53548. * @param emitter defines the emitter to use
  53549. * @param capacity defines the system capacity (default is 500 particles)
  53550. * @param scene defines the hosting scene
  53551. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53552. * @returns the new Particle system
  53553. */
  53554. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53555. /**
  53556. * This is the main static method (one-liner) of this helper to create different particle systems
  53557. * @param type This string represents the type to the particle system to create
  53558. * @param scene The scene where the particle system should live
  53559. * @param gpu If the system will use gpu
  53560. * @returns the ParticleSystemSet created
  53561. */
  53562. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53563. /**
  53564. * Static function used to export a particle system to a ParticleSystemSet variable.
  53565. * Please note that the emitter shape is not exported
  53566. * @param systems defines the particle systems to export
  53567. * @returns the created particle system set
  53568. */
  53569. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53570. }
  53571. }
  53572. declare module "babylonjs/Particles/particleSystemComponent" {
  53573. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53574. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53575. import "babylonjs/Shaders/particles.vertex";
  53576. module "babylonjs/Engines/engine" {
  53577. interface Engine {
  53578. /**
  53579. * Create an effect to use with particle systems.
  53580. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53581. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53582. * @param uniformsNames defines a list of attribute names
  53583. * @param samplers defines an array of string used to represent textures
  53584. * @param defines defines the string containing the defines to use to compile the shaders
  53585. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53586. * @param onCompiled defines a function to call when the effect creation is successful
  53587. * @param onError defines a function to call when the effect creation has failed
  53588. * @returns the new Effect
  53589. */
  53590. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53591. }
  53592. }
  53593. module "babylonjs/Meshes/mesh" {
  53594. interface Mesh {
  53595. /**
  53596. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53597. * @returns an array of IParticleSystem
  53598. */
  53599. getEmittedParticleSystems(): IParticleSystem[];
  53600. /**
  53601. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53602. * @returns an array of IParticleSystem
  53603. */
  53604. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53605. }
  53606. }
  53607. /**
  53608. * @hidden
  53609. */
  53610. export var _IDoNeedToBeInTheBuild: number;
  53611. }
  53612. declare module "babylonjs/Particles/index" {
  53613. export * from "babylonjs/Particles/baseParticleSystem";
  53614. export * from "babylonjs/Particles/EmitterTypes/index";
  53615. export * from "babylonjs/Particles/gpuParticleSystem";
  53616. export * from "babylonjs/Particles/IParticleSystem";
  53617. export * from "babylonjs/Particles/particle";
  53618. export * from "babylonjs/Particles/particleHelper";
  53619. export * from "babylonjs/Particles/particleSystem";
  53620. export * from "babylonjs/Particles/particleSystemComponent";
  53621. export * from "babylonjs/Particles/particleSystemSet";
  53622. export * from "babylonjs/Particles/solidParticle";
  53623. export * from "babylonjs/Particles/solidParticleSystem";
  53624. export * from "babylonjs/Particles/subEmitter";
  53625. }
  53626. declare module "babylonjs/Physics/physicsEngineComponent" {
  53627. import { Nullable } from "babylonjs/types";
  53628. import { Observable, Observer } from "babylonjs/Misc/observable";
  53629. import { Vector3 } from "babylonjs/Maths/math";
  53630. import { Mesh } from "babylonjs/Meshes/mesh";
  53631. import { ISceneComponent } from "babylonjs/sceneComponent";
  53632. import { Scene } from "babylonjs/scene";
  53633. import { Node } from "babylonjs/node";
  53634. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53635. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53636. module "babylonjs/scene" {
  53637. interface Scene {
  53638. /** @hidden (Backing field) */
  53639. _physicsEngine: Nullable<IPhysicsEngine>;
  53640. /**
  53641. * Gets the current physics engine
  53642. * @returns a IPhysicsEngine or null if none attached
  53643. */
  53644. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53645. /**
  53646. * Enables physics to the current scene
  53647. * @param gravity defines the scene's gravity for the physics engine
  53648. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53649. * @return a boolean indicating if the physics engine was initialized
  53650. */
  53651. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53652. /**
  53653. * Disables and disposes the physics engine associated with the scene
  53654. */
  53655. disablePhysicsEngine(): void;
  53656. /**
  53657. * Gets a boolean indicating if there is an active physics engine
  53658. * @returns a boolean indicating if there is an active physics engine
  53659. */
  53660. isPhysicsEnabled(): boolean;
  53661. /**
  53662. * Deletes a physics compound impostor
  53663. * @param compound defines the compound to delete
  53664. */
  53665. deleteCompoundImpostor(compound: any): void;
  53666. /**
  53667. * An event triggered when physic simulation is about to be run
  53668. */
  53669. onBeforePhysicsObservable: Observable<Scene>;
  53670. /**
  53671. * An event triggered when physic simulation has been done
  53672. */
  53673. onAfterPhysicsObservable: Observable<Scene>;
  53674. }
  53675. }
  53676. module "babylonjs/Meshes/abstractMesh" {
  53677. interface AbstractMesh {
  53678. /** @hidden */
  53679. _physicsImpostor: Nullable<PhysicsImpostor>;
  53680. /**
  53681. * Gets or sets impostor used for physic simulation
  53682. * @see http://doc.babylonjs.com/features/physics_engine
  53683. */
  53684. physicsImpostor: Nullable<PhysicsImpostor>;
  53685. /**
  53686. * Gets the current physics impostor
  53687. * @see http://doc.babylonjs.com/features/physics_engine
  53688. * @returns a physics impostor or null
  53689. */
  53690. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53691. /** Apply a physic impulse to the mesh
  53692. * @param force defines the force to apply
  53693. * @param contactPoint defines where to apply the force
  53694. * @returns the current mesh
  53695. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53696. */
  53697. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53698. /**
  53699. * Creates a physic joint between two meshes
  53700. * @param otherMesh defines the other mesh to use
  53701. * @param pivot1 defines the pivot to use on this mesh
  53702. * @param pivot2 defines the pivot to use on the other mesh
  53703. * @param options defines additional options (can be plugin dependent)
  53704. * @returns the current mesh
  53705. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53706. */
  53707. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53708. /** @hidden */
  53709. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53710. }
  53711. }
  53712. /**
  53713. * Defines the physics engine scene component responsible to manage a physics engine
  53714. */
  53715. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53716. /**
  53717. * The component name helpful to identify the component in the list of scene components.
  53718. */
  53719. readonly name: string;
  53720. /**
  53721. * The scene the component belongs to.
  53722. */
  53723. scene: Scene;
  53724. /**
  53725. * Creates a new instance of the component for the given scene
  53726. * @param scene Defines the scene to register the component in
  53727. */
  53728. constructor(scene: Scene);
  53729. /**
  53730. * Registers the component in a given scene
  53731. */
  53732. register(): void;
  53733. /**
  53734. * Rebuilds the elements related to this component in case of
  53735. * context lost for instance.
  53736. */
  53737. rebuild(): void;
  53738. /**
  53739. * Disposes the component and the associated ressources
  53740. */
  53741. dispose(): void;
  53742. }
  53743. }
  53744. declare module "babylonjs/Physics/physicsHelper" {
  53745. import { Nullable } from "babylonjs/types";
  53746. import { Vector3 } from "babylonjs/Maths/math";
  53747. import { Mesh } from "babylonjs/Meshes/mesh";
  53748. import { Scene } from "babylonjs/scene";
  53749. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53750. /**
  53751. * A helper for physics simulations
  53752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53753. */
  53754. export class PhysicsHelper {
  53755. private _scene;
  53756. private _physicsEngine;
  53757. /**
  53758. * Initializes the Physics helper
  53759. * @param scene Babylon.js scene
  53760. */
  53761. constructor(scene: Scene);
  53762. /**
  53763. * Applies a radial explosion impulse
  53764. * @param origin the origin of the explosion
  53765. * @param radiusOrEventOptions the radius or the options of radial explosion
  53766. * @param strength the explosion strength
  53767. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53768. * @returns A physics radial explosion event, or null
  53769. */
  53770. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53771. /**
  53772. * Applies a radial explosion force
  53773. * @param origin the origin of the explosion
  53774. * @param radiusOrEventOptions the radius or the options of radial explosion
  53775. * @param strength the explosion strength
  53776. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53777. * @returns A physics radial explosion event, or null
  53778. */
  53779. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53780. /**
  53781. * Creates a gravitational field
  53782. * @param origin the origin of the explosion
  53783. * @param radiusOrEventOptions the radius or the options of radial explosion
  53784. * @param strength the explosion strength
  53785. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53786. * @returns A physics gravitational field event, or null
  53787. */
  53788. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53789. /**
  53790. * Creates a physics updraft event
  53791. * @param origin the origin of the updraft
  53792. * @param radiusOrEventOptions the radius or the options of the updraft
  53793. * @param strength the strength of the updraft
  53794. * @param height the height of the updraft
  53795. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53796. * @returns A physics updraft event, or null
  53797. */
  53798. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53799. /**
  53800. * Creates a physics vortex event
  53801. * @param origin the of the vortex
  53802. * @param radiusOrEventOptions the radius or the options of the vortex
  53803. * @param strength the strength of the vortex
  53804. * @param height the height of the vortex
  53805. * @returns a Physics vortex event, or null
  53806. * A physics vortex event or null
  53807. */
  53808. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53809. }
  53810. /**
  53811. * Represents a physics radial explosion event
  53812. */
  53813. class PhysicsRadialExplosionEvent {
  53814. private _scene;
  53815. private _options;
  53816. private _sphere;
  53817. private _dataFetched;
  53818. /**
  53819. * Initializes a radial explosioin event
  53820. * @param _scene BabylonJS scene
  53821. * @param _options The options for the vortex event
  53822. */
  53823. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53824. /**
  53825. * Returns the data related to the radial explosion event (sphere).
  53826. * @returns The radial explosion event data
  53827. */
  53828. getData(): PhysicsRadialExplosionEventData;
  53829. /**
  53830. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53831. * @param impostor A physics imposter
  53832. * @param origin the origin of the explosion
  53833. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53834. */
  53835. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53836. /**
  53837. * Triggers affecterd impostors callbacks
  53838. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53839. */
  53840. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53841. /**
  53842. * Disposes the sphere.
  53843. * @param force Specifies if the sphere should be disposed by force
  53844. */
  53845. dispose(force?: boolean): void;
  53846. /*** Helpers ***/
  53847. private _prepareSphere;
  53848. private _intersectsWithSphere;
  53849. }
  53850. /**
  53851. * Represents a gravitational field event
  53852. */
  53853. class PhysicsGravitationalFieldEvent {
  53854. private _physicsHelper;
  53855. private _scene;
  53856. private _origin;
  53857. private _options;
  53858. private _tickCallback;
  53859. private _sphere;
  53860. private _dataFetched;
  53861. /**
  53862. * Initializes the physics gravitational field event
  53863. * @param _physicsHelper A physics helper
  53864. * @param _scene BabylonJS scene
  53865. * @param _origin The origin position of the gravitational field event
  53866. * @param _options The options for the vortex event
  53867. */
  53868. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53869. /**
  53870. * Returns the data related to the gravitational field event (sphere).
  53871. * @returns A gravitational field event
  53872. */
  53873. getData(): PhysicsGravitationalFieldEventData;
  53874. /**
  53875. * Enables the gravitational field.
  53876. */
  53877. enable(): void;
  53878. /**
  53879. * Disables the gravitational field.
  53880. */
  53881. disable(): void;
  53882. /**
  53883. * Disposes the sphere.
  53884. * @param force The force to dispose from the gravitational field event
  53885. */
  53886. dispose(force?: boolean): void;
  53887. private _tick;
  53888. }
  53889. /**
  53890. * Represents a physics updraft event
  53891. */
  53892. class PhysicsUpdraftEvent {
  53893. private _scene;
  53894. private _origin;
  53895. private _options;
  53896. private _physicsEngine;
  53897. private _originTop;
  53898. private _originDirection;
  53899. private _tickCallback;
  53900. private _cylinder;
  53901. private _cylinderPosition;
  53902. private _dataFetched;
  53903. /**
  53904. * Initializes the physics updraft event
  53905. * @param _scene BabylonJS scene
  53906. * @param _origin The origin position of the updraft
  53907. * @param _options The options for the updraft event
  53908. */
  53909. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53910. /**
  53911. * Returns the data related to the updraft event (cylinder).
  53912. * @returns A physics updraft event
  53913. */
  53914. getData(): PhysicsUpdraftEventData;
  53915. /**
  53916. * Enables the updraft.
  53917. */
  53918. enable(): void;
  53919. /**
  53920. * Disables the updraft.
  53921. */
  53922. disable(): void;
  53923. /**
  53924. * Disposes the cylinder.
  53925. * @param force Specifies if the updraft should be disposed by force
  53926. */
  53927. dispose(force?: boolean): void;
  53928. private getImpostorHitData;
  53929. private _tick;
  53930. /*** Helpers ***/
  53931. private _prepareCylinder;
  53932. private _intersectsWithCylinder;
  53933. }
  53934. /**
  53935. * Represents a physics vortex event
  53936. */
  53937. class PhysicsVortexEvent {
  53938. private _scene;
  53939. private _origin;
  53940. private _options;
  53941. private _physicsEngine;
  53942. private _originTop;
  53943. private _tickCallback;
  53944. private _cylinder;
  53945. private _cylinderPosition;
  53946. private _dataFetched;
  53947. /**
  53948. * Initializes the physics vortex event
  53949. * @param _scene The BabylonJS scene
  53950. * @param _origin The origin position of the vortex
  53951. * @param _options The options for the vortex event
  53952. */
  53953. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53954. /**
  53955. * Returns the data related to the vortex event (cylinder).
  53956. * @returns The physics vortex event data
  53957. */
  53958. getData(): PhysicsVortexEventData;
  53959. /**
  53960. * Enables the vortex.
  53961. */
  53962. enable(): void;
  53963. /**
  53964. * Disables the cortex.
  53965. */
  53966. disable(): void;
  53967. /**
  53968. * Disposes the sphere.
  53969. * @param force
  53970. */
  53971. dispose(force?: boolean): void;
  53972. private getImpostorHitData;
  53973. private _tick;
  53974. /*** Helpers ***/
  53975. private _prepareCylinder;
  53976. private _intersectsWithCylinder;
  53977. }
  53978. /**
  53979. * Options fot the radial explosion event
  53980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53981. */
  53982. export class PhysicsRadialExplosionEventOptions {
  53983. /**
  53984. * The radius of the sphere for the radial explosion.
  53985. */
  53986. radius: number;
  53987. /**
  53988. * The strenth of the explosion.
  53989. */
  53990. strength: number;
  53991. /**
  53992. * The strenght of the force in correspondence to the distance of the affected object
  53993. */
  53994. falloff: PhysicsRadialImpulseFalloff;
  53995. /**
  53996. * Sphere options for the radial explosion.
  53997. */
  53998. sphere: {
  53999. segments: number;
  54000. diameter: number;
  54001. };
  54002. /**
  54003. * Sphere options for the radial explosion.
  54004. */
  54005. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54006. }
  54007. /**
  54008. * Options fot the updraft event
  54009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54010. */
  54011. export class PhysicsUpdraftEventOptions {
  54012. /**
  54013. * The radius of the cylinder for the vortex
  54014. */
  54015. radius: number;
  54016. /**
  54017. * The strenth of the updraft.
  54018. */
  54019. strength: number;
  54020. /**
  54021. * The height of the cylinder for the updraft.
  54022. */
  54023. height: number;
  54024. /**
  54025. * The mode for the the updraft.
  54026. */
  54027. updraftMode: PhysicsUpdraftMode;
  54028. }
  54029. /**
  54030. * Options fot the vortex event
  54031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54032. */
  54033. export class PhysicsVortexEventOptions {
  54034. /**
  54035. * The radius of the cylinder for the vortex
  54036. */
  54037. radius: number;
  54038. /**
  54039. * The strenth of the vortex.
  54040. */
  54041. strength: number;
  54042. /**
  54043. * The height of the cylinder for the vortex.
  54044. */
  54045. height: number;
  54046. /**
  54047. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54048. */
  54049. centripetalForceThreshold: number;
  54050. /**
  54051. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54052. */
  54053. centripetalForceMultiplier: number;
  54054. /**
  54055. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54056. */
  54057. centrifugalForceMultiplier: number;
  54058. /**
  54059. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54060. */
  54061. updraftForceMultiplier: number;
  54062. }
  54063. /**
  54064. * The strenght of the force in correspondence to the distance of the affected object
  54065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54066. */
  54067. export enum PhysicsRadialImpulseFalloff {
  54068. /** Defines that impulse is constant in strength across it's whole radius */
  54069. Constant = 0,
  54070. /** Defines that impulse gets weaker if it's further from the origin */
  54071. Linear = 1
  54072. }
  54073. /**
  54074. * The strength of the force in correspondence to the distance of the affected object
  54075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54076. */
  54077. export enum PhysicsUpdraftMode {
  54078. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54079. Center = 0,
  54080. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54081. Perpendicular = 1
  54082. }
  54083. /**
  54084. * Interface for a physics hit data
  54085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54086. */
  54087. export interface PhysicsHitData {
  54088. /**
  54089. * The force applied at the contact point
  54090. */
  54091. force: Vector3;
  54092. /**
  54093. * The contact point
  54094. */
  54095. contactPoint: Vector3;
  54096. /**
  54097. * The distance from the origin to the contact point
  54098. */
  54099. distanceFromOrigin: number;
  54100. }
  54101. /**
  54102. * Interface for radial explosion event data
  54103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54104. */
  54105. export interface PhysicsRadialExplosionEventData {
  54106. /**
  54107. * A sphere used for the radial explosion event
  54108. */
  54109. sphere: Mesh;
  54110. }
  54111. /**
  54112. * Interface for gravitational field event data
  54113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54114. */
  54115. export interface PhysicsGravitationalFieldEventData {
  54116. /**
  54117. * A sphere mesh used for the gravitational field event
  54118. */
  54119. sphere: Mesh;
  54120. }
  54121. /**
  54122. * Interface for updraft event data
  54123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54124. */
  54125. export interface PhysicsUpdraftEventData {
  54126. /**
  54127. * A cylinder used for the updraft event
  54128. */
  54129. cylinder: Mesh;
  54130. }
  54131. /**
  54132. * Interface for vortex event data
  54133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54134. */
  54135. export interface PhysicsVortexEventData {
  54136. /**
  54137. * A cylinder used for the vortex event
  54138. */
  54139. cylinder: Mesh;
  54140. }
  54141. /**
  54142. * Interface for an affected physics impostor
  54143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54144. */
  54145. export interface PhysicsAffectedImpostorWithData {
  54146. /**
  54147. * The impostor affected by the effect
  54148. */
  54149. impostor: PhysicsImpostor;
  54150. /**
  54151. * The data about the hit/horce from the explosion
  54152. */
  54153. hitData: PhysicsHitData;
  54154. }
  54155. }
  54156. declare module "babylonjs/Physics/Plugins/index" {
  54157. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54158. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54159. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54160. }
  54161. declare module "babylonjs/Physics/index" {
  54162. export * from "babylonjs/Physics/IPhysicsEngine";
  54163. export * from "babylonjs/Physics/physicsEngine";
  54164. export * from "babylonjs/Physics/physicsEngineComponent";
  54165. export * from "babylonjs/Physics/physicsHelper";
  54166. export * from "babylonjs/Physics/physicsImpostor";
  54167. export * from "babylonjs/Physics/physicsJoint";
  54168. export * from "babylonjs/Physics/Plugins/index";
  54169. }
  54170. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54171. /** @hidden */
  54172. export var blackAndWhitePixelShader: {
  54173. name: string;
  54174. shader: string;
  54175. };
  54176. }
  54177. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54178. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54179. import { Camera } from "babylonjs/Cameras/camera";
  54180. import { Engine } from "babylonjs/Engines/engine";
  54181. import "babylonjs/Shaders/blackAndWhite.fragment";
  54182. /**
  54183. * Post process used to render in black and white
  54184. */
  54185. export class BlackAndWhitePostProcess extends PostProcess {
  54186. /**
  54187. * Linear about to convert he result to black and white (default: 1)
  54188. */
  54189. degree: number;
  54190. /**
  54191. * Creates a black and white post process
  54192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54193. * @param name The name of the effect.
  54194. * @param options The required width/height ratio to downsize to before computing the render pass.
  54195. * @param camera The camera to apply the render pass to.
  54196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54197. * @param engine The engine which the post process will be applied. (default: current engine)
  54198. * @param reusable If the post process can be reused on the same frame. (default: false)
  54199. */
  54200. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54201. }
  54202. }
  54203. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54204. import { Nullable } from "babylonjs/types";
  54205. import { Camera } from "babylonjs/Cameras/camera";
  54206. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54207. import { Engine } from "babylonjs/Engines/engine";
  54208. /**
  54209. * This represents a set of one or more post processes in Babylon.
  54210. * A post process can be used to apply a shader to a texture after it is rendered.
  54211. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54212. */
  54213. export class PostProcessRenderEffect {
  54214. private _postProcesses;
  54215. private _getPostProcesses;
  54216. private _singleInstance;
  54217. private _cameras;
  54218. private _indicesForCamera;
  54219. /**
  54220. * Name of the effect
  54221. * @hidden
  54222. */
  54223. _name: string;
  54224. /**
  54225. * Instantiates a post process render effect.
  54226. * A post process can be used to apply a shader to a texture after it is rendered.
  54227. * @param engine The engine the effect is tied to
  54228. * @param name The name of the effect
  54229. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54230. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54231. */
  54232. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54233. /**
  54234. * Checks if all the post processes in the effect are supported.
  54235. */
  54236. readonly isSupported: boolean;
  54237. /**
  54238. * Updates the current state of the effect
  54239. * @hidden
  54240. */
  54241. _update(): void;
  54242. /**
  54243. * Attaches the effect on cameras
  54244. * @param cameras The camera to attach to.
  54245. * @hidden
  54246. */
  54247. _attachCameras(cameras: Camera): void;
  54248. /**
  54249. * Attaches the effect on cameras
  54250. * @param cameras The camera to attach to.
  54251. * @hidden
  54252. */
  54253. _attachCameras(cameras: Camera[]): void;
  54254. /**
  54255. * Detatches the effect on cameras
  54256. * @param cameras The camera to detatch from.
  54257. * @hidden
  54258. */
  54259. _detachCameras(cameras: Camera): void;
  54260. /**
  54261. * Detatches the effect on cameras
  54262. * @param cameras The camera to detatch from.
  54263. * @hidden
  54264. */
  54265. _detachCameras(cameras: Camera[]): void;
  54266. /**
  54267. * Enables the effect on given cameras
  54268. * @param cameras The camera to enable.
  54269. * @hidden
  54270. */
  54271. _enable(cameras: Camera): void;
  54272. /**
  54273. * Enables the effect on given cameras
  54274. * @param cameras The camera to enable.
  54275. * @hidden
  54276. */
  54277. _enable(cameras: Nullable<Camera[]>): void;
  54278. /**
  54279. * Disables the effect on the given cameras
  54280. * @param cameras The camera to disable.
  54281. * @hidden
  54282. */
  54283. _disable(cameras: Camera): void;
  54284. /**
  54285. * Disables the effect on the given cameras
  54286. * @param cameras The camera to disable.
  54287. * @hidden
  54288. */
  54289. _disable(cameras: Nullable<Camera[]>): void;
  54290. /**
  54291. * Gets a list of the post processes contained in the effect.
  54292. * @param camera The camera to get the post processes on.
  54293. * @returns The list of the post processes in the effect.
  54294. */
  54295. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54296. }
  54297. }
  54298. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54299. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54300. /** @hidden */
  54301. export var extractHighlightsPixelShader: {
  54302. name: string;
  54303. shader: string;
  54304. };
  54305. }
  54306. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54307. import { Nullable } from "babylonjs/types";
  54308. import { Camera } from "babylonjs/Cameras/camera";
  54309. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54310. import { Engine } from "babylonjs/Engines/engine";
  54311. import "babylonjs/Shaders/extractHighlights.fragment";
  54312. /**
  54313. * 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.
  54314. */
  54315. export class ExtractHighlightsPostProcess extends PostProcess {
  54316. /**
  54317. * The luminance threshold, pixels below this value will be set to black.
  54318. */
  54319. threshold: number;
  54320. /** @hidden */
  54321. _exposure: number;
  54322. /**
  54323. * Post process which has the input texture to be used when performing highlight extraction
  54324. * @hidden
  54325. */
  54326. _inputPostProcess: Nullable<PostProcess>;
  54327. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54328. }
  54329. }
  54330. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54331. /** @hidden */
  54332. export var bloomMergePixelShader: {
  54333. name: string;
  54334. shader: string;
  54335. };
  54336. }
  54337. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54338. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54339. import { Nullable } from "babylonjs/types";
  54340. import { Engine } from "babylonjs/Engines/engine";
  54341. import { Camera } from "babylonjs/Cameras/camera";
  54342. import "babylonjs/Shaders/bloomMerge.fragment";
  54343. /**
  54344. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54345. */
  54346. export class BloomMergePostProcess extends PostProcess {
  54347. /** Weight of the bloom to be added to the original input. */
  54348. weight: number;
  54349. /**
  54350. * Creates a new instance of @see BloomMergePostProcess
  54351. * @param name The name of the effect.
  54352. * @param originalFromInput Post process which's input will be used for the merge.
  54353. * @param blurred Blurred highlights post process which's output will be used.
  54354. * @param weight Weight of the bloom to be added to the original input.
  54355. * @param options The required width/height ratio to downsize to before computing the render pass.
  54356. * @param camera The camera to apply the render pass to.
  54357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54358. * @param engine The engine which the post process will be applied. (default: current engine)
  54359. * @param reusable If the post process can be reused on the same frame. (default: false)
  54360. * @param textureType Type of textures used when performing the post process. (default: 0)
  54361. * @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)
  54362. */
  54363. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54364. /** Weight of the bloom to be added to the original input. */
  54365. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54366. }
  54367. }
  54368. declare module "babylonjs/PostProcesses/bloomEffect" {
  54369. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54370. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54371. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54372. import { Camera } from "babylonjs/Cameras/camera";
  54373. import { Scene } from "babylonjs/scene";
  54374. /**
  54375. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54376. */
  54377. export class BloomEffect extends PostProcessRenderEffect {
  54378. private bloomScale;
  54379. /**
  54380. * @hidden Internal
  54381. */
  54382. _effects: Array<PostProcess>;
  54383. /**
  54384. * @hidden Internal
  54385. */
  54386. _downscale: ExtractHighlightsPostProcess;
  54387. private _blurX;
  54388. private _blurY;
  54389. private _merge;
  54390. /**
  54391. * The luminance threshold to find bright areas of the image to bloom.
  54392. */
  54393. threshold: number;
  54394. /**
  54395. * The strength of the bloom.
  54396. */
  54397. weight: number;
  54398. /**
  54399. * Specifies the size of the bloom blur kernel, relative to the final output size
  54400. */
  54401. kernel: number;
  54402. /**
  54403. * Creates a new instance of @see BloomEffect
  54404. * @param scene The scene the effect belongs to.
  54405. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54406. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54407. * @param bloomWeight The the strength of bloom.
  54408. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54409. * @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)
  54410. */
  54411. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54412. /**
  54413. * Disposes each of the internal effects for a given camera.
  54414. * @param camera The camera to dispose the effect on.
  54415. */
  54416. disposeEffects(camera: Camera): void;
  54417. /**
  54418. * @hidden Internal
  54419. */
  54420. _updateEffects(): void;
  54421. /**
  54422. * Internal
  54423. * @returns if all the contained post processes are ready.
  54424. * @hidden
  54425. */
  54426. _isReady(): boolean;
  54427. }
  54428. }
  54429. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54430. /** @hidden */
  54431. export var chromaticAberrationPixelShader: {
  54432. name: string;
  54433. shader: string;
  54434. };
  54435. }
  54436. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54437. import { Vector2 } from "babylonjs/Maths/math";
  54438. import { Nullable } from "babylonjs/types";
  54439. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54440. import { Camera } from "babylonjs/Cameras/camera";
  54441. import { Engine } from "babylonjs/Engines/engine";
  54442. import "babylonjs/Shaders/chromaticAberration.fragment";
  54443. /**
  54444. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54445. */
  54446. export class ChromaticAberrationPostProcess extends PostProcess {
  54447. /**
  54448. * The amount of seperation of rgb channels (default: 30)
  54449. */
  54450. aberrationAmount: number;
  54451. /**
  54452. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54453. */
  54454. radialIntensity: number;
  54455. /**
  54456. * 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))
  54457. */
  54458. direction: Vector2;
  54459. /**
  54460. * 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))
  54461. */
  54462. centerPosition: Vector2;
  54463. /**
  54464. * Creates a new instance ChromaticAberrationPostProcess
  54465. * @param name The name of the effect.
  54466. * @param screenWidth The width of the screen to apply the effect on.
  54467. * @param screenHeight The height of the screen to apply the effect on.
  54468. * @param options The required width/height ratio to downsize to before computing the render pass.
  54469. * @param camera The camera to apply the render pass to.
  54470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54471. * @param engine The engine which the post process will be applied. (default: current engine)
  54472. * @param reusable If the post process can be reused on the same frame. (default: false)
  54473. * @param textureType Type of textures used when performing the post process. (default: 0)
  54474. * @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)
  54475. */
  54476. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54477. }
  54478. }
  54479. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54480. /** @hidden */
  54481. export var circleOfConfusionPixelShader: {
  54482. name: string;
  54483. shader: string;
  54484. };
  54485. }
  54486. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54487. import { Nullable } from "babylonjs/types";
  54488. import { Engine } from "babylonjs/Engines/engine";
  54489. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54490. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54491. import { Camera } from "babylonjs/Cameras/camera";
  54492. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54493. /**
  54494. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54495. */
  54496. export class CircleOfConfusionPostProcess extends PostProcess {
  54497. /**
  54498. * 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.
  54499. */
  54500. lensSize: number;
  54501. /**
  54502. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54503. */
  54504. fStop: number;
  54505. /**
  54506. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54507. */
  54508. focusDistance: number;
  54509. /**
  54510. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54511. */
  54512. focalLength: number;
  54513. private _depthTexture;
  54514. /**
  54515. * Creates a new instance CircleOfConfusionPostProcess
  54516. * @param name The name of the effect.
  54517. * @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.
  54518. * @param options The required width/height ratio to downsize to before computing the render pass.
  54519. * @param camera The camera to apply the render pass to.
  54520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54521. * @param engine The engine which the post process will be applied. (default: current engine)
  54522. * @param reusable If the post process can be reused on the same frame. (default: false)
  54523. * @param textureType Type of textures used when performing the post process. (default: 0)
  54524. * @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)
  54525. */
  54526. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54527. /**
  54528. * 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.
  54529. */
  54530. depthTexture: RenderTargetTexture;
  54531. }
  54532. }
  54533. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54534. /** @hidden */
  54535. export var colorCorrectionPixelShader: {
  54536. name: string;
  54537. shader: string;
  54538. };
  54539. }
  54540. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54541. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54542. import { Engine } from "babylonjs/Engines/engine";
  54543. import { Camera } from "babylonjs/Cameras/camera";
  54544. import "babylonjs/Shaders/colorCorrection.fragment";
  54545. /**
  54546. *
  54547. * This post-process allows the modification of rendered colors by using
  54548. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54549. *
  54550. * The object needs to be provided an url to a texture containing the color
  54551. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54552. * Use an image editing software to tweak the LUT to match your needs.
  54553. *
  54554. * For an example of a color LUT, see here:
  54555. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54556. * For explanations on color grading, see here:
  54557. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54558. *
  54559. */
  54560. export class ColorCorrectionPostProcess extends PostProcess {
  54561. private _colorTableTexture;
  54562. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54563. }
  54564. }
  54565. declare module "babylonjs/Shaders/convolution.fragment" {
  54566. /** @hidden */
  54567. export var convolutionPixelShader: {
  54568. name: string;
  54569. shader: string;
  54570. };
  54571. }
  54572. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54573. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54574. import { Nullable } from "babylonjs/types";
  54575. import { Camera } from "babylonjs/Cameras/camera";
  54576. import { Engine } from "babylonjs/Engines/engine";
  54577. import "babylonjs/Shaders/convolution.fragment";
  54578. /**
  54579. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54580. * input texture to perform effects such as edge detection or sharpening
  54581. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54582. */
  54583. export class ConvolutionPostProcess extends PostProcess {
  54584. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54585. kernel: number[];
  54586. /**
  54587. * Creates a new instance ConvolutionPostProcess
  54588. * @param name The name of the effect.
  54589. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54590. * @param options The required width/height ratio to downsize to before computing the render pass.
  54591. * @param camera The camera to apply the render pass to.
  54592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54593. * @param engine The engine which the post process will be applied. (default: current engine)
  54594. * @param reusable If the post process can be reused on the same frame. (default: false)
  54595. * @param textureType Type of textures used when performing the post process. (default: 0)
  54596. */
  54597. constructor(name: string,
  54598. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54599. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54600. /**
  54601. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54602. */
  54603. static EdgeDetect0Kernel: number[];
  54604. /**
  54605. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54606. */
  54607. static EdgeDetect1Kernel: number[];
  54608. /**
  54609. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54610. */
  54611. static EdgeDetect2Kernel: number[];
  54612. /**
  54613. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54614. */
  54615. static SharpenKernel: number[];
  54616. /**
  54617. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54618. */
  54619. static EmbossKernel: number[];
  54620. /**
  54621. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54622. */
  54623. static GaussianKernel: number[];
  54624. }
  54625. }
  54626. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54627. import { Nullable } from "babylonjs/types";
  54628. import { Vector2 } from "babylonjs/Maths/math";
  54629. import { Camera } from "babylonjs/Cameras/camera";
  54630. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54631. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54632. import { Engine } from "babylonjs/Engines/engine";
  54633. import { Scene } from "babylonjs/scene";
  54634. /**
  54635. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54636. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54637. * based on samples that have a large difference in distance than the center pixel.
  54638. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54639. */
  54640. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54641. direction: Vector2;
  54642. /**
  54643. * Creates a new instance CircleOfConfusionPostProcess
  54644. * @param name The name of the effect.
  54645. * @param scene The scene the effect belongs to.
  54646. * @param direction The direction the blur should be applied.
  54647. * @param kernel The size of the kernel used to blur.
  54648. * @param options The required width/height ratio to downsize to before computing the render pass.
  54649. * @param camera The camera to apply the render pass to.
  54650. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54651. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54653. * @param engine The engine which the post process will be applied. (default: current engine)
  54654. * @param reusable If the post process can be reused on the same frame. (default: false)
  54655. * @param textureType Type of textures used when performing the post process. (default: 0)
  54656. * @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)
  54657. */
  54658. 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);
  54659. }
  54660. }
  54661. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54662. /** @hidden */
  54663. export var depthOfFieldMergePixelShader: {
  54664. name: string;
  54665. shader: string;
  54666. };
  54667. }
  54668. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54669. import { Nullable } from "babylonjs/types";
  54670. import { Camera } from "babylonjs/Cameras/camera";
  54671. import { Effect } from "babylonjs/Materials/effect";
  54672. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54673. import { Engine } from "babylonjs/Engines/engine";
  54674. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54675. /**
  54676. * Options to be set when merging outputs from the default pipeline.
  54677. */
  54678. export class DepthOfFieldMergePostProcessOptions {
  54679. /**
  54680. * The original image to merge on top of
  54681. */
  54682. originalFromInput: PostProcess;
  54683. /**
  54684. * Parameters to perform the merge of the depth of field effect
  54685. */
  54686. depthOfField?: {
  54687. circleOfConfusion: PostProcess;
  54688. blurSteps: Array<PostProcess>;
  54689. };
  54690. /**
  54691. * Parameters to perform the merge of bloom effect
  54692. */
  54693. bloom?: {
  54694. blurred: PostProcess;
  54695. weight: number;
  54696. };
  54697. }
  54698. /**
  54699. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54700. */
  54701. export class DepthOfFieldMergePostProcess extends PostProcess {
  54702. private blurSteps;
  54703. /**
  54704. * Creates a new instance of DepthOfFieldMergePostProcess
  54705. * @param name The name of the effect.
  54706. * @param originalFromInput Post process which's input will be used for the merge.
  54707. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54708. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54709. * @param options The required width/height ratio to downsize to before computing the render pass.
  54710. * @param camera The camera to apply the render pass to.
  54711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54712. * @param engine The engine which the post process will be applied. (default: current engine)
  54713. * @param reusable If the post process can be reused on the same frame. (default: false)
  54714. * @param textureType Type of textures used when performing the post process. (default: 0)
  54715. * @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)
  54716. */
  54717. 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);
  54718. /**
  54719. * Updates the effect with the current post process compile time values and recompiles the shader.
  54720. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54721. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54722. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54723. * @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
  54724. * @param onCompiled Called when the shader has been compiled.
  54725. * @param onError Called if there is an error when compiling a shader.
  54726. */
  54727. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54728. }
  54729. }
  54730. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54731. import { Nullable } from "babylonjs/types";
  54732. import { Camera } from "babylonjs/Cameras/camera";
  54733. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54734. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54735. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54736. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54737. import { Scene } from "babylonjs/scene";
  54738. /**
  54739. * Specifies the level of max blur that should be applied when using the depth of field effect
  54740. */
  54741. export enum DepthOfFieldEffectBlurLevel {
  54742. /**
  54743. * Subtle blur
  54744. */
  54745. Low = 0,
  54746. /**
  54747. * Medium blur
  54748. */
  54749. Medium = 1,
  54750. /**
  54751. * Large blur
  54752. */
  54753. High = 2
  54754. }
  54755. /**
  54756. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54757. */
  54758. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54759. private _circleOfConfusion;
  54760. /**
  54761. * @hidden Internal, blurs from high to low
  54762. */
  54763. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54764. private _depthOfFieldBlurY;
  54765. private _dofMerge;
  54766. /**
  54767. * @hidden Internal post processes in depth of field effect
  54768. */
  54769. _effects: Array<PostProcess>;
  54770. /**
  54771. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54772. */
  54773. focalLength: number;
  54774. /**
  54775. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54776. */
  54777. fStop: number;
  54778. /**
  54779. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54780. */
  54781. focusDistance: number;
  54782. /**
  54783. * 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.
  54784. */
  54785. lensSize: number;
  54786. /**
  54787. * Creates a new instance DepthOfFieldEffect
  54788. * @param scene The scene the effect belongs to.
  54789. * @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.
  54790. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54791. * @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)
  54792. */
  54793. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54794. /**
  54795. * 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.
  54796. */
  54797. depthTexture: RenderTargetTexture;
  54798. /**
  54799. * Disposes each of the internal effects for a given camera.
  54800. * @param camera The camera to dispose the effect on.
  54801. */
  54802. disposeEffects(camera: Camera): void;
  54803. /**
  54804. * @hidden Internal
  54805. */
  54806. _updateEffects(): void;
  54807. /**
  54808. * Internal
  54809. * @returns if all the contained post processes are ready.
  54810. * @hidden
  54811. */
  54812. _isReady(): boolean;
  54813. }
  54814. }
  54815. declare module "babylonjs/Shaders/displayPass.fragment" {
  54816. /** @hidden */
  54817. export var displayPassPixelShader: {
  54818. name: string;
  54819. shader: string;
  54820. };
  54821. }
  54822. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54823. import { Nullable } from "babylonjs/types";
  54824. import { Camera } from "babylonjs/Cameras/camera";
  54825. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54826. import { Engine } from "babylonjs/Engines/engine";
  54827. import "babylonjs/Shaders/displayPass.fragment";
  54828. /**
  54829. * DisplayPassPostProcess which produces an output the same as it's input
  54830. */
  54831. export class DisplayPassPostProcess extends PostProcess {
  54832. /**
  54833. * Creates the DisplayPassPostProcess
  54834. * @param name The name of the effect.
  54835. * @param options The required width/height ratio to downsize to before computing the render pass.
  54836. * @param camera The camera to apply the render pass to.
  54837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54838. * @param engine The engine which the post process will be applied. (default: current engine)
  54839. * @param reusable If the post process can be reused on the same frame. (default: false)
  54840. */
  54841. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54842. }
  54843. }
  54844. declare module "babylonjs/Shaders/filter.fragment" {
  54845. /** @hidden */
  54846. export var filterPixelShader: {
  54847. name: string;
  54848. shader: string;
  54849. };
  54850. }
  54851. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54852. import { Nullable } from "babylonjs/types";
  54853. import { Matrix } from "babylonjs/Maths/math";
  54854. import { Camera } from "babylonjs/Cameras/camera";
  54855. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54856. import { Engine } from "babylonjs/Engines/engine";
  54857. import "babylonjs/Shaders/filter.fragment";
  54858. /**
  54859. * Applies a kernel filter to the image
  54860. */
  54861. export class FilterPostProcess extends PostProcess {
  54862. /** The matrix to be applied to the image */
  54863. kernelMatrix: Matrix;
  54864. /**
  54865. *
  54866. * @param name The name of the effect.
  54867. * @param kernelMatrix The matrix to be applied to the image
  54868. * @param options The required width/height ratio to downsize to before computing the render pass.
  54869. * @param camera The camera to apply the render pass to.
  54870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54871. * @param engine The engine which the post process will be applied. (default: current engine)
  54872. * @param reusable If the post process can be reused on the same frame. (default: false)
  54873. */
  54874. constructor(name: string,
  54875. /** The matrix to be applied to the image */
  54876. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54877. }
  54878. }
  54879. declare module "babylonjs/Shaders/fxaa.fragment" {
  54880. /** @hidden */
  54881. export var fxaaPixelShader: {
  54882. name: string;
  54883. shader: string;
  54884. };
  54885. }
  54886. declare module "babylonjs/Shaders/fxaa.vertex" {
  54887. /** @hidden */
  54888. export var fxaaVertexShader: {
  54889. name: string;
  54890. shader: string;
  54891. };
  54892. }
  54893. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54894. import { Nullable } from "babylonjs/types";
  54895. import { Camera } from "babylonjs/Cameras/camera";
  54896. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54897. import { Engine } from "babylonjs/Engines/engine";
  54898. import "babylonjs/Shaders/fxaa.fragment";
  54899. import "babylonjs/Shaders/fxaa.vertex";
  54900. /**
  54901. * Fxaa post process
  54902. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54903. */
  54904. export class FxaaPostProcess extends PostProcess {
  54905. /** @hidden */
  54906. texelWidth: number;
  54907. /** @hidden */
  54908. texelHeight: number;
  54909. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54910. private _getDefines;
  54911. }
  54912. }
  54913. declare module "babylonjs/Shaders/grain.fragment" {
  54914. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54915. /** @hidden */
  54916. export var grainPixelShader: {
  54917. name: string;
  54918. shader: string;
  54919. };
  54920. }
  54921. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54922. import { Nullable } from "babylonjs/types";
  54923. import { Camera } from "babylonjs/Cameras/camera";
  54924. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54925. import { Engine } from "babylonjs/Engines/engine";
  54926. import "babylonjs/Shaders/grain.fragment";
  54927. /**
  54928. * The GrainPostProcess adds noise to the image at mid luminance levels
  54929. */
  54930. export class GrainPostProcess extends PostProcess {
  54931. /**
  54932. * The intensity of the grain added (default: 30)
  54933. */
  54934. intensity: number;
  54935. /**
  54936. * If the grain should be randomized on every frame
  54937. */
  54938. animated: boolean;
  54939. /**
  54940. * Creates a new instance of @see GrainPostProcess
  54941. * @param name The name of the effect.
  54942. * @param options The required width/height ratio to downsize to before computing the render pass.
  54943. * @param camera The camera to apply the render pass to.
  54944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54945. * @param engine The engine which the post process will be applied. (default: current engine)
  54946. * @param reusable If the post process can be reused on the same frame. (default: false)
  54947. * @param textureType Type of textures used when performing the post process. (default: 0)
  54948. * @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)
  54949. */
  54950. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54951. }
  54952. }
  54953. declare module "babylonjs/Shaders/highlights.fragment" {
  54954. /** @hidden */
  54955. export var highlightsPixelShader: {
  54956. name: string;
  54957. shader: string;
  54958. };
  54959. }
  54960. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54961. import { Nullable } from "babylonjs/types";
  54962. import { Camera } from "babylonjs/Cameras/camera";
  54963. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54964. import { Engine } from "babylonjs/Engines/engine";
  54965. import "babylonjs/Shaders/highlights.fragment";
  54966. /**
  54967. * Extracts highlights from the image
  54968. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54969. */
  54970. export class HighlightsPostProcess extends PostProcess {
  54971. /**
  54972. * Extracts highlights from the image
  54973. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54974. * @param name The name of the effect.
  54975. * @param options The required width/height ratio to downsize to before computing the render pass.
  54976. * @param camera The camera to apply the render pass to.
  54977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54978. * @param engine The engine which the post process will be applied. (default: current engine)
  54979. * @param reusable If the post process can be reused on the same frame. (default: false)
  54980. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54981. */
  54982. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54983. }
  54984. }
  54985. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54986. /** @hidden */
  54987. export var mrtFragmentDeclaration: {
  54988. name: string;
  54989. shader: string;
  54990. };
  54991. }
  54992. declare module "babylonjs/Shaders/geometry.fragment" {
  54993. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54994. /** @hidden */
  54995. export var geometryPixelShader: {
  54996. name: string;
  54997. shader: string;
  54998. };
  54999. }
  55000. declare module "babylonjs/Shaders/geometry.vertex" {
  55001. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55002. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55003. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55004. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55005. /** @hidden */
  55006. export var geometryVertexShader: {
  55007. name: string;
  55008. shader: string;
  55009. };
  55010. }
  55011. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55012. import { Matrix } from "babylonjs/Maths/math";
  55013. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55014. import { Mesh } from "babylonjs/Meshes/mesh";
  55015. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55016. import { Effect } from "babylonjs/Materials/effect";
  55017. import { Scene } from "babylonjs/scene";
  55018. import "babylonjs/Shaders/geometry.fragment";
  55019. import "babylonjs/Shaders/geometry.vertex";
  55020. /**
  55021. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55022. */
  55023. export class GeometryBufferRenderer {
  55024. /**
  55025. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55026. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55027. */
  55028. static readonly POSITION_TEXTURE_TYPE: number;
  55029. /**
  55030. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55031. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55032. */
  55033. static readonly VELOCITY_TEXTURE_TYPE: number;
  55034. /**
  55035. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55036. * in order to compute objects velocities when enableVelocity is set to "true"
  55037. * @hidden
  55038. */
  55039. _previousTransformationMatrices: {
  55040. [index: number]: Matrix;
  55041. };
  55042. private _scene;
  55043. private _multiRenderTarget;
  55044. private _ratio;
  55045. private _enablePosition;
  55046. private _enableVelocity;
  55047. private _positionIndex;
  55048. private _velocityIndex;
  55049. protected _effect: Effect;
  55050. protected _cachedDefines: string;
  55051. /**
  55052. * Set the render list (meshes to be rendered) used in the G buffer.
  55053. */
  55054. renderList: Mesh[];
  55055. /**
  55056. * Gets wether or not G buffer are supported by the running hardware.
  55057. * This requires draw buffer supports
  55058. */
  55059. readonly isSupported: boolean;
  55060. /**
  55061. * Returns the index of the given texture type in the G-Buffer textures array
  55062. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55063. * @returns the index of the given texture type in the G-Buffer textures array
  55064. */
  55065. getTextureIndex(textureType: number): number;
  55066. /**
  55067. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55068. */
  55069. /**
  55070. * Sets whether or not objects positions are enabled for the G buffer.
  55071. */
  55072. enablePosition: boolean;
  55073. /**
  55074. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55075. */
  55076. /**
  55077. * Sets wether or not objects velocities are enabled for the G buffer.
  55078. */
  55079. enableVelocity: boolean;
  55080. /**
  55081. * Gets the scene associated with the buffer.
  55082. */
  55083. readonly scene: Scene;
  55084. /**
  55085. * Gets the ratio used by the buffer during its creation.
  55086. * How big is the buffer related to the main canvas.
  55087. */
  55088. readonly ratio: number;
  55089. /** @hidden */
  55090. static _SceneComponentInitialization: (scene: Scene) => void;
  55091. /**
  55092. * Creates a new G Buffer for the scene
  55093. * @param scene The scene the buffer belongs to
  55094. * @param ratio How big is the buffer related to the main canvas.
  55095. */
  55096. constructor(scene: Scene, ratio?: number);
  55097. /**
  55098. * Checks wether everything is ready to render a submesh to the G buffer.
  55099. * @param subMesh the submesh to check readiness for
  55100. * @param useInstances is the mesh drawn using instance or not
  55101. * @returns true if ready otherwise false
  55102. */
  55103. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55104. /**
  55105. * Gets the current underlying G Buffer.
  55106. * @returns the buffer
  55107. */
  55108. getGBuffer(): MultiRenderTarget;
  55109. /**
  55110. * Gets the number of samples used to render the buffer (anti aliasing).
  55111. */
  55112. /**
  55113. * Sets the number of samples used to render the buffer (anti aliasing).
  55114. */
  55115. samples: number;
  55116. /**
  55117. * Disposes the renderer and frees up associated resources.
  55118. */
  55119. dispose(): void;
  55120. protected _createRenderTargets(): void;
  55121. }
  55122. }
  55123. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55124. import { Nullable } from "babylonjs/types";
  55125. import { Scene } from "babylonjs/scene";
  55126. import { ISceneComponent } from "babylonjs/sceneComponent";
  55127. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55128. module "babylonjs/scene" {
  55129. interface Scene {
  55130. /** @hidden (Backing field) */
  55131. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55132. /**
  55133. * Gets or Sets the current geometry buffer associated to the scene.
  55134. */
  55135. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55136. /**
  55137. * Enables a GeometryBufferRender and associates it with the scene
  55138. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55139. * @returns the GeometryBufferRenderer
  55140. */
  55141. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55142. /**
  55143. * Disables the GeometryBufferRender associated with the scene
  55144. */
  55145. disableGeometryBufferRenderer(): void;
  55146. }
  55147. }
  55148. /**
  55149. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55150. * in several rendering techniques.
  55151. */
  55152. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55153. /**
  55154. * The component name helpful to identify the component in the list of scene components.
  55155. */
  55156. readonly name: string;
  55157. /**
  55158. * The scene the component belongs to.
  55159. */
  55160. scene: Scene;
  55161. /**
  55162. * Creates a new instance of the component for the given scene
  55163. * @param scene Defines the scene to register the component in
  55164. */
  55165. constructor(scene: Scene);
  55166. /**
  55167. * Registers the component in a given scene
  55168. */
  55169. register(): void;
  55170. /**
  55171. * Rebuilds the elements related to this component in case of
  55172. * context lost for instance.
  55173. */
  55174. rebuild(): void;
  55175. /**
  55176. * Disposes the component and the associated ressources
  55177. */
  55178. dispose(): void;
  55179. private _gatherRenderTargets;
  55180. }
  55181. }
  55182. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55183. /** @hidden */
  55184. export var motionBlurPixelShader: {
  55185. name: string;
  55186. shader: string;
  55187. };
  55188. }
  55189. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55190. import { Nullable } from "babylonjs/types";
  55191. import { Camera } from "babylonjs/Cameras/camera";
  55192. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55193. import { Scene } from "babylonjs/scene";
  55194. import "babylonjs/Animations/animatable";
  55195. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55196. import "babylonjs/Shaders/motionBlur.fragment";
  55197. import { Engine } from "babylonjs/Engines/engine";
  55198. /**
  55199. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55200. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55201. * As an example, all you have to do is to create the post-process:
  55202. * var mb = new BABYLON.MotionBlurPostProcess(
  55203. * 'mb', // The name of the effect.
  55204. * scene, // The scene containing the objects to blur according to their velocity.
  55205. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55206. * camera // The camera to apply the render pass to.
  55207. * );
  55208. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55209. */
  55210. export class MotionBlurPostProcess extends PostProcess {
  55211. /**
  55212. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55213. */
  55214. motionStrength: number;
  55215. /**
  55216. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55217. */
  55218. /**
  55219. * Sets the number of iterations to be used for motion blur quality
  55220. */
  55221. motionBlurSamples: number;
  55222. private _motionBlurSamples;
  55223. private _geometryBufferRenderer;
  55224. /**
  55225. * Creates a new instance MotionBlurPostProcess
  55226. * @param name The name of the effect.
  55227. * @param scene The scene containing the objects to blur according to their velocity.
  55228. * @param options The required width/height ratio to downsize to before computing the render pass.
  55229. * @param camera The camera to apply the render pass to.
  55230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55231. * @param engine The engine which the post process will be applied. (default: current engine)
  55232. * @param reusable If the post process can be reused on the same frame. (default: false)
  55233. * @param textureType Type of textures used when performing the post process. (default: 0)
  55234. * @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)
  55235. */
  55236. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55237. /**
  55238. * Disposes the post process.
  55239. * @param camera The camera to dispose the post process on.
  55240. */
  55241. dispose(camera?: Camera): void;
  55242. }
  55243. }
  55244. declare module "babylonjs/Shaders/refraction.fragment" {
  55245. /** @hidden */
  55246. export var refractionPixelShader: {
  55247. name: string;
  55248. shader: string;
  55249. };
  55250. }
  55251. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55252. import { Color3 } from "babylonjs/Maths/math";
  55253. import { Camera } from "babylonjs/Cameras/camera";
  55254. import { Texture } from "babylonjs/Materials/Textures/texture";
  55255. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55256. import { Engine } from "babylonjs/Engines/engine";
  55257. import "babylonjs/Shaders/refraction.fragment";
  55258. /**
  55259. * Post process which applies a refractin texture
  55260. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55261. */
  55262. export class RefractionPostProcess extends PostProcess {
  55263. /** the base color of the refraction (used to taint the rendering) */
  55264. color: Color3;
  55265. /** simulated refraction depth */
  55266. depth: number;
  55267. /** the coefficient of the base color (0 to remove base color tainting) */
  55268. colorLevel: number;
  55269. private _refTexture;
  55270. private _ownRefractionTexture;
  55271. /**
  55272. * Gets or sets the refraction texture
  55273. * Please note that you are responsible for disposing the texture if you set it manually
  55274. */
  55275. refractionTexture: Texture;
  55276. /**
  55277. * Initializes the RefractionPostProcess
  55278. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55279. * @param name The name of the effect.
  55280. * @param refractionTextureUrl Url of the refraction texture to use
  55281. * @param color the base color of the refraction (used to taint the rendering)
  55282. * @param depth simulated refraction depth
  55283. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55284. * @param camera The camera to apply the render pass to.
  55285. * @param options The required width/height ratio to downsize to before computing the render pass.
  55286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55287. * @param engine The engine which the post process will be applied. (default: current engine)
  55288. * @param reusable If the post process can be reused on the same frame. (default: false)
  55289. */
  55290. constructor(name: string, refractionTextureUrl: string,
  55291. /** the base color of the refraction (used to taint the rendering) */
  55292. color: Color3,
  55293. /** simulated refraction depth */
  55294. depth: number,
  55295. /** the coefficient of the base color (0 to remove base color tainting) */
  55296. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55297. /**
  55298. * Disposes of the post process
  55299. * @param camera Camera to dispose post process on
  55300. */
  55301. dispose(camera: Camera): void;
  55302. }
  55303. }
  55304. declare module "babylonjs/Shaders/sharpen.fragment" {
  55305. /** @hidden */
  55306. export var sharpenPixelShader: {
  55307. name: string;
  55308. shader: string;
  55309. };
  55310. }
  55311. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55312. import { Nullable } from "babylonjs/types";
  55313. import { Camera } from "babylonjs/Cameras/camera";
  55314. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55315. import "babylonjs/Shaders/sharpen.fragment";
  55316. import { Engine } from "babylonjs/Engines/engine";
  55317. /**
  55318. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55319. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55320. */
  55321. export class SharpenPostProcess extends PostProcess {
  55322. /**
  55323. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55324. */
  55325. colorAmount: number;
  55326. /**
  55327. * How much sharpness should be applied (default: 0.3)
  55328. */
  55329. edgeAmount: number;
  55330. /**
  55331. * Creates a new instance ConvolutionPostProcess
  55332. * @param name The name of the effect.
  55333. * @param options The required width/height ratio to downsize to before computing the render pass.
  55334. * @param camera The camera to apply the render pass to.
  55335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55336. * @param engine The engine which the post process will be applied. (default: current engine)
  55337. * @param reusable If the post process can be reused on the same frame. (default: false)
  55338. * @param textureType Type of textures used when performing the post process. (default: 0)
  55339. * @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)
  55340. */
  55341. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55342. }
  55343. }
  55344. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55345. import { Nullable } from "babylonjs/types";
  55346. import { Camera } from "babylonjs/Cameras/camera";
  55347. import { Engine } from "babylonjs/Engines/engine";
  55348. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55349. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55350. /**
  55351. * PostProcessRenderPipeline
  55352. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55353. */
  55354. export class PostProcessRenderPipeline {
  55355. private engine;
  55356. private _renderEffects;
  55357. private _renderEffectsForIsolatedPass;
  55358. /**
  55359. * List of inspectable custom properties (used by the Inspector)
  55360. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55361. */
  55362. inspectableCustomProperties: IInspectable[];
  55363. /**
  55364. * @hidden
  55365. */
  55366. protected _cameras: Camera[];
  55367. /** @hidden */
  55368. _name: string;
  55369. /**
  55370. * Gets pipeline name
  55371. */
  55372. readonly name: string;
  55373. /**
  55374. * Initializes a PostProcessRenderPipeline
  55375. * @param engine engine to add the pipeline to
  55376. * @param name name of the pipeline
  55377. */
  55378. constructor(engine: Engine, name: string);
  55379. /**
  55380. * Gets the class name
  55381. * @returns "PostProcessRenderPipeline"
  55382. */
  55383. getClassName(): string;
  55384. /**
  55385. * If all the render effects in the pipeline are supported
  55386. */
  55387. readonly isSupported: boolean;
  55388. /**
  55389. * Adds an effect to the pipeline
  55390. * @param renderEffect the effect to add
  55391. */
  55392. addEffect(renderEffect: PostProcessRenderEffect): void;
  55393. /** @hidden */
  55394. _rebuild(): void;
  55395. /** @hidden */
  55396. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55397. /** @hidden */
  55398. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55399. /** @hidden */
  55400. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55401. /** @hidden */
  55402. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55403. /** @hidden */
  55404. _attachCameras(cameras: Camera, unique: boolean): void;
  55405. /** @hidden */
  55406. _attachCameras(cameras: Camera[], unique: boolean): void;
  55407. /** @hidden */
  55408. _detachCameras(cameras: Camera): void;
  55409. /** @hidden */
  55410. _detachCameras(cameras: Nullable<Camera[]>): void;
  55411. /** @hidden */
  55412. _update(): void;
  55413. /** @hidden */
  55414. _reset(): void;
  55415. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55416. /**
  55417. * Disposes of the pipeline
  55418. */
  55419. dispose(): void;
  55420. }
  55421. }
  55422. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55423. import { Camera } from "babylonjs/Cameras/camera";
  55424. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55425. /**
  55426. * PostProcessRenderPipelineManager class
  55427. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55428. */
  55429. export class PostProcessRenderPipelineManager {
  55430. private _renderPipelines;
  55431. /**
  55432. * Initializes a PostProcessRenderPipelineManager
  55433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55434. */
  55435. constructor();
  55436. /**
  55437. * Gets the list of supported render pipelines
  55438. */
  55439. readonly supportedPipelines: PostProcessRenderPipeline[];
  55440. /**
  55441. * Adds a pipeline to the manager
  55442. * @param renderPipeline The pipeline to add
  55443. */
  55444. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55445. /**
  55446. * Attaches a camera to the pipeline
  55447. * @param renderPipelineName The name of the pipeline to attach to
  55448. * @param cameras the camera to attach
  55449. * @param unique if the camera can be attached multiple times to the pipeline
  55450. */
  55451. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55452. /**
  55453. * Detaches a camera from the pipeline
  55454. * @param renderPipelineName The name of the pipeline to detach from
  55455. * @param cameras the camera to detach
  55456. */
  55457. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55458. /**
  55459. * Enables an effect by name on a pipeline
  55460. * @param renderPipelineName the name of the pipeline to enable the effect in
  55461. * @param renderEffectName the name of the effect to enable
  55462. * @param cameras the cameras that the effect should be enabled on
  55463. */
  55464. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55465. /**
  55466. * Disables an effect by name on a pipeline
  55467. * @param renderPipelineName the name of the pipeline to disable the effect in
  55468. * @param renderEffectName the name of the effect to disable
  55469. * @param cameras the cameras that the effect should be disabled on
  55470. */
  55471. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55472. /**
  55473. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55474. */
  55475. update(): void;
  55476. /** @hidden */
  55477. _rebuild(): void;
  55478. /**
  55479. * Disposes of the manager and pipelines
  55480. */
  55481. dispose(): void;
  55482. }
  55483. }
  55484. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55485. import { ISceneComponent } from "babylonjs/sceneComponent";
  55486. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55487. import { Scene } from "babylonjs/scene";
  55488. module "babylonjs/scene" {
  55489. interface Scene {
  55490. /** @hidden (Backing field) */
  55491. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55492. /**
  55493. * Gets the postprocess render pipeline manager
  55494. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55495. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55496. */
  55497. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55498. }
  55499. }
  55500. /**
  55501. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55502. */
  55503. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55504. /**
  55505. * The component name helpfull to identify the component in the list of scene components.
  55506. */
  55507. readonly name: string;
  55508. /**
  55509. * The scene the component belongs to.
  55510. */
  55511. scene: Scene;
  55512. /**
  55513. * Creates a new instance of the component for the given scene
  55514. * @param scene Defines the scene to register the component in
  55515. */
  55516. constructor(scene: Scene);
  55517. /**
  55518. * Registers the component in a given scene
  55519. */
  55520. register(): void;
  55521. /**
  55522. * Rebuilds the elements related to this component in case of
  55523. * context lost for instance.
  55524. */
  55525. rebuild(): void;
  55526. /**
  55527. * Disposes the component and the associated ressources
  55528. */
  55529. dispose(): void;
  55530. private _gatherRenderTargets;
  55531. }
  55532. }
  55533. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55534. import { IAnimatable } from "babylonjs/Misc/tools";
  55535. import { Camera } from "babylonjs/Cameras/camera";
  55536. import { IDisposable } from "babylonjs/scene";
  55537. import { Scene } from "babylonjs/scene";
  55538. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55539. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55540. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55541. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55542. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55543. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55544. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55545. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55546. import { Animation } from "babylonjs/Animations/animation";
  55547. /**
  55548. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55549. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55550. */
  55551. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55552. private _scene;
  55553. private _camerasToBeAttached;
  55554. /**
  55555. * ID of the sharpen post process,
  55556. */
  55557. private readonly SharpenPostProcessId;
  55558. /**
  55559. * @ignore
  55560. * ID of the image processing post process;
  55561. */
  55562. readonly ImageProcessingPostProcessId: string;
  55563. /**
  55564. * @ignore
  55565. * ID of the Fast Approximate Anti-Aliasing post process;
  55566. */
  55567. readonly FxaaPostProcessId: string;
  55568. /**
  55569. * ID of the chromatic aberration post process,
  55570. */
  55571. private readonly ChromaticAberrationPostProcessId;
  55572. /**
  55573. * ID of the grain post process
  55574. */
  55575. private readonly GrainPostProcessId;
  55576. /**
  55577. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55578. */
  55579. sharpen: SharpenPostProcess;
  55580. private _sharpenEffect;
  55581. private bloom;
  55582. /**
  55583. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55584. */
  55585. depthOfField: DepthOfFieldEffect;
  55586. /**
  55587. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55588. */
  55589. fxaa: FxaaPostProcess;
  55590. /**
  55591. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55592. */
  55593. imageProcessing: ImageProcessingPostProcess;
  55594. /**
  55595. * Chromatic aberration post process which will shift rgb colors in the image
  55596. */
  55597. chromaticAberration: ChromaticAberrationPostProcess;
  55598. private _chromaticAberrationEffect;
  55599. /**
  55600. * Grain post process which add noise to the image
  55601. */
  55602. grain: GrainPostProcess;
  55603. private _grainEffect;
  55604. /**
  55605. * Glow post process which adds a glow to emissive areas of the image
  55606. */
  55607. private _glowLayer;
  55608. /**
  55609. * Animations which can be used to tweak settings over a period of time
  55610. */
  55611. animations: Animation[];
  55612. private _imageProcessingConfigurationObserver;
  55613. private _sharpenEnabled;
  55614. private _bloomEnabled;
  55615. private _depthOfFieldEnabled;
  55616. private _depthOfFieldBlurLevel;
  55617. private _fxaaEnabled;
  55618. private _imageProcessingEnabled;
  55619. private _defaultPipelineTextureType;
  55620. private _bloomScale;
  55621. private _chromaticAberrationEnabled;
  55622. private _grainEnabled;
  55623. private _buildAllowed;
  55624. /**
  55625. * Gets active scene
  55626. */
  55627. readonly scene: Scene;
  55628. /**
  55629. * Enable or disable the sharpen process from the pipeline
  55630. */
  55631. sharpenEnabled: boolean;
  55632. private _resizeObserver;
  55633. private _hardwareScaleLevel;
  55634. private _bloomKernel;
  55635. /**
  55636. * Specifies the size of the bloom blur kernel, relative to the final output size
  55637. */
  55638. bloomKernel: number;
  55639. /**
  55640. * Specifies the weight of the bloom in the final rendering
  55641. */
  55642. private _bloomWeight;
  55643. /**
  55644. * Specifies the luma threshold for the area that will be blurred by the bloom
  55645. */
  55646. private _bloomThreshold;
  55647. private _hdr;
  55648. /**
  55649. * The strength of the bloom.
  55650. */
  55651. bloomWeight: number;
  55652. /**
  55653. * The strength of the bloom.
  55654. */
  55655. bloomThreshold: number;
  55656. /**
  55657. * The scale of the bloom, lower value will provide better performance.
  55658. */
  55659. bloomScale: number;
  55660. /**
  55661. * Enable or disable the bloom from the pipeline
  55662. */
  55663. bloomEnabled: boolean;
  55664. private _rebuildBloom;
  55665. /**
  55666. * If the depth of field is enabled.
  55667. */
  55668. depthOfFieldEnabled: boolean;
  55669. /**
  55670. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55671. */
  55672. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55673. /**
  55674. * If the anti aliasing is enabled.
  55675. */
  55676. fxaaEnabled: boolean;
  55677. private _samples;
  55678. /**
  55679. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55680. */
  55681. samples: number;
  55682. /**
  55683. * If image processing is enabled.
  55684. */
  55685. imageProcessingEnabled: boolean;
  55686. /**
  55687. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55688. */
  55689. glowLayerEnabled: boolean;
  55690. /**
  55691. * Enable or disable the chromaticAberration process from the pipeline
  55692. */
  55693. chromaticAberrationEnabled: boolean;
  55694. /**
  55695. * Enable or disable the grain process from the pipeline
  55696. */
  55697. grainEnabled: boolean;
  55698. /**
  55699. * @constructor
  55700. * @param name - The rendering pipeline name (default: "")
  55701. * @param hdr - If high dynamic range textures should be used (default: true)
  55702. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55703. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55704. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55705. */
  55706. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55707. /**
  55708. * Get the class name
  55709. * @returns "DefaultRenderingPipeline"
  55710. */
  55711. getClassName(): string;
  55712. /**
  55713. * Force the compilation of the entire pipeline.
  55714. */
  55715. prepare(): void;
  55716. private _hasCleared;
  55717. private _prevPostProcess;
  55718. private _prevPrevPostProcess;
  55719. private _setAutoClearAndTextureSharing;
  55720. private _depthOfFieldSceneObserver;
  55721. private _buildPipeline;
  55722. private _disposePostProcesses;
  55723. /**
  55724. * Adds a camera to the pipeline
  55725. * @param camera the camera to be added
  55726. */
  55727. addCamera(camera: Camera): void;
  55728. /**
  55729. * Removes a camera from the pipeline
  55730. * @param camera the camera to remove
  55731. */
  55732. removeCamera(camera: Camera): void;
  55733. /**
  55734. * Dispose of the pipeline and stop all post processes
  55735. */
  55736. dispose(): void;
  55737. /**
  55738. * Serialize the rendering pipeline (Used when exporting)
  55739. * @returns the serialized object
  55740. */
  55741. serialize(): any;
  55742. /**
  55743. * Parse the serialized pipeline
  55744. * @param source Source pipeline.
  55745. * @param scene The scene to load the pipeline to.
  55746. * @param rootUrl The URL of the serialized pipeline.
  55747. * @returns An instantiated pipeline from the serialized object.
  55748. */
  55749. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55750. }
  55751. }
  55752. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55753. /** @hidden */
  55754. export var lensHighlightsPixelShader: {
  55755. name: string;
  55756. shader: string;
  55757. };
  55758. }
  55759. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55760. /** @hidden */
  55761. export var depthOfFieldPixelShader: {
  55762. name: string;
  55763. shader: string;
  55764. };
  55765. }
  55766. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55767. import { Camera } from "babylonjs/Cameras/camera";
  55768. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55769. import { Scene } from "babylonjs/scene";
  55770. import "babylonjs/Shaders/chromaticAberration.fragment";
  55771. import "babylonjs/Shaders/lensHighlights.fragment";
  55772. import "babylonjs/Shaders/depthOfField.fragment";
  55773. /**
  55774. * BABYLON.JS Chromatic Aberration GLSL Shader
  55775. * Author: Olivier Guyot
  55776. * Separates very slightly R, G and B colors on the edges of the screen
  55777. * Inspired by Francois Tarlier & Martins Upitis
  55778. */
  55779. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55780. /**
  55781. * @ignore
  55782. * The chromatic aberration PostProcess id in the pipeline
  55783. */
  55784. LensChromaticAberrationEffect: string;
  55785. /**
  55786. * @ignore
  55787. * The highlights enhancing PostProcess id in the pipeline
  55788. */
  55789. HighlightsEnhancingEffect: string;
  55790. /**
  55791. * @ignore
  55792. * The depth-of-field PostProcess id in the pipeline
  55793. */
  55794. LensDepthOfFieldEffect: string;
  55795. private _scene;
  55796. private _depthTexture;
  55797. private _grainTexture;
  55798. private _chromaticAberrationPostProcess;
  55799. private _highlightsPostProcess;
  55800. private _depthOfFieldPostProcess;
  55801. private _edgeBlur;
  55802. private _grainAmount;
  55803. private _chromaticAberration;
  55804. private _distortion;
  55805. private _highlightsGain;
  55806. private _highlightsThreshold;
  55807. private _dofDistance;
  55808. private _dofAperture;
  55809. private _dofDarken;
  55810. private _dofPentagon;
  55811. private _blurNoise;
  55812. /**
  55813. * @constructor
  55814. *
  55815. * Effect parameters are as follow:
  55816. * {
  55817. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55818. * edge_blur: number; // from 0 to x (1 for realism)
  55819. * distortion: number; // from 0 to x (1 for realism)
  55820. * grain_amount: number; // from 0 to 1
  55821. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55822. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55823. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55824. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55825. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55826. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55827. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55828. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55829. * }
  55830. * Note: if an effect parameter is unset, effect is disabled
  55831. *
  55832. * @param name The rendering pipeline name
  55833. * @param parameters - An object containing all parameters (see above)
  55834. * @param scene The scene linked to this pipeline
  55835. * @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)
  55836. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55837. */
  55838. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55839. /**
  55840. * Get the class name
  55841. * @returns "LensRenderingPipeline"
  55842. */
  55843. getClassName(): string;
  55844. /**
  55845. * Gets associated scene
  55846. */
  55847. readonly scene: Scene;
  55848. /**
  55849. * Gets or sets the edge blur
  55850. */
  55851. edgeBlur: number;
  55852. /**
  55853. * Gets or sets the grain amount
  55854. */
  55855. grainAmount: number;
  55856. /**
  55857. * Gets or sets the chromatic aberration amount
  55858. */
  55859. chromaticAberration: number;
  55860. /**
  55861. * Gets or sets the depth of field aperture
  55862. */
  55863. dofAperture: number;
  55864. /**
  55865. * Gets or sets the edge distortion
  55866. */
  55867. edgeDistortion: number;
  55868. /**
  55869. * Gets or sets the depth of field distortion
  55870. */
  55871. dofDistortion: number;
  55872. /**
  55873. * Gets or sets the darken out of focus amount
  55874. */
  55875. darkenOutOfFocus: number;
  55876. /**
  55877. * Gets or sets a boolean indicating if blur noise is enabled
  55878. */
  55879. blurNoise: boolean;
  55880. /**
  55881. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55882. */
  55883. pentagonBokeh: boolean;
  55884. /**
  55885. * Gets or sets the highlight grain amount
  55886. */
  55887. highlightsGain: number;
  55888. /**
  55889. * Gets or sets the highlight threshold
  55890. */
  55891. highlightsThreshold: number;
  55892. /**
  55893. * Sets the amount of blur at the edges
  55894. * @param amount blur amount
  55895. */
  55896. setEdgeBlur(amount: number): void;
  55897. /**
  55898. * Sets edge blur to 0
  55899. */
  55900. disableEdgeBlur(): void;
  55901. /**
  55902. * Sets the amout of grain
  55903. * @param amount Amount of grain
  55904. */
  55905. setGrainAmount(amount: number): void;
  55906. /**
  55907. * Set grain amount to 0
  55908. */
  55909. disableGrain(): void;
  55910. /**
  55911. * Sets the chromatic aberration amount
  55912. * @param amount amount of chromatic aberration
  55913. */
  55914. setChromaticAberration(amount: number): void;
  55915. /**
  55916. * Sets chromatic aberration amount to 0
  55917. */
  55918. disableChromaticAberration(): void;
  55919. /**
  55920. * Sets the EdgeDistortion amount
  55921. * @param amount amount of EdgeDistortion
  55922. */
  55923. setEdgeDistortion(amount: number): void;
  55924. /**
  55925. * Sets edge distortion to 0
  55926. */
  55927. disableEdgeDistortion(): void;
  55928. /**
  55929. * Sets the FocusDistance amount
  55930. * @param amount amount of FocusDistance
  55931. */
  55932. setFocusDistance(amount: number): void;
  55933. /**
  55934. * Disables depth of field
  55935. */
  55936. disableDepthOfField(): void;
  55937. /**
  55938. * Sets the Aperture amount
  55939. * @param amount amount of Aperture
  55940. */
  55941. setAperture(amount: number): void;
  55942. /**
  55943. * Sets the DarkenOutOfFocus amount
  55944. * @param amount amount of DarkenOutOfFocus
  55945. */
  55946. setDarkenOutOfFocus(amount: number): void;
  55947. private _pentagonBokehIsEnabled;
  55948. /**
  55949. * Creates a pentagon bokeh effect
  55950. */
  55951. enablePentagonBokeh(): void;
  55952. /**
  55953. * Disables the pentagon bokeh effect
  55954. */
  55955. disablePentagonBokeh(): void;
  55956. /**
  55957. * Enables noise blur
  55958. */
  55959. enableNoiseBlur(): void;
  55960. /**
  55961. * Disables noise blur
  55962. */
  55963. disableNoiseBlur(): void;
  55964. /**
  55965. * Sets the HighlightsGain amount
  55966. * @param amount amount of HighlightsGain
  55967. */
  55968. setHighlightsGain(amount: number): void;
  55969. /**
  55970. * Sets the HighlightsThreshold amount
  55971. * @param amount amount of HighlightsThreshold
  55972. */
  55973. setHighlightsThreshold(amount: number): void;
  55974. /**
  55975. * Disables highlights
  55976. */
  55977. disableHighlights(): void;
  55978. /**
  55979. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55980. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55981. */
  55982. dispose(disableDepthRender?: boolean): void;
  55983. private _createChromaticAberrationPostProcess;
  55984. private _createHighlightsPostProcess;
  55985. private _createDepthOfFieldPostProcess;
  55986. private _createGrainTexture;
  55987. }
  55988. }
  55989. declare module "babylonjs/Shaders/ssao2.fragment" {
  55990. /** @hidden */
  55991. export var ssao2PixelShader: {
  55992. name: string;
  55993. shader: string;
  55994. };
  55995. }
  55996. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55997. /** @hidden */
  55998. export var ssaoCombinePixelShader: {
  55999. name: string;
  56000. shader: string;
  56001. };
  56002. }
  56003. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56004. import { Camera } from "babylonjs/Cameras/camera";
  56005. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56006. import { Scene } from "babylonjs/scene";
  56007. import "babylonjs/Shaders/ssao2.fragment";
  56008. import "babylonjs/Shaders/ssaoCombine.fragment";
  56009. /**
  56010. * Render pipeline to produce ssao effect
  56011. */
  56012. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56013. /**
  56014. * @ignore
  56015. * The PassPostProcess id in the pipeline that contains the original scene color
  56016. */
  56017. SSAOOriginalSceneColorEffect: string;
  56018. /**
  56019. * @ignore
  56020. * The SSAO PostProcess id in the pipeline
  56021. */
  56022. SSAORenderEffect: string;
  56023. /**
  56024. * @ignore
  56025. * The horizontal blur PostProcess id in the pipeline
  56026. */
  56027. SSAOBlurHRenderEffect: string;
  56028. /**
  56029. * @ignore
  56030. * The vertical blur PostProcess id in the pipeline
  56031. */
  56032. SSAOBlurVRenderEffect: string;
  56033. /**
  56034. * @ignore
  56035. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56036. */
  56037. SSAOCombineRenderEffect: string;
  56038. /**
  56039. * The output strength of the SSAO post-process. Default value is 1.0.
  56040. */
  56041. totalStrength: number;
  56042. /**
  56043. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56044. */
  56045. maxZ: number;
  56046. /**
  56047. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56048. */
  56049. minZAspect: number;
  56050. private _samples;
  56051. /**
  56052. * Number of samples used for the SSAO calculations. Default value is 8
  56053. */
  56054. samples: number;
  56055. private _textureSamples;
  56056. /**
  56057. * Number of samples to use for antialiasing
  56058. */
  56059. textureSamples: number;
  56060. /**
  56061. * Ratio object used for SSAO ratio and blur ratio
  56062. */
  56063. private _ratio;
  56064. /**
  56065. * Dynamically generated sphere sampler.
  56066. */
  56067. private _sampleSphere;
  56068. /**
  56069. * Blur filter offsets
  56070. */
  56071. private _samplerOffsets;
  56072. private _expensiveBlur;
  56073. /**
  56074. * If bilateral blur should be used
  56075. */
  56076. expensiveBlur: boolean;
  56077. /**
  56078. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56079. */
  56080. radius: number;
  56081. /**
  56082. * The base color of the SSAO post-process
  56083. * The final result is "base + ssao" between [0, 1]
  56084. */
  56085. base: number;
  56086. /**
  56087. * Support test.
  56088. */
  56089. static readonly IsSupported: boolean;
  56090. private _scene;
  56091. private _depthTexture;
  56092. private _normalTexture;
  56093. private _randomTexture;
  56094. private _originalColorPostProcess;
  56095. private _ssaoPostProcess;
  56096. private _blurHPostProcess;
  56097. private _blurVPostProcess;
  56098. private _ssaoCombinePostProcess;
  56099. private _firstUpdate;
  56100. /**
  56101. * Gets active scene
  56102. */
  56103. readonly scene: Scene;
  56104. /**
  56105. * @constructor
  56106. * @param name The rendering pipeline name
  56107. * @param scene The scene linked to this pipeline
  56108. * @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 }
  56109. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56110. */
  56111. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56112. /**
  56113. * Get the class name
  56114. * @returns "SSAO2RenderingPipeline"
  56115. */
  56116. getClassName(): string;
  56117. /**
  56118. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56119. */
  56120. dispose(disableGeometryBufferRenderer?: boolean): void;
  56121. private _createBlurPostProcess;
  56122. /** @hidden */
  56123. _rebuild(): void;
  56124. private _bits;
  56125. private _radicalInverse_VdC;
  56126. private _hammersley;
  56127. private _hemisphereSample_uniform;
  56128. private _generateHemisphere;
  56129. private _createSSAOPostProcess;
  56130. private _createSSAOCombinePostProcess;
  56131. private _createRandomTexture;
  56132. /**
  56133. * Serialize the rendering pipeline (Used when exporting)
  56134. * @returns the serialized object
  56135. */
  56136. serialize(): any;
  56137. /**
  56138. * Parse the serialized pipeline
  56139. * @param source Source pipeline.
  56140. * @param scene The scene to load the pipeline to.
  56141. * @param rootUrl The URL of the serialized pipeline.
  56142. * @returns An instantiated pipeline from the serialized object.
  56143. */
  56144. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56145. }
  56146. }
  56147. declare module "babylonjs/Shaders/ssao.fragment" {
  56148. /** @hidden */
  56149. export var ssaoPixelShader: {
  56150. name: string;
  56151. shader: string;
  56152. };
  56153. }
  56154. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56155. import { Camera } from "babylonjs/Cameras/camera";
  56156. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56157. import { Scene } from "babylonjs/scene";
  56158. import "babylonjs/Shaders/ssao.fragment";
  56159. import "babylonjs/Shaders/ssaoCombine.fragment";
  56160. /**
  56161. * Render pipeline to produce ssao effect
  56162. */
  56163. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56164. /**
  56165. * @ignore
  56166. * The PassPostProcess id in the pipeline that contains the original scene color
  56167. */
  56168. SSAOOriginalSceneColorEffect: string;
  56169. /**
  56170. * @ignore
  56171. * The SSAO PostProcess id in the pipeline
  56172. */
  56173. SSAORenderEffect: string;
  56174. /**
  56175. * @ignore
  56176. * The horizontal blur PostProcess id in the pipeline
  56177. */
  56178. SSAOBlurHRenderEffect: string;
  56179. /**
  56180. * @ignore
  56181. * The vertical blur PostProcess id in the pipeline
  56182. */
  56183. SSAOBlurVRenderEffect: string;
  56184. /**
  56185. * @ignore
  56186. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56187. */
  56188. SSAOCombineRenderEffect: string;
  56189. /**
  56190. * The output strength of the SSAO post-process. Default value is 1.0.
  56191. */
  56192. totalStrength: number;
  56193. /**
  56194. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56195. */
  56196. radius: number;
  56197. /**
  56198. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56199. * Must not be equal to fallOff and superior to fallOff.
  56200. * Default value is 0.0075
  56201. */
  56202. area: number;
  56203. /**
  56204. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56205. * Must not be equal to area and inferior to area.
  56206. * Default value is 0.000001
  56207. */
  56208. fallOff: number;
  56209. /**
  56210. * The base color of the SSAO post-process
  56211. * The final result is "base + ssao" between [0, 1]
  56212. */
  56213. base: number;
  56214. private _scene;
  56215. private _depthTexture;
  56216. private _randomTexture;
  56217. private _originalColorPostProcess;
  56218. private _ssaoPostProcess;
  56219. private _blurHPostProcess;
  56220. private _blurVPostProcess;
  56221. private _ssaoCombinePostProcess;
  56222. private _firstUpdate;
  56223. /**
  56224. * Gets active scene
  56225. */
  56226. readonly scene: Scene;
  56227. /**
  56228. * @constructor
  56229. * @param name - The rendering pipeline name
  56230. * @param scene - The scene linked to this pipeline
  56231. * @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 }
  56232. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56233. */
  56234. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56235. /**
  56236. * Get the class name
  56237. * @returns "SSAORenderingPipeline"
  56238. */
  56239. getClassName(): string;
  56240. /**
  56241. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56242. */
  56243. dispose(disableDepthRender?: boolean): void;
  56244. private _createBlurPostProcess;
  56245. /** @hidden */
  56246. _rebuild(): void;
  56247. private _createSSAOPostProcess;
  56248. private _createSSAOCombinePostProcess;
  56249. private _createRandomTexture;
  56250. }
  56251. }
  56252. declare module "babylonjs/Shaders/standard.fragment" {
  56253. /** @hidden */
  56254. export var standardPixelShader: {
  56255. name: string;
  56256. shader: string;
  56257. };
  56258. }
  56259. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56260. import { Nullable } from "babylonjs/types";
  56261. import { IAnimatable } from "babylonjs/Misc/tools";
  56262. import { Camera } from "babylonjs/Cameras/camera";
  56263. import { Texture } from "babylonjs/Materials/Textures/texture";
  56264. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56265. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56266. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56267. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56268. import { IDisposable } from "babylonjs/scene";
  56269. import { SpotLight } from "babylonjs/Lights/spotLight";
  56270. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56271. import { Scene } from "babylonjs/scene";
  56272. import { Animation } from "babylonjs/Animations/animation";
  56273. import "babylonjs/Shaders/standard.fragment";
  56274. /**
  56275. * Standard rendering pipeline
  56276. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56277. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56278. */
  56279. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56280. /**
  56281. * Public members
  56282. */
  56283. /**
  56284. * Post-process which contains the original scene color before the pipeline applies all the effects
  56285. */
  56286. originalPostProcess: Nullable<PostProcess>;
  56287. /**
  56288. * Post-process used to down scale an image x4
  56289. */
  56290. downSampleX4PostProcess: Nullable<PostProcess>;
  56291. /**
  56292. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56293. */
  56294. brightPassPostProcess: Nullable<PostProcess>;
  56295. /**
  56296. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56297. */
  56298. blurHPostProcesses: PostProcess[];
  56299. /**
  56300. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56301. */
  56302. blurVPostProcesses: PostProcess[];
  56303. /**
  56304. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56305. */
  56306. textureAdderPostProcess: Nullable<PostProcess>;
  56307. /**
  56308. * Post-process used to create volumetric lighting effect
  56309. */
  56310. volumetricLightPostProcess: Nullable<PostProcess>;
  56311. /**
  56312. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56313. */
  56314. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56315. /**
  56316. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56317. */
  56318. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56319. /**
  56320. * Post-process used to merge the volumetric light effect and the real scene color
  56321. */
  56322. volumetricLightMergePostProces: Nullable<PostProcess>;
  56323. /**
  56324. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56325. */
  56326. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56327. /**
  56328. * Base post-process used to calculate the average luminance of the final image for HDR
  56329. */
  56330. luminancePostProcess: Nullable<PostProcess>;
  56331. /**
  56332. * Post-processes used to create down sample post-processes in order to get
  56333. * the average luminance of the final image for HDR
  56334. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56335. */
  56336. luminanceDownSamplePostProcesses: PostProcess[];
  56337. /**
  56338. * Post-process used to create a HDR effect (light adaptation)
  56339. */
  56340. hdrPostProcess: Nullable<PostProcess>;
  56341. /**
  56342. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56343. */
  56344. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56345. /**
  56346. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56347. */
  56348. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56349. /**
  56350. * Post-process used to merge the final HDR post-process and the real scene color
  56351. */
  56352. hdrFinalPostProcess: Nullable<PostProcess>;
  56353. /**
  56354. * Post-process used to create a lens flare effect
  56355. */
  56356. lensFlarePostProcess: Nullable<PostProcess>;
  56357. /**
  56358. * Post-process that merges the result of the lens flare post-process and the real scene color
  56359. */
  56360. lensFlareComposePostProcess: Nullable<PostProcess>;
  56361. /**
  56362. * Post-process used to create a motion blur effect
  56363. */
  56364. motionBlurPostProcess: Nullable<PostProcess>;
  56365. /**
  56366. * Post-process used to create a depth of field effect
  56367. */
  56368. depthOfFieldPostProcess: Nullable<PostProcess>;
  56369. /**
  56370. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56371. */
  56372. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56373. /**
  56374. * Represents the brightness threshold in order to configure the illuminated surfaces
  56375. */
  56376. brightThreshold: number;
  56377. /**
  56378. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56379. */
  56380. blurWidth: number;
  56381. /**
  56382. * Sets if the blur for highlighted surfaces must be only horizontal
  56383. */
  56384. horizontalBlur: boolean;
  56385. /**
  56386. * Gets the overall exposure used by the pipeline
  56387. */
  56388. /**
  56389. * Sets the overall exposure used by the pipeline
  56390. */
  56391. exposure: number;
  56392. /**
  56393. * Texture used typically to simulate "dirty" on camera lens
  56394. */
  56395. lensTexture: Nullable<Texture>;
  56396. /**
  56397. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56398. */
  56399. volumetricLightCoefficient: number;
  56400. /**
  56401. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56402. */
  56403. volumetricLightPower: number;
  56404. /**
  56405. * Used the set the blur intensity to smooth the volumetric lights
  56406. */
  56407. volumetricLightBlurScale: number;
  56408. /**
  56409. * Light (spot or directional) used to generate the volumetric lights rays
  56410. * The source light must have a shadow generate so the pipeline can get its
  56411. * depth map
  56412. */
  56413. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56414. /**
  56415. * For eye adaptation, represents the minimum luminance the eye can see
  56416. */
  56417. hdrMinimumLuminance: number;
  56418. /**
  56419. * For eye adaptation, represents the decrease luminance speed
  56420. */
  56421. hdrDecreaseRate: number;
  56422. /**
  56423. * For eye adaptation, represents the increase luminance speed
  56424. */
  56425. hdrIncreaseRate: number;
  56426. /**
  56427. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56428. */
  56429. /**
  56430. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56431. */
  56432. hdrAutoExposure: boolean;
  56433. /**
  56434. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56435. */
  56436. lensColorTexture: Nullable<Texture>;
  56437. /**
  56438. * The overall strengh for the lens flare effect
  56439. */
  56440. lensFlareStrength: number;
  56441. /**
  56442. * Dispersion coefficient for lens flare ghosts
  56443. */
  56444. lensFlareGhostDispersal: number;
  56445. /**
  56446. * Main lens flare halo width
  56447. */
  56448. lensFlareHaloWidth: number;
  56449. /**
  56450. * Based on the lens distortion effect, defines how much the lens flare result
  56451. * is distorted
  56452. */
  56453. lensFlareDistortionStrength: number;
  56454. /**
  56455. * Lens star texture must be used to simulate rays on the flares and is available
  56456. * in the documentation
  56457. */
  56458. lensStarTexture: Nullable<Texture>;
  56459. /**
  56460. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56461. * flare effect by taking account of the dirt texture
  56462. */
  56463. lensFlareDirtTexture: Nullable<Texture>;
  56464. /**
  56465. * Represents the focal length for the depth of field effect
  56466. */
  56467. depthOfFieldDistance: number;
  56468. /**
  56469. * Represents the blur intensity for the blurred part of the depth of field effect
  56470. */
  56471. depthOfFieldBlurWidth: number;
  56472. /**
  56473. * For motion blur, defines how much the image is blurred by the movement
  56474. */
  56475. motionStrength: number;
  56476. /**
  56477. * List of animations for the pipeline (IAnimatable implementation)
  56478. */
  56479. animations: Animation[];
  56480. /**
  56481. * Private members
  56482. */
  56483. private _scene;
  56484. private _currentDepthOfFieldSource;
  56485. private _basePostProcess;
  56486. private _fixedExposure;
  56487. private _currentExposure;
  56488. private _hdrAutoExposure;
  56489. private _hdrCurrentLuminance;
  56490. private _floatTextureType;
  56491. private _ratio;
  56492. private _bloomEnabled;
  56493. private _depthOfFieldEnabled;
  56494. private _vlsEnabled;
  56495. private _lensFlareEnabled;
  56496. private _hdrEnabled;
  56497. private _motionBlurEnabled;
  56498. private _fxaaEnabled;
  56499. private _motionBlurSamples;
  56500. private _volumetricLightStepsCount;
  56501. private _samples;
  56502. /**
  56503. * @ignore
  56504. * Specifies if the bloom pipeline is enabled
  56505. */
  56506. BloomEnabled: boolean;
  56507. /**
  56508. * @ignore
  56509. * Specifies if the depth of field pipeline is enabed
  56510. */
  56511. DepthOfFieldEnabled: boolean;
  56512. /**
  56513. * @ignore
  56514. * Specifies if the lens flare pipeline is enabed
  56515. */
  56516. LensFlareEnabled: boolean;
  56517. /**
  56518. * @ignore
  56519. * Specifies if the HDR pipeline is enabled
  56520. */
  56521. HDREnabled: boolean;
  56522. /**
  56523. * @ignore
  56524. * Specifies if the volumetric lights scattering effect is enabled
  56525. */
  56526. VLSEnabled: boolean;
  56527. /**
  56528. * @ignore
  56529. * Specifies if the motion blur effect is enabled
  56530. */
  56531. MotionBlurEnabled: boolean;
  56532. /**
  56533. * Specifies if anti-aliasing is enabled
  56534. */
  56535. fxaaEnabled: boolean;
  56536. /**
  56537. * Specifies the number of steps used to calculate the volumetric lights
  56538. * Typically in interval [50, 200]
  56539. */
  56540. volumetricLightStepsCount: number;
  56541. /**
  56542. * Specifies the number of samples used for the motion blur effect
  56543. * Typically in interval [16, 64]
  56544. */
  56545. motionBlurSamples: number;
  56546. /**
  56547. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56548. */
  56549. samples: number;
  56550. /**
  56551. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56552. * @constructor
  56553. * @param name The rendering pipeline name
  56554. * @param scene The scene linked to this pipeline
  56555. * @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)
  56556. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56557. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56558. */
  56559. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56560. private _buildPipeline;
  56561. private _createDownSampleX4PostProcess;
  56562. private _createBrightPassPostProcess;
  56563. private _createBlurPostProcesses;
  56564. private _createTextureAdderPostProcess;
  56565. private _createVolumetricLightPostProcess;
  56566. private _createLuminancePostProcesses;
  56567. private _createHdrPostProcess;
  56568. private _createLensFlarePostProcess;
  56569. private _createDepthOfFieldPostProcess;
  56570. private _createMotionBlurPostProcess;
  56571. private _getDepthTexture;
  56572. private _disposePostProcesses;
  56573. /**
  56574. * Dispose of the pipeline and stop all post processes
  56575. */
  56576. dispose(): void;
  56577. /**
  56578. * Serialize the rendering pipeline (Used when exporting)
  56579. * @returns the serialized object
  56580. */
  56581. serialize(): any;
  56582. /**
  56583. * Parse the serialized pipeline
  56584. * @param source Source pipeline.
  56585. * @param scene The scene to load the pipeline to.
  56586. * @param rootUrl The URL of the serialized pipeline.
  56587. * @returns An instantiated pipeline from the serialized object.
  56588. */
  56589. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56590. /**
  56591. * Luminance steps
  56592. */
  56593. static LuminanceSteps: number;
  56594. }
  56595. }
  56596. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56597. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56598. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56599. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56600. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56601. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56602. }
  56603. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56604. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56605. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56606. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56607. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56608. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56609. }
  56610. declare module "babylonjs/Shaders/tonemap.fragment" {
  56611. /** @hidden */
  56612. export var tonemapPixelShader: {
  56613. name: string;
  56614. shader: string;
  56615. };
  56616. }
  56617. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56618. import { Camera } from "babylonjs/Cameras/camera";
  56619. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56620. import "babylonjs/Shaders/tonemap.fragment";
  56621. import { Engine } from "babylonjs/Engines/engine";
  56622. /** Defines operator used for tonemapping */
  56623. export enum TonemappingOperator {
  56624. /** Hable */
  56625. Hable = 0,
  56626. /** Reinhard */
  56627. Reinhard = 1,
  56628. /** HejiDawson */
  56629. HejiDawson = 2,
  56630. /** Photographic */
  56631. Photographic = 3
  56632. }
  56633. /**
  56634. * Defines a post process to apply tone mapping
  56635. */
  56636. export class TonemapPostProcess extends PostProcess {
  56637. private _operator;
  56638. /** Defines the required exposure adjustement */
  56639. exposureAdjustment: number;
  56640. /**
  56641. * Creates a new TonemapPostProcess
  56642. * @param name defines the name of the postprocess
  56643. * @param _operator defines the operator to use
  56644. * @param exposureAdjustment defines the required exposure adjustement
  56645. * @param camera defines the camera to use (can be null)
  56646. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56647. * @param engine defines the hosting engine (can be ignore if camera is set)
  56648. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56649. */
  56650. constructor(name: string, _operator: TonemappingOperator,
  56651. /** Defines the required exposure adjustement */
  56652. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56653. }
  56654. }
  56655. declare module "babylonjs/Shaders/depth.vertex" {
  56656. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56657. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56658. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56659. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56660. /** @hidden */
  56661. export var depthVertexShader: {
  56662. name: string;
  56663. shader: string;
  56664. };
  56665. }
  56666. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56667. /** @hidden */
  56668. export var volumetricLightScatteringPixelShader: {
  56669. name: string;
  56670. shader: string;
  56671. };
  56672. }
  56673. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56674. /** @hidden */
  56675. export var volumetricLightScatteringPassPixelShader: {
  56676. name: string;
  56677. shader: string;
  56678. };
  56679. }
  56680. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56681. import { Vector3 } from "babylonjs/Maths/math";
  56682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56683. import { Mesh } from "babylonjs/Meshes/mesh";
  56684. import { Camera } from "babylonjs/Cameras/camera";
  56685. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56686. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56687. import { Scene } from "babylonjs/scene";
  56688. import "babylonjs/Meshes/Builders/planeBuilder";
  56689. import "babylonjs/Shaders/depth.vertex";
  56690. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  56691. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  56692. import { Engine } from "babylonjs/Engines/engine";
  56693. /**
  56694. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56695. */
  56696. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56697. private _volumetricLightScatteringPass;
  56698. private _volumetricLightScatteringRTT;
  56699. private _viewPort;
  56700. private _screenCoordinates;
  56701. private _cachedDefines;
  56702. /**
  56703. * If not undefined, the mesh position is computed from the attached node position
  56704. */
  56705. attachedNode: {
  56706. position: Vector3;
  56707. };
  56708. /**
  56709. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56710. */
  56711. customMeshPosition: Vector3;
  56712. /**
  56713. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56714. */
  56715. useCustomMeshPosition: boolean;
  56716. /**
  56717. * If the post-process should inverse the light scattering direction
  56718. */
  56719. invert: boolean;
  56720. /**
  56721. * The internal mesh used by the post-process
  56722. */
  56723. mesh: Mesh;
  56724. /**
  56725. * @hidden
  56726. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56727. */
  56728. useDiffuseColor: boolean;
  56729. /**
  56730. * Array containing the excluded meshes not rendered in the internal pass
  56731. */
  56732. excludedMeshes: AbstractMesh[];
  56733. /**
  56734. * Controls the overall intensity of the post-process
  56735. */
  56736. exposure: number;
  56737. /**
  56738. * Dissipates each sample's contribution in range [0, 1]
  56739. */
  56740. decay: number;
  56741. /**
  56742. * Controls the overall intensity of each sample
  56743. */
  56744. weight: number;
  56745. /**
  56746. * Controls the density of each sample
  56747. */
  56748. density: number;
  56749. /**
  56750. * @constructor
  56751. * @param name The post-process name
  56752. * @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)
  56753. * @param camera The camera that the post-process will be attached to
  56754. * @param mesh The mesh used to create the light scattering
  56755. * @param samples The post-process quality, default 100
  56756. * @param samplingModeThe post-process filtering mode
  56757. * @param engine The babylon engine
  56758. * @param reusable If the post-process is reusable
  56759. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56760. */
  56761. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56762. /**
  56763. * Returns the string "VolumetricLightScatteringPostProcess"
  56764. * @returns "VolumetricLightScatteringPostProcess"
  56765. */
  56766. getClassName(): string;
  56767. private _isReady;
  56768. /**
  56769. * Sets the new light position for light scattering effect
  56770. * @param position The new custom light position
  56771. */
  56772. setCustomMeshPosition(position: Vector3): void;
  56773. /**
  56774. * Returns the light position for light scattering effect
  56775. * @return Vector3 The custom light position
  56776. */
  56777. getCustomMeshPosition(): Vector3;
  56778. /**
  56779. * Disposes the internal assets and detaches the post-process from the camera
  56780. */
  56781. dispose(camera: Camera): void;
  56782. /**
  56783. * Returns the render target texture used by the post-process
  56784. * @return the render target texture used by the post-process
  56785. */
  56786. getPass(): RenderTargetTexture;
  56787. private _meshExcluded;
  56788. private _createPass;
  56789. private _updateMeshScreenCoordinates;
  56790. /**
  56791. * Creates a default mesh for the Volumeric Light Scattering post-process
  56792. * @param name The mesh name
  56793. * @param scene The scene where to create the mesh
  56794. * @return the default mesh
  56795. */
  56796. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56797. }
  56798. }
  56799. declare module "babylonjs/PostProcesses/index" {
  56800. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56801. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56802. export * from "babylonjs/PostProcesses/bloomEffect";
  56803. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56804. export * from "babylonjs/PostProcesses/blurPostProcess";
  56805. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56806. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56807. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56808. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56809. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56810. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56811. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56812. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56813. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56814. export * from "babylonjs/PostProcesses/filterPostProcess";
  56815. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56816. export * from "babylonjs/PostProcesses/grainPostProcess";
  56817. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56818. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56819. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56820. export * from "babylonjs/PostProcesses/passPostProcess";
  56821. export * from "babylonjs/PostProcesses/postProcess";
  56822. export * from "babylonjs/PostProcesses/postProcessManager";
  56823. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56824. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56825. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56826. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56827. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56828. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56829. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56830. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  56831. }
  56832. declare module "babylonjs/Probes/index" {
  56833. export * from "babylonjs/Probes/reflectionProbe";
  56834. }
  56835. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56836. import { Scene } from "babylonjs/scene";
  56837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56838. import { Color3 } from "babylonjs/Maths/math";
  56839. import { SmartArray } from "babylonjs/Misc/smartArray";
  56840. import { ISceneComponent } from "babylonjs/sceneComponent";
  56841. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56842. import "babylonjs/Meshes/Builders/boxBuilder";
  56843. import "babylonjs/Shaders/color.fragment";
  56844. import "babylonjs/Shaders/color.vertex";
  56845. module "babylonjs/scene" {
  56846. interface Scene {
  56847. /** @hidden (Backing field) */
  56848. _boundingBoxRenderer: BoundingBoxRenderer;
  56849. /** @hidden (Backing field) */
  56850. _forceShowBoundingBoxes: boolean;
  56851. /**
  56852. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56853. */
  56854. forceShowBoundingBoxes: boolean;
  56855. /**
  56856. * Gets the bounding box renderer associated with the scene
  56857. * @returns a BoundingBoxRenderer
  56858. */
  56859. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56860. }
  56861. }
  56862. module "babylonjs/Meshes/abstractMesh" {
  56863. interface AbstractMesh {
  56864. /** @hidden (Backing field) */
  56865. _showBoundingBox: boolean;
  56866. /**
  56867. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56868. */
  56869. showBoundingBox: boolean;
  56870. }
  56871. }
  56872. /**
  56873. * Component responsible of rendering the bounding box of the meshes in a scene.
  56874. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56875. */
  56876. export class BoundingBoxRenderer implements ISceneComponent {
  56877. /**
  56878. * The component name helpfull to identify the component in the list of scene components.
  56879. */
  56880. readonly name: string;
  56881. /**
  56882. * The scene the component belongs to.
  56883. */
  56884. scene: Scene;
  56885. /**
  56886. * Color of the bounding box lines placed in front of an object
  56887. */
  56888. frontColor: Color3;
  56889. /**
  56890. * Color of the bounding box lines placed behind an object
  56891. */
  56892. backColor: Color3;
  56893. /**
  56894. * Defines if the renderer should show the back lines or not
  56895. */
  56896. showBackLines: boolean;
  56897. /**
  56898. * @hidden
  56899. */
  56900. renderList: SmartArray<BoundingBox>;
  56901. private _colorShader;
  56902. private _vertexBuffers;
  56903. private _indexBuffer;
  56904. /**
  56905. * Instantiates a new bounding box renderer in a scene.
  56906. * @param scene the scene the renderer renders in
  56907. */
  56908. constructor(scene: Scene);
  56909. /**
  56910. * Registers the component in a given scene
  56911. */
  56912. register(): void;
  56913. private _evaluateSubMesh;
  56914. private _activeMesh;
  56915. private _prepareRessources;
  56916. private _createIndexBuffer;
  56917. /**
  56918. * Rebuilds the elements related to this component in case of
  56919. * context lost for instance.
  56920. */
  56921. rebuild(): void;
  56922. /**
  56923. * @hidden
  56924. */
  56925. reset(): void;
  56926. /**
  56927. * Render the bounding boxes of a specific rendering group
  56928. * @param renderingGroupId defines the rendering group to render
  56929. */
  56930. render(renderingGroupId: number): void;
  56931. /**
  56932. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56933. * @param mesh Define the mesh to render the occlusion bounding box for
  56934. */
  56935. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56936. /**
  56937. * Dispose and release the resources attached to this renderer.
  56938. */
  56939. dispose(): void;
  56940. }
  56941. }
  56942. declare module "babylonjs/Shaders/depth.fragment" {
  56943. /** @hidden */
  56944. export var depthPixelShader: {
  56945. name: string;
  56946. shader: string;
  56947. };
  56948. }
  56949. declare module "babylonjs/Rendering/depthRenderer" {
  56950. import { Nullable } from "babylonjs/types";
  56951. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56952. import { Scene } from "babylonjs/scene";
  56953. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56954. import { Camera } from "babylonjs/Cameras/camera";
  56955. import "babylonjs/Shaders/depth.fragment";
  56956. import "babylonjs/Shaders/depth.vertex";
  56957. /**
  56958. * This represents a depth renderer in Babylon.
  56959. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56960. */
  56961. export class DepthRenderer {
  56962. private _scene;
  56963. private _depthMap;
  56964. private _effect;
  56965. private _cachedDefines;
  56966. private _camera;
  56967. /**
  56968. * Specifiess that the depth renderer will only be used within
  56969. * the camera it is created for.
  56970. * This can help forcing its rendering during the camera processing.
  56971. */
  56972. useOnlyInActiveCamera: boolean;
  56973. /** @hidden */
  56974. static _SceneComponentInitialization: (scene: Scene) => void;
  56975. /**
  56976. * Instantiates a depth renderer
  56977. * @param scene The scene the renderer belongs to
  56978. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56979. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56980. */
  56981. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56982. /**
  56983. * Creates the depth rendering effect and checks if the effect is ready.
  56984. * @param subMesh The submesh to be used to render the depth map of
  56985. * @param useInstances If multiple world instances should be used
  56986. * @returns if the depth renderer is ready to render the depth map
  56987. */
  56988. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56989. /**
  56990. * Gets the texture which the depth map will be written to.
  56991. * @returns The depth map texture
  56992. */
  56993. getDepthMap(): RenderTargetTexture;
  56994. /**
  56995. * Disposes of the depth renderer.
  56996. */
  56997. dispose(): void;
  56998. }
  56999. }
  57000. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57001. import { Nullable } from "babylonjs/types";
  57002. import { Scene } from "babylonjs/scene";
  57003. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57004. import { Camera } from "babylonjs/Cameras/camera";
  57005. import { ISceneComponent } from "babylonjs/sceneComponent";
  57006. module "babylonjs/scene" {
  57007. interface Scene {
  57008. /** @hidden (Backing field) */
  57009. _depthRenderer: {
  57010. [id: string]: DepthRenderer;
  57011. };
  57012. /**
  57013. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57014. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57015. * @returns the created depth renderer
  57016. */
  57017. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57018. /**
  57019. * Disables a depth renderer for a given camera
  57020. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57021. */
  57022. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57023. }
  57024. }
  57025. /**
  57026. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57027. * in several rendering techniques.
  57028. */
  57029. export class DepthRendererSceneComponent implements ISceneComponent {
  57030. /**
  57031. * The component name helpfull to identify the component in the list of scene components.
  57032. */
  57033. readonly name: string;
  57034. /**
  57035. * The scene the component belongs to.
  57036. */
  57037. scene: Scene;
  57038. /**
  57039. * Creates a new instance of the component for the given scene
  57040. * @param scene Defines the scene to register the component in
  57041. */
  57042. constructor(scene: Scene);
  57043. /**
  57044. * Registers the component in a given scene
  57045. */
  57046. register(): void;
  57047. /**
  57048. * Rebuilds the elements related to this component in case of
  57049. * context lost for instance.
  57050. */
  57051. rebuild(): void;
  57052. /**
  57053. * Disposes the component and the associated ressources
  57054. */
  57055. dispose(): void;
  57056. private _gatherRenderTargets;
  57057. private _gatherActiveCameraRenderTargets;
  57058. }
  57059. }
  57060. declare module "babylonjs/Shaders/outline.fragment" {
  57061. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57062. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57063. /** @hidden */
  57064. export var outlinePixelShader: {
  57065. name: string;
  57066. shader: string;
  57067. };
  57068. }
  57069. declare module "babylonjs/Shaders/outline.vertex" {
  57070. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57071. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57072. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57073. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57074. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57075. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57076. /** @hidden */
  57077. export var outlineVertexShader: {
  57078. name: string;
  57079. shader: string;
  57080. };
  57081. }
  57082. declare module "babylonjs/Rendering/outlineRenderer" {
  57083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57084. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57085. import { Scene } from "babylonjs/scene";
  57086. import { ISceneComponent } from "babylonjs/sceneComponent";
  57087. import "babylonjs/Shaders/outline.fragment";
  57088. import "babylonjs/Shaders/outline.vertex";
  57089. module "babylonjs/scene" {
  57090. interface Scene {
  57091. /** @hidden */
  57092. _outlineRenderer: OutlineRenderer;
  57093. /**
  57094. * Gets the outline renderer associated with the scene
  57095. * @returns a OutlineRenderer
  57096. */
  57097. getOutlineRenderer(): OutlineRenderer;
  57098. }
  57099. }
  57100. module "babylonjs/Meshes/abstractMesh" {
  57101. interface AbstractMesh {
  57102. /** @hidden (Backing field) */
  57103. _renderOutline: boolean;
  57104. /**
  57105. * Gets or sets a boolean indicating if the outline must be rendered as well
  57106. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57107. */
  57108. renderOutline: boolean;
  57109. /** @hidden (Backing field) */
  57110. _renderOverlay: boolean;
  57111. /**
  57112. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57113. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57114. */
  57115. renderOverlay: boolean;
  57116. }
  57117. }
  57118. /**
  57119. * This class is responsible to draw bothe outline/overlay of meshes.
  57120. * It should not be used directly but through the available method on mesh.
  57121. */
  57122. export class OutlineRenderer implements ISceneComponent {
  57123. /**
  57124. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57125. */
  57126. private static _StencilReference;
  57127. /**
  57128. * The name of the component. Each component must have a unique name.
  57129. */
  57130. name: string;
  57131. /**
  57132. * The scene the component belongs to.
  57133. */
  57134. scene: Scene;
  57135. /**
  57136. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57137. */
  57138. zOffset: number;
  57139. private _engine;
  57140. private _effect;
  57141. private _cachedDefines;
  57142. private _savedDepthWrite;
  57143. /**
  57144. * Instantiates a new outline renderer. (There could be only one per scene).
  57145. * @param scene Defines the scene it belongs to
  57146. */
  57147. constructor(scene: Scene);
  57148. /**
  57149. * Register the component to one instance of a scene.
  57150. */
  57151. register(): void;
  57152. /**
  57153. * Rebuilds the elements related to this component in case of
  57154. * context lost for instance.
  57155. */
  57156. rebuild(): void;
  57157. /**
  57158. * Disposes the component and the associated ressources.
  57159. */
  57160. dispose(): void;
  57161. /**
  57162. * Renders the outline in the canvas.
  57163. * @param subMesh Defines the sumesh to render
  57164. * @param batch Defines the batch of meshes in case of instances
  57165. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57166. */
  57167. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57168. /**
  57169. * Returns whether or not the outline renderer is ready for a given submesh.
  57170. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57171. * @param subMesh Defines the submesh to check readyness for
  57172. * @param useInstances Defines wheter wee are trying to render instances or not
  57173. * @returns true if ready otherwise false
  57174. */
  57175. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57176. private _beforeRenderingMesh;
  57177. private _afterRenderingMesh;
  57178. }
  57179. }
  57180. declare module "babylonjs/Rendering/index" {
  57181. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57182. export * from "babylonjs/Rendering/depthRenderer";
  57183. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57184. export * from "babylonjs/Rendering/edgesRenderer";
  57185. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57186. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57187. export * from "babylonjs/Rendering/outlineRenderer";
  57188. export * from "babylonjs/Rendering/renderingGroup";
  57189. export * from "babylonjs/Rendering/renderingManager";
  57190. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57191. }
  57192. declare module "babylonjs/Sprites/index" {
  57193. export * from "babylonjs/Sprites/sprite";
  57194. export * from "babylonjs/Sprites/spriteManager";
  57195. export * from "babylonjs/Sprites/spriteSceneComponent";
  57196. }
  57197. declare module "babylonjs/Misc/assetsManager" {
  57198. import { Scene } from "babylonjs/scene";
  57199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57200. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57201. import { Skeleton } from "babylonjs/Bones/skeleton";
  57202. import { Observable } from "babylonjs/Misc/observable";
  57203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57204. import { Texture } from "babylonjs/Materials/Textures/texture";
  57205. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57206. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57207. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57208. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57209. /**
  57210. * Defines the list of states available for a task inside a AssetsManager
  57211. */
  57212. export enum AssetTaskState {
  57213. /**
  57214. * Initialization
  57215. */
  57216. INIT = 0,
  57217. /**
  57218. * Running
  57219. */
  57220. RUNNING = 1,
  57221. /**
  57222. * Done
  57223. */
  57224. DONE = 2,
  57225. /**
  57226. * Error
  57227. */
  57228. ERROR = 3
  57229. }
  57230. /**
  57231. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57232. */
  57233. export abstract class AbstractAssetTask {
  57234. /**
  57235. * Task name
  57236. */ name: string;
  57237. /**
  57238. * Callback called when the task is successful
  57239. */
  57240. onSuccess: (task: any) => void;
  57241. /**
  57242. * Callback called when the task is not successful
  57243. */
  57244. onError: (task: any, message?: string, exception?: any) => void;
  57245. /**
  57246. * Creates a new AssetsManager
  57247. * @param name defines the name of the task
  57248. */
  57249. constructor(
  57250. /**
  57251. * Task name
  57252. */ name: string);
  57253. private _isCompleted;
  57254. private _taskState;
  57255. private _errorObject;
  57256. /**
  57257. * Get if the task is completed
  57258. */
  57259. readonly isCompleted: boolean;
  57260. /**
  57261. * Gets the current state of the task
  57262. */
  57263. readonly taskState: AssetTaskState;
  57264. /**
  57265. * Gets the current error object (if task is in error)
  57266. */
  57267. readonly errorObject: {
  57268. message?: string;
  57269. exception?: any;
  57270. };
  57271. /**
  57272. * Internal only
  57273. * @hidden
  57274. */
  57275. _setErrorObject(message?: string, exception?: any): void;
  57276. /**
  57277. * Execute the current task
  57278. * @param scene defines the scene where you want your assets to be loaded
  57279. * @param onSuccess is a callback called when the task is successfully executed
  57280. * @param onError is a callback called if an error occurs
  57281. */
  57282. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57283. /**
  57284. * Execute the current task
  57285. * @param scene defines the scene where you want your assets to be loaded
  57286. * @param onSuccess is a callback called when the task is successfully executed
  57287. * @param onError is a callback called if an error occurs
  57288. */
  57289. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57290. /**
  57291. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57292. * This can be used with failed tasks that have the reason for failure fixed.
  57293. */
  57294. reset(): void;
  57295. private onErrorCallback;
  57296. private onDoneCallback;
  57297. }
  57298. /**
  57299. * Define the interface used by progress events raised during assets loading
  57300. */
  57301. export interface IAssetsProgressEvent {
  57302. /**
  57303. * Defines the number of remaining tasks to process
  57304. */
  57305. remainingCount: number;
  57306. /**
  57307. * Defines the total number of tasks
  57308. */
  57309. totalCount: number;
  57310. /**
  57311. * Defines the task that was just processed
  57312. */
  57313. task: AbstractAssetTask;
  57314. }
  57315. /**
  57316. * Class used to share progress information about assets loading
  57317. */
  57318. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57319. /**
  57320. * Defines the number of remaining tasks to process
  57321. */
  57322. remainingCount: number;
  57323. /**
  57324. * Defines the total number of tasks
  57325. */
  57326. totalCount: number;
  57327. /**
  57328. * Defines the task that was just processed
  57329. */
  57330. task: AbstractAssetTask;
  57331. /**
  57332. * Creates a AssetsProgressEvent
  57333. * @param remainingCount defines the number of remaining tasks to process
  57334. * @param totalCount defines the total number of tasks
  57335. * @param task defines the task that was just processed
  57336. */
  57337. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57338. }
  57339. /**
  57340. * Define a task used by AssetsManager to load meshes
  57341. */
  57342. export class MeshAssetTask extends AbstractAssetTask {
  57343. /**
  57344. * Defines the name of the task
  57345. */
  57346. name: string;
  57347. /**
  57348. * Defines the list of mesh's names you want to load
  57349. */
  57350. meshesNames: any;
  57351. /**
  57352. * Defines the root url to use as a base to load your meshes and associated resources
  57353. */
  57354. rootUrl: string;
  57355. /**
  57356. * Defines the filename of the scene to load from
  57357. */
  57358. sceneFilename: string;
  57359. /**
  57360. * Gets the list of loaded meshes
  57361. */
  57362. loadedMeshes: Array<AbstractMesh>;
  57363. /**
  57364. * Gets the list of loaded particle systems
  57365. */
  57366. loadedParticleSystems: Array<IParticleSystem>;
  57367. /**
  57368. * Gets the list of loaded skeletons
  57369. */
  57370. loadedSkeletons: Array<Skeleton>;
  57371. /**
  57372. * Gets the list of loaded animation groups
  57373. */
  57374. loadedAnimationGroups: Array<AnimationGroup>;
  57375. /**
  57376. * Callback called when the task is successful
  57377. */
  57378. onSuccess: (task: MeshAssetTask) => void;
  57379. /**
  57380. * Callback called when the task is successful
  57381. */
  57382. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57383. /**
  57384. * Creates a new MeshAssetTask
  57385. * @param name defines the name of the task
  57386. * @param meshesNames defines the list of mesh's names you want to load
  57387. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57388. * @param sceneFilename defines the filename of the scene to load from
  57389. */
  57390. constructor(
  57391. /**
  57392. * Defines the name of the task
  57393. */
  57394. name: string,
  57395. /**
  57396. * Defines the list of mesh's names you want to load
  57397. */
  57398. meshesNames: any,
  57399. /**
  57400. * Defines the root url to use as a base to load your meshes and associated resources
  57401. */
  57402. rootUrl: string,
  57403. /**
  57404. * Defines the filename of the scene to load from
  57405. */
  57406. sceneFilename: string);
  57407. /**
  57408. * Execute the current task
  57409. * @param scene defines the scene where you want your assets to be loaded
  57410. * @param onSuccess is a callback called when the task is successfully executed
  57411. * @param onError is a callback called if an error occurs
  57412. */
  57413. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57414. }
  57415. /**
  57416. * Define a task used by AssetsManager to load text content
  57417. */
  57418. export class TextFileAssetTask extends AbstractAssetTask {
  57419. /**
  57420. * Defines the name of the task
  57421. */
  57422. name: string;
  57423. /**
  57424. * Defines the location of the file to load
  57425. */
  57426. url: string;
  57427. /**
  57428. * Gets the loaded text string
  57429. */
  57430. text: string;
  57431. /**
  57432. * Callback called when the task is successful
  57433. */
  57434. onSuccess: (task: TextFileAssetTask) => void;
  57435. /**
  57436. * Callback called when the task is successful
  57437. */
  57438. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57439. /**
  57440. * Creates a new TextFileAssetTask object
  57441. * @param name defines the name of the task
  57442. * @param url defines the location of the file to load
  57443. */
  57444. constructor(
  57445. /**
  57446. * Defines the name of the task
  57447. */
  57448. name: string,
  57449. /**
  57450. * Defines the location of the file to load
  57451. */
  57452. url: string);
  57453. /**
  57454. * Execute the current task
  57455. * @param scene defines the scene where you want your assets to be loaded
  57456. * @param onSuccess is a callback called when the task is successfully executed
  57457. * @param onError is a callback called if an error occurs
  57458. */
  57459. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57460. }
  57461. /**
  57462. * Define a task used by AssetsManager to load binary data
  57463. */
  57464. export class BinaryFileAssetTask extends AbstractAssetTask {
  57465. /**
  57466. * Defines the name of the task
  57467. */
  57468. name: string;
  57469. /**
  57470. * Defines the location of the file to load
  57471. */
  57472. url: string;
  57473. /**
  57474. * Gets the lodaded data (as an array buffer)
  57475. */
  57476. data: ArrayBuffer;
  57477. /**
  57478. * Callback called when the task is successful
  57479. */
  57480. onSuccess: (task: BinaryFileAssetTask) => void;
  57481. /**
  57482. * Callback called when the task is successful
  57483. */
  57484. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57485. /**
  57486. * Creates a new BinaryFileAssetTask object
  57487. * @param name defines the name of the new task
  57488. * @param url defines the location of the file to load
  57489. */
  57490. constructor(
  57491. /**
  57492. * Defines the name of the task
  57493. */
  57494. name: string,
  57495. /**
  57496. * Defines the location of the file to load
  57497. */
  57498. url: string);
  57499. /**
  57500. * Execute the current task
  57501. * @param scene defines the scene where you want your assets to be loaded
  57502. * @param onSuccess is a callback called when the task is successfully executed
  57503. * @param onError is a callback called if an error occurs
  57504. */
  57505. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57506. }
  57507. /**
  57508. * Define a task used by AssetsManager to load images
  57509. */
  57510. export class ImageAssetTask extends AbstractAssetTask {
  57511. /**
  57512. * Defines the name of the task
  57513. */
  57514. name: string;
  57515. /**
  57516. * Defines the location of the image to load
  57517. */
  57518. url: string;
  57519. /**
  57520. * Gets the loaded images
  57521. */
  57522. image: HTMLImageElement;
  57523. /**
  57524. * Callback called when the task is successful
  57525. */
  57526. onSuccess: (task: ImageAssetTask) => void;
  57527. /**
  57528. * Callback called when the task is successful
  57529. */
  57530. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57531. /**
  57532. * Creates a new ImageAssetTask
  57533. * @param name defines the name of the task
  57534. * @param url defines the location of the image to load
  57535. */
  57536. constructor(
  57537. /**
  57538. * Defines the name of the task
  57539. */
  57540. name: string,
  57541. /**
  57542. * Defines the location of the image to load
  57543. */
  57544. url: string);
  57545. /**
  57546. * Execute the current task
  57547. * @param scene defines the scene where you want your assets to be loaded
  57548. * @param onSuccess is a callback called when the task is successfully executed
  57549. * @param onError is a callback called if an error occurs
  57550. */
  57551. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57552. }
  57553. /**
  57554. * Defines the interface used by texture loading tasks
  57555. */
  57556. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57557. /**
  57558. * Gets the loaded texture
  57559. */
  57560. texture: TEX;
  57561. }
  57562. /**
  57563. * Define a task used by AssetsManager to load 2D textures
  57564. */
  57565. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57566. /**
  57567. * Defines the name of the task
  57568. */
  57569. name: string;
  57570. /**
  57571. * Defines the location of the file to load
  57572. */
  57573. url: string;
  57574. /**
  57575. * Defines if mipmap should not be generated (default is false)
  57576. */
  57577. noMipmap?: boolean | undefined;
  57578. /**
  57579. * Defines if texture must be inverted on Y axis (default is false)
  57580. */
  57581. invertY?: boolean | undefined;
  57582. /**
  57583. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57584. */
  57585. samplingMode: number;
  57586. /**
  57587. * Gets the loaded texture
  57588. */
  57589. texture: Texture;
  57590. /**
  57591. * Callback called when the task is successful
  57592. */
  57593. onSuccess: (task: TextureAssetTask) => void;
  57594. /**
  57595. * Callback called when the task is successful
  57596. */
  57597. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57598. /**
  57599. * Creates a new TextureAssetTask object
  57600. * @param name defines the name of the task
  57601. * @param url defines the location of the file to load
  57602. * @param noMipmap defines if mipmap should not be generated (default is false)
  57603. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57604. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57605. */
  57606. constructor(
  57607. /**
  57608. * Defines the name of the task
  57609. */
  57610. name: string,
  57611. /**
  57612. * Defines the location of the file to load
  57613. */
  57614. url: string,
  57615. /**
  57616. * Defines if mipmap should not be generated (default is false)
  57617. */
  57618. noMipmap?: boolean | undefined,
  57619. /**
  57620. * Defines if texture must be inverted on Y axis (default is false)
  57621. */
  57622. invertY?: boolean | undefined,
  57623. /**
  57624. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57625. */
  57626. samplingMode?: number);
  57627. /**
  57628. * Execute the current task
  57629. * @param scene defines the scene where you want your assets to be loaded
  57630. * @param onSuccess is a callback called when the task is successfully executed
  57631. * @param onError is a callback called if an error occurs
  57632. */
  57633. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57634. }
  57635. /**
  57636. * Define a task used by AssetsManager to load cube textures
  57637. */
  57638. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57639. /**
  57640. * Defines the name of the task
  57641. */
  57642. name: string;
  57643. /**
  57644. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57645. */
  57646. url: string;
  57647. /**
  57648. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57649. */
  57650. extensions?: string[] | undefined;
  57651. /**
  57652. * Defines if mipmaps should not be generated (default is false)
  57653. */
  57654. noMipmap?: boolean | undefined;
  57655. /**
  57656. * Defines the explicit list of files (undefined by default)
  57657. */
  57658. files?: string[] | undefined;
  57659. /**
  57660. * Gets the loaded texture
  57661. */
  57662. texture: CubeTexture;
  57663. /**
  57664. * Callback called when the task is successful
  57665. */
  57666. onSuccess: (task: CubeTextureAssetTask) => void;
  57667. /**
  57668. * Callback called when the task is successful
  57669. */
  57670. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57671. /**
  57672. * Creates a new CubeTextureAssetTask
  57673. * @param name defines the name of the task
  57674. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57675. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57676. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57677. * @param files defines the explicit list of files (undefined by default)
  57678. */
  57679. constructor(
  57680. /**
  57681. * Defines the name of the task
  57682. */
  57683. name: string,
  57684. /**
  57685. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57686. */
  57687. url: string,
  57688. /**
  57689. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57690. */
  57691. extensions?: string[] | undefined,
  57692. /**
  57693. * Defines if mipmaps should not be generated (default is false)
  57694. */
  57695. noMipmap?: boolean | undefined,
  57696. /**
  57697. * Defines the explicit list of files (undefined by default)
  57698. */
  57699. files?: string[] | undefined);
  57700. /**
  57701. * Execute the current task
  57702. * @param scene defines the scene where you want your assets to be loaded
  57703. * @param onSuccess is a callback called when the task is successfully executed
  57704. * @param onError is a callback called if an error occurs
  57705. */
  57706. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57707. }
  57708. /**
  57709. * Define a task used by AssetsManager to load HDR cube textures
  57710. */
  57711. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57712. /**
  57713. * Defines the name of the task
  57714. */
  57715. name: string;
  57716. /**
  57717. * Defines the location of the file to load
  57718. */
  57719. url: string;
  57720. /**
  57721. * Defines the desired size (the more it increases the longer the generation will be)
  57722. */
  57723. size: number;
  57724. /**
  57725. * Defines if mipmaps should not be generated (default is false)
  57726. */
  57727. noMipmap: boolean;
  57728. /**
  57729. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57730. */
  57731. generateHarmonics: boolean;
  57732. /**
  57733. * 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)
  57734. */
  57735. gammaSpace: boolean;
  57736. /**
  57737. * Internal Use Only
  57738. */
  57739. reserved: boolean;
  57740. /**
  57741. * Gets the loaded texture
  57742. */
  57743. texture: HDRCubeTexture;
  57744. /**
  57745. * Callback called when the task is successful
  57746. */
  57747. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57748. /**
  57749. * Callback called when the task is successful
  57750. */
  57751. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57752. /**
  57753. * Creates a new HDRCubeTextureAssetTask object
  57754. * @param name defines the name of the task
  57755. * @param url defines the location of the file to load
  57756. * @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.
  57757. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57758. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57759. * @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)
  57760. * @param reserved Internal use only
  57761. */
  57762. constructor(
  57763. /**
  57764. * Defines the name of the task
  57765. */
  57766. name: string,
  57767. /**
  57768. * Defines the location of the file to load
  57769. */
  57770. url: string,
  57771. /**
  57772. * Defines the desired size (the more it increases the longer the generation will be)
  57773. */
  57774. size: number,
  57775. /**
  57776. * Defines if mipmaps should not be generated (default is false)
  57777. */
  57778. noMipmap?: boolean,
  57779. /**
  57780. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57781. */
  57782. generateHarmonics?: boolean,
  57783. /**
  57784. * 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)
  57785. */
  57786. gammaSpace?: boolean,
  57787. /**
  57788. * Internal Use Only
  57789. */
  57790. reserved?: boolean);
  57791. /**
  57792. * Execute the current task
  57793. * @param scene defines the scene where you want your assets to be loaded
  57794. * @param onSuccess is a callback called when the task is successfully executed
  57795. * @param onError is a callback called if an error occurs
  57796. */
  57797. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57798. }
  57799. /**
  57800. * Define a task used by AssetsManager to load Equirectangular cube textures
  57801. */
  57802. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57803. /**
  57804. * Defines the name of the task
  57805. */
  57806. name: string;
  57807. /**
  57808. * Defines the location of the file to load
  57809. */
  57810. url: string;
  57811. /**
  57812. * Defines the desired size (the more it increases the longer the generation will be)
  57813. */
  57814. size: number;
  57815. /**
  57816. * Defines if mipmaps should not be generated (default is false)
  57817. */
  57818. noMipmap: boolean;
  57819. /**
  57820. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57821. * but the standard material would require them in Gamma space) (default is true)
  57822. */
  57823. gammaSpace: boolean;
  57824. /**
  57825. * Gets the loaded texture
  57826. */
  57827. texture: EquiRectangularCubeTexture;
  57828. /**
  57829. * Callback called when the task is successful
  57830. */
  57831. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57832. /**
  57833. * Callback called when the task is successful
  57834. */
  57835. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57836. /**
  57837. * Creates a new EquiRectangularCubeTextureAssetTask object
  57838. * @param name defines the name of the task
  57839. * @param url defines the location of the file to load
  57840. * @param size defines the desired size (the more it increases the longer the generation will be)
  57841. * If the size is omitted this implies you are using a preprocessed cubemap.
  57842. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57843. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57844. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57845. * (default is true)
  57846. */
  57847. constructor(
  57848. /**
  57849. * Defines the name of the task
  57850. */
  57851. name: string,
  57852. /**
  57853. * Defines the location of the file to load
  57854. */
  57855. url: string,
  57856. /**
  57857. * Defines the desired size (the more it increases the longer the generation will be)
  57858. */
  57859. size: number,
  57860. /**
  57861. * Defines if mipmaps should not be generated (default is false)
  57862. */
  57863. noMipmap?: boolean,
  57864. /**
  57865. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57866. * but the standard material would require them in Gamma space) (default is true)
  57867. */
  57868. gammaSpace?: boolean);
  57869. /**
  57870. * Execute the current task
  57871. * @param scene defines the scene where you want your assets to be loaded
  57872. * @param onSuccess is a callback called when the task is successfully executed
  57873. * @param onError is a callback called if an error occurs
  57874. */
  57875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57876. }
  57877. /**
  57878. * This class can be used to easily import assets into a scene
  57879. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57880. */
  57881. export class AssetsManager {
  57882. private _scene;
  57883. private _isLoading;
  57884. protected _tasks: AbstractAssetTask[];
  57885. protected _waitingTasksCount: number;
  57886. protected _totalTasksCount: number;
  57887. /**
  57888. * Callback called when all tasks are processed
  57889. */
  57890. onFinish: (tasks: AbstractAssetTask[]) => void;
  57891. /**
  57892. * Callback called when a task is successful
  57893. */
  57894. onTaskSuccess: (task: AbstractAssetTask) => void;
  57895. /**
  57896. * Callback called when a task had an error
  57897. */
  57898. onTaskError: (task: AbstractAssetTask) => void;
  57899. /**
  57900. * Callback called when a task is done (whatever the result is)
  57901. */
  57902. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57903. /**
  57904. * Observable called when all tasks are processed
  57905. */
  57906. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57907. /**
  57908. * Observable called when a task had an error
  57909. */
  57910. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57911. /**
  57912. * Observable called when all tasks were executed
  57913. */
  57914. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57915. /**
  57916. * Observable called when a task is done (whatever the result is)
  57917. */
  57918. onProgressObservable: Observable<IAssetsProgressEvent>;
  57919. /**
  57920. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57921. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57922. */
  57923. useDefaultLoadingScreen: boolean;
  57924. /**
  57925. * Creates a new AssetsManager
  57926. * @param scene defines the scene to work on
  57927. */
  57928. constructor(scene: Scene);
  57929. /**
  57930. * Add a MeshAssetTask to the list of active tasks
  57931. * @param taskName defines the name of the new task
  57932. * @param meshesNames defines the name of meshes to load
  57933. * @param rootUrl defines the root url to use to locate files
  57934. * @param sceneFilename defines the filename of the scene file
  57935. * @returns a new MeshAssetTask object
  57936. */
  57937. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57938. /**
  57939. * Add a TextFileAssetTask to the list of active tasks
  57940. * @param taskName defines the name of the new task
  57941. * @param url defines the url of the file to load
  57942. * @returns a new TextFileAssetTask object
  57943. */
  57944. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57945. /**
  57946. * Add a BinaryFileAssetTask to the list of active tasks
  57947. * @param taskName defines the name of the new task
  57948. * @param url defines the url of the file to load
  57949. * @returns a new BinaryFileAssetTask object
  57950. */
  57951. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57952. /**
  57953. * Add a ImageAssetTask to the list of active tasks
  57954. * @param taskName defines the name of the new task
  57955. * @param url defines the url of the file to load
  57956. * @returns a new ImageAssetTask object
  57957. */
  57958. addImageTask(taskName: string, url: string): ImageAssetTask;
  57959. /**
  57960. * Add a TextureAssetTask to the list of active tasks
  57961. * @param taskName defines the name of the new task
  57962. * @param url defines the url of the file to load
  57963. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57964. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57965. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57966. * @returns a new TextureAssetTask object
  57967. */
  57968. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57969. /**
  57970. * Add a CubeTextureAssetTask to the list of active tasks
  57971. * @param taskName defines the name of the new task
  57972. * @param url defines the url of the file to load
  57973. * @param extensions defines the extension to use to load the cube map (can be null)
  57974. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57975. * @param files defines the list of files to load (can be null)
  57976. * @returns a new CubeTextureAssetTask object
  57977. */
  57978. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57979. /**
  57980. *
  57981. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57982. * @param taskName defines the name of the new task
  57983. * @param url defines the url of the file to load
  57984. * @param size defines the size you want for the cubemap (can be null)
  57985. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57986. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57987. * @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)
  57988. * @param reserved Internal use only
  57989. * @returns a new HDRCubeTextureAssetTask object
  57990. */
  57991. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57992. /**
  57993. *
  57994. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57995. * @param taskName defines the name of the new task
  57996. * @param url defines the url of the file to load
  57997. * @param size defines the size you want for the cubemap (can be null)
  57998. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57999. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58000. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58001. * @returns a new EquiRectangularCubeTextureAssetTask object
  58002. */
  58003. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58004. /**
  58005. * Remove a task from the assets manager.
  58006. * @param task the task to remove
  58007. */
  58008. removeTask(task: AbstractAssetTask): void;
  58009. private _decreaseWaitingTasksCount;
  58010. private _runTask;
  58011. /**
  58012. * Reset the AssetsManager and remove all tasks
  58013. * @return the current instance of the AssetsManager
  58014. */
  58015. reset(): AssetsManager;
  58016. /**
  58017. * Start the loading process
  58018. * @return the current instance of the AssetsManager
  58019. */
  58020. load(): AssetsManager;
  58021. /**
  58022. * Start the loading process as an async operation
  58023. * @return a promise returning the list of failed tasks
  58024. */
  58025. loadAsync(): Promise<void>;
  58026. }
  58027. }
  58028. declare module "babylonjs/Misc/deferred" {
  58029. /**
  58030. * Wrapper class for promise with external resolve and reject.
  58031. */
  58032. export class Deferred<T> {
  58033. /**
  58034. * The promise associated with this deferred object.
  58035. */
  58036. readonly promise: Promise<T>;
  58037. private _resolve;
  58038. private _reject;
  58039. /**
  58040. * The resolve method of the promise associated with this deferred object.
  58041. */
  58042. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58043. /**
  58044. * The reject method of the promise associated with this deferred object.
  58045. */
  58046. readonly reject: (reason?: any) => void;
  58047. /**
  58048. * Constructor for this deferred object.
  58049. */
  58050. constructor();
  58051. }
  58052. }
  58053. declare module "babylonjs/Misc/meshExploder" {
  58054. import { Mesh } from "babylonjs/Meshes/mesh";
  58055. /**
  58056. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58057. */
  58058. export class MeshExploder {
  58059. private _centerMesh;
  58060. private _meshes;
  58061. private _meshesOrigins;
  58062. private _toCenterVectors;
  58063. private _scaledDirection;
  58064. private _newPosition;
  58065. private _centerPosition;
  58066. /**
  58067. * Explodes meshes from a center mesh.
  58068. * @param meshes The meshes to explode.
  58069. * @param centerMesh The mesh to be center of explosion.
  58070. */
  58071. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58072. private _setCenterMesh;
  58073. /**
  58074. * Get class name
  58075. * @returns "MeshExploder"
  58076. */
  58077. getClassName(): string;
  58078. /**
  58079. * "Exploded meshes"
  58080. * @returns Array of meshes with the centerMesh at index 0.
  58081. */
  58082. getMeshes(): Array<Mesh>;
  58083. /**
  58084. * Explodes meshes giving a specific direction
  58085. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58086. */
  58087. explode(direction?: number): void;
  58088. }
  58089. }
  58090. declare module "babylonjs/Misc/filesInput" {
  58091. import { Engine } from "babylonjs/Engines/engine";
  58092. import { Scene } from "babylonjs/scene";
  58093. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58094. /**
  58095. * Class used to help managing file picking and drag'n'drop
  58096. */
  58097. export class FilesInput {
  58098. /**
  58099. * List of files ready to be loaded
  58100. */
  58101. static readonly FilesToLoad: {
  58102. [key: string]: File;
  58103. };
  58104. /**
  58105. * Callback called when a file is processed
  58106. */
  58107. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58108. private _engine;
  58109. private _currentScene;
  58110. private _sceneLoadedCallback;
  58111. private _progressCallback;
  58112. private _additionalRenderLoopLogicCallback;
  58113. private _textureLoadingCallback;
  58114. private _startingProcessingFilesCallback;
  58115. private _onReloadCallback;
  58116. private _errorCallback;
  58117. private _elementToMonitor;
  58118. private _sceneFileToLoad;
  58119. private _filesToLoad;
  58120. /**
  58121. * Creates a new FilesInput
  58122. * @param engine defines the rendering engine
  58123. * @param scene defines the hosting scene
  58124. * @param sceneLoadedCallback callback called when scene is loaded
  58125. * @param progressCallback callback called to track progress
  58126. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58127. * @param textureLoadingCallback callback called when a texture is loading
  58128. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58129. * @param onReloadCallback callback called when a reload is requested
  58130. * @param errorCallback callback call if an error occurs
  58131. */
  58132. 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);
  58133. private _dragEnterHandler;
  58134. private _dragOverHandler;
  58135. private _dropHandler;
  58136. /**
  58137. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58138. * @param elementToMonitor defines the DOM element to track
  58139. */
  58140. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58141. /**
  58142. * Release all associated resources
  58143. */
  58144. dispose(): void;
  58145. private renderFunction;
  58146. private drag;
  58147. private drop;
  58148. private _traverseFolder;
  58149. private _processFiles;
  58150. /**
  58151. * Load files from a drop event
  58152. * @param event defines the drop event to use as source
  58153. */
  58154. loadFiles(event: any): void;
  58155. private _processReload;
  58156. /**
  58157. * Reload the current scene from the loaded files
  58158. */
  58159. reload(): void;
  58160. }
  58161. }
  58162. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58163. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58164. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58165. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58166. }
  58167. declare module "babylonjs/Misc/sceneOptimizer" {
  58168. import { Scene, IDisposable } from "babylonjs/scene";
  58169. import { Observable } from "babylonjs/Misc/observable";
  58170. /**
  58171. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58172. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58173. */
  58174. export class SceneOptimization {
  58175. /**
  58176. * Defines the priority of this optimization (0 by default which means first in the list)
  58177. */
  58178. priority: number;
  58179. /**
  58180. * Gets a string describing the action executed by the current optimization
  58181. * @returns description string
  58182. */
  58183. getDescription(): string;
  58184. /**
  58185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58186. * @param scene defines the current scene where to apply this optimization
  58187. * @param optimizer defines the current optimizer
  58188. * @returns true if everything that can be done was applied
  58189. */
  58190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58191. /**
  58192. * Creates the SceneOptimization object
  58193. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58194. * @param desc defines the description associated with the optimization
  58195. */
  58196. constructor(
  58197. /**
  58198. * Defines the priority of this optimization (0 by default which means first in the list)
  58199. */
  58200. priority?: number);
  58201. }
  58202. /**
  58203. * Defines an optimization used to reduce the size of render target textures
  58204. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58205. */
  58206. export class TextureOptimization extends SceneOptimization {
  58207. /**
  58208. * Defines the priority of this optimization (0 by default which means first in the list)
  58209. */
  58210. priority: number;
  58211. /**
  58212. * 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
  58213. */
  58214. maximumSize: number;
  58215. /**
  58216. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58217. */
  58218. step: number;
  58219. /**
  58220. * Gets a string describing the action executed by the current optimization
  58221. * @returns description string
  58222. */
  58223. getDescription(): string;
  58224. /**
  58225. * Creates the TextureOptimization object
  58226. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58227. * @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
  58228. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58229. */
  58230. constructor(
  58231. /**
  58232. * Defines the priority of this optimization (0 by default which means first in the list)
  58233. */
  58234. priority?: number,
  58235. /**
  58236. * 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
  58237. */
  58238. maximumSize?: number,
  58239. /**
  58240. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58241. */
  58242. step?: number);
  58243. /**
  58244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58245. * @param scene defines the current scene where to apply this optimization
  58246. * @param optimizer defines the current optimizer
  58247. * @returns true if everything that can be done was applied
  58248. */
  58249. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58250. }
  58251. /**
  58252. * Defines an optimization used to increase or decrease the rendering resolution
  58253. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58254. */
  58255. export class HardwareScalingOptimization extends SceneOptimization {
  58256. /**
  58257. * Defines the priority of this optimization (0 by default which means first in the list)
  58258. */
  58259. priority: number;
  58260. /**
  58261. * Defines the maximum scale to use (2 by default)
  58262. */
  58263. maximumScale: number;
  58264. /**
  58265. * Defines the step to use between two passes (0.5 by default)
  58266. */
  58267. step: number;
  58268. private _currentScale;
  58269. private _directionOffset;
  58270. /**
  58271. * Gets a string describing the action executed by the current optimization
  58272. * @return description string
  58273. */
  58274. getDescription(): string;
  58275. /**
  58276. * Creates the HardwareScalingOptimization object
  58277. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58278. * @param maximumScale defines the maximum scale to use (2 by default)
  58279. * @param step defines the step to use between two passes (0.5 by default)
  58280. */
  58281. constructor(
  58282. /**
  58283. * Defines the priority of this optimization (0 by default which means first in the list)
  58284. */
  58285. priority?: number,
  58286. /**
  58287. * Defines the maximum scale to use (2 by default)
  58288. */
  58289. maximumScale?: number,
  58290. /**
  58291. * Defines the step to use between two passes (0.5 by default)
  58292. */
  58293. step?: number);
  58294. /**
  58295. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58296. * @param scene defines the current scene where to apply this optimization
  58297. * @param optimizer defines the current optimizer
  58298. * @returns true if everything that can be done was applied
  58299. */
  58300. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58301. }
  58302. /**
  58303. * Defines an optimization used to remove shadows
  58304. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58305. */
  58306. export class ShadowsOptimization extends SceneOptimization {
  58307. /**
  58308. * Gets a string describing the action executed by the current optimization
  58309. * @return description string
  58310. */
  58311. getDescription(): string;
  58312. /**
  58313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58314. * @param scene defines the current scene where to apply this optimization
  58315. * @param optimizer defines the current optimizer
  58316. * @returns true if everything that can be done was applied
  58317. */
  58318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58319. }
  58320. /**
  58321. * Defines an optimization used to turn post-processes off
  58322. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58323. */
  58324. export class PostProcessesOptimization extends SceneOptimization {
  58325. /**
  58326. * Gets a string describing the action executed by the current optimization
  58327. * @return description string
  58328. */
  58329. getDescription(): string;
  58330. /**
  58331. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58332. * @param scene defines the current scene where to apply this optimization
  58333. * @param optimizer defines the current optimizer
  58334. * @returns true if everything that can be done was applied
  58335. */
  58336. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58337. }
  58338. /**
  58339. * Defines an optimization used to turn lens flares off
  58340. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58341. */
  58342. export class LensFlaresOptimization extends SceneOptimization {
  58343. /**
  58344. * Gets a string describing the action executed by the current optimization
  58345. * @return description string
  58346. */
  58347. getDescription(): string;
  58348. /**
  58349. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58350. * @param scene defines the current scene where to apply this optimization
  58351. * @param optimizer defines the current optimizer
  58352. * @returns true if everything that can be done was applied
  58353. */
  58354. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58355. }
  58356. /**
  58357. * Defines an optimization based on user defined callback.
  58358. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58359. */
  58360. export class CustomOptimization extends SceneOptimization {
  58361. /**
  58362. * Callback called to apply the custom optimization.
  58363. */
  58364. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58365. /**
  58366. * Callback called to get custom description
  58367. */
  58368. onGetDescription: () => string;
  58369. /**
  58370. * Gets a string describing the action executed by the current optimization
  58371. * @returns description string
  58372. */
  58373. getDescription(): string;
  58374. /**
  58375. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58376. * @param scene defines the current scene where to apply this optimization
  58377. * @param optimizer defines the current optimizer
  58378. * @returns true if everything that can be done was applied
  58379. */
  58380. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58381. }
  58382. /**
  58383. * Defines an optimization used to turn particles off
  58384. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58385. */
  58386. export class ParticlesOptimization extends SceneOptimization {
  58387. /**
  58388. * Gets a string describing the action executed by the current optimization
  58389. * @return description string
  58390. */
  58391. getDescription(): string;
  58392. /**
  58393. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58394. * @param scene defines the current scene where to apply this optimization
  58395. * @param optimizer defines the current optimizer
  58396. * @returns true if everything that can be done was applied
  58397. */
  58398. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58399. }
  58400. /**
  58401. * Defines an optimization used to turn render targets off
  58402. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58403. */
  58404. export class RenderTargetsOptimization extends SceneOptimization {
  58405. /**
  58406. * Gets a string describing the action executed by the current optimization
  58407. * @return description string
  58408. */
  58409. getDescription(): string;
  58410. /**
  58411. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58412. * @param scene defines the current scene where to apply this optimization
  58413. * @param optimizer defines the current optimizer
  58414. * @returns true if everything that can be done was applied
  58415. */
  58416. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58417. }
  58418. /**
  58419. * Defines an optimization used to merge meshes with compatible materials
  58420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58421. */
  58422. export class MergeMeshesOptimization extends SceneOptimization {
  58423. private static _UpdateSelectionTree;
  58424. /**
  58425. * Gets or sets a boolean which defines if optimization octree has to be updated
  58426. */
  58427. /**
  58428. * Gets or sets a boolean which defines if optimization octree has to be updated
  58429. */
  58430. static UpdateSelectionTree: boolean;
  58431. /**
  58432. * Gets a string describing the action executed by the current optimization
  58433. * @return description string
  58434. */
  58435. getDescription(): string;
  58436. private _canBeMerged;
  58437. /**
  58438. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58439. * @param scene defines the current scene where to apply this optimization
  58440. * @param optimizer defines the current optimizer
  58441. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58442. * @returns true if everything that can be done was applied
  58443. */
  58444. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58445. }
  58446. /**
  58447. * Defines a list of options used by SceneOptimizer
  58448. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58449. */
  58450. export class SceneOptimizerOptions {
  58451. /**
  58452. * Defines the target frame rate to reach (60 by default)
  58453. */
  58454. targetFrameRate: number;
  58455. /**
  58456. * Defines the interval between two checkes (2000ms by default)
  58457. */
  58458. trackerDuration: number;
  58459. /**
  58460. * Gets the list of optimizations to apply
  58461. */
  58462. optimizations: SceneOptimization[];
  58463. /**
  58464. * Creates a new list of options used by SceneOptimizer
  58465. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58466. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58467. */
  58468. constructor(
  58469. /**
  58470. * Defines the target frame rate to reach (60 by default)
  58471. */
  58472. targetFrameRate?: number,
  58473. /**
  58474. * Defines the interval between two checkes (2000ms by default)
  58475. */
  58476. trackerDuration?: number);
  58477. /**
  58478. * Add a new optimization
  58479. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58480. * @returns the current SceneOptimizerOptions
  58481. */
  58482. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58483. /**
  58484. * Add a new custom optimization
  58485. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58486. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58487. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58488. * @returns the current SceneOptimizerOptions
  58489. */
  58490. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58491. /**
  58492. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58493. * @param targetFrameRate defines the target frame rate (60 by default)
  58494. * @returns a SceneOptimizerOptions object
  58495. */
  58496. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58497. /**
  58498. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58499. * @param targetFrameRate defines the target frame rate (60 by default)
  58500. * @returns a SceneOptimizerOptions object
  58501. */
  58502. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58503. /**
  58504. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58505. * @param targetFrameRate defines the target frame rate (60 by default)
  58506. * @returns a SceneOptimizerOptions object
  58507. */
  58508. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58509. }
  58510. /**
  58511. * Class used to run optimizations in order to reach a target frame rate
  58512. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58513. */
  58514. export class SceneOptimizer implements IDisposable {
  58515. private _isRunning;
  58516. private _options;
  58517. private _scene;
  58518. private _currentPriorityLevel;
  58519. private _targetFrameRate;
  58520. private _trackerDuration;
  58521. private _currentFrameRate;
  58522. private _sceneDisposeObserver;
  58523. private _improvementMode;
  58524. /**
  58525. * Defines an observable called when the optimizer reaches the target frame rate
  58526. */
  58527. onSuccessObservable: Observable<SceneOptimizer>;
  58528. /**
  58529. * Defines an observable called when the optimizer enables an optimization
  58530. */
  58531. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58532. /**
  58533. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58534. */
  58535. onFailureObservable: Observable<SceneOptimizer>;
  58536. /**
  58537. * Gets a boolean indicating if the optimizer is in improvement mode
  58538. */
  58539. readonly isInImprovementMode: boolean;
  58540. /**
  58541. * Gets the current priority level (0 at start)
  58542. */
  58543. readonly currentPriorityLevel: number;
  58544. /**
  58545. * Gets the current frame rate checked by the SceneOptimizer
  58546. */
  58547. readonly currentFrameRate: number;
  58548. /**
  58549. * Gets or sets the current target frame rate (60 by default)
  58550. */
  58551. /**
  58552. * Gets or sets the current target frame rate (60 by default)
  58553. */
  58554. targetFrameRate: number;
  58555. /**
  58556. * Gets or sets the current interval between two checks (every 2000ms by default)
  58557. */
  58558. /**
  58559. * Gets or sets the current interval between two checks (every 2000ms by default)
  58560. */
  58561. trackerDuration: number;
  58562. /**
  58563. * Gets the list of active optimizations
  58564. */
  58565. readonly optimizations: SceneOptimization[];
  58566. /**
  58567. * Creates a new SceneOptimizer
  58568. * @param scene defines the scene to work on
  58569. * @param options defines the options to use with the SceneOptimizer
  58570. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58571. * @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)
  58572. */
  58573. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58574. /**
  58575. * Stops the current optimizer
  58576. */
  58577. stop(): void;
  58578. /**
  58579. * Reset the optimizer to initial step (current priority level = 0)
  58580. */
  58581. reset(): void;
  58582. /**
  58583. * Start the optimizer. By default it will try to reach a specific framerate
  58584. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58585. */
  58586. start(): void;
  58587. private _checkCurrentState;
  58588. /**
  58589. * Release all resources
  58590. */
  58591. dispose(): void;
  58592. /**
  58593. * Helper function to create a SceneOptimizer with one single line of code
  58594. * @param scene defines the scene to work on
  58595. * @param options defines the options to use with the SceneOptimizer
  58596. * @param onSuccess defines a callback to call on success
  58597. * @param onFailure defines a callback to call on failure
  58598. * @returns the new SceneOptimizer object
  58599. */
  58600. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58601. }
  58602. }
  58603. declare module "babylonjs/Misc/sceneSerializer" {
  58604. import { Scene } from "babylonjs/scene";
  58605. /**
  58606. * Class used to serialize a scene into a string
  58607. */
  58608. export class SceneSerializer {
  58609. /**
  58610. * Clear cache used by a previous serialization
  58611. */
  58612. static ClearCache(): void;
  58613. /**
  58614. * Serialize a scene into a JSON compatible object
  58615. * @param scene defines the scene to serialize
  58616. * @returns a JSON compatible object
  58617. */
  58618. static Serialize(scene: Scene): any;
  58619. /**
  58620. * Serialize a mesh into a JSON compatible object
  58621. * @param toSerialize defines the mesh to serialize
  58622. * @param withParents defines if parents must be serialized as well
  58623. * @param withChildren defines if children must be serialized as well
  58624. * @returns a JSON compatible object
  58625. */
  58626. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58627. }
  58628. }
  58629. declare module "babylonjs/Misc/textureTools" {
  58630. import { Texture } from "babylonjs/Materials/Textures/texture";
  58631. /**
  58632. * Class used to host texture specific utilities
  58633. */
  58634. export class TextureTools {
  58635. /**
  58636. * Uses the GPU to create a copy texture rescaled at a given size
  58637. * @param texture Texture to copy from
  58638. * @param width defines the desired width
  58639. * @param height defines the desired height
  58640. * @param useBilinearMode defines if bilinear mode has to be used
  58641. * @return the generated texture
  58642. */
  58643. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58644. }
  58645. }
  58646. declare module "babylonjs/Misc/videoRecorder" {
  58647. import { Nullable } from "babylonjs/types";
  58648. import { Engine } from "babylonjs/Engines/engine";
  58649. /**
  58650. * This represents the different options avilable for the video capture.
  58651. */
  58652. export interface VideoRecorderOptions {
  58653. /** Defines the mime type of the video */
  58654. mimeType: string;
  58655. /** Defines the video the video should be recorded at */
  58656. fps: number;
  58657. /** Defines the chunk size for the recording data */
  58658. recordChunckSize: number;
  58659. /** The audio tracks to attach to the record */
  58660. audioTracks?: MediaStreamTrack[];
  58661. }
  58662. /**
  58663. * This can helps recording videos from BabylonJS.
  58664. * This is based on the available WebRTC functionalities of the browser.
  58665. *
  58666. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58667. */
  58668. export class VideoRecorder {
  58669. private static readonly _defaultOptions;
  58670. /**
  58671. * Returns wehther or not the VideoRecorder is available in your browser.
  58672. * @param engine Defines the Babylon Engine to check the support for
  58673. * @returns true if supported otherwise false
  58674. */
  58675. static IsSupported(engine: Engine): boolean;
  58676. private readonly _options;
  58677. private _canvas;
  58678. private _mediaRecorder;
  58679. private _recordedChunks;
  58680. private _fileName;
  58681. private _resolve;
  58682. private _reject;
  58683. /**
  58684. * True wether a recording is already in progress.
  58685. */
  58686. readonly isRecording: boolean;
  58687. /**
  58688. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58689. * a video file.
  58690. * @param engine Defines the BabylonJS Engine you wish to record
  58691. * @param options Defines options that can be used to customized the capture
  58692. */
  58693. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58694. /**
  58695. * Stops the current recording before the default capture timeout passed in the startRecording
  58696. * functions.
  58697. */
  58698. stopRecording(): void;
  58699. /**
  58700. * Starts recording the canvas for a max duration specified in parameters.
  58701. * @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.
  58702. * @param maxDuration Defines the maximum recording time in seconds.
  58703. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58704. * @return a promise callback at the end of the recording with the video data in Blob.
  58705. */
  58706. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58707. /**
  58708. * Releases internal resources used during the recording.
  58709. */
  58710. dispose(): void;
  58711. private _handleDataAvailable;
  58712. private _handleError;
  58713. private _handleStop;
  58714. }
  58715. }
  58716. declare module "babylonjs/Misc/screenshotTools" {
  58717. import { Camera } from "babylonjs/Cameras/camera";
  58718. import { Engine } from "babylonjs/Engines/engine";
  58719. /**
  58720. * Class containing a set of static utilities functions for screenshots
  58721. */
  58722. export class ScreenshotTools {
  58723. /**
  58724. * Captures a screenshot of the current rendering
  58725. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58726. * @param engine defines the rendering engine
  58727. * @param camera defines the source camera
  58728. * @param size This parameter can be set to a single number or to an object with the
  58729. * following (optional) properties: precision, width, height. If a single number is passed,
  58730. * it will be used for both width and height. If an object is passed, the screenshot size
  58731. * will be derived from the parameters. The precision property is a multiplier allowing
  58732. * rendering at a higher or lower resolution
  58733. * @param successCallback defines the callback receives a single parameter which contains the
  58734. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58735. * src parameter of an <img> to display it
  58736. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58737. * Check your browser for supported MIME types
  58738. */
  58739. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58740. /**
  58741. * Generates an image screenshot from the specified camera.
  58742. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58743. * @param engine The engine to use for rendering
  58744. * @param camera The camera to use for rendering
  58745. * @param size This parameter can be set to a single number or to an object with the
  58746. * following (optional) properties: precision, width, height. If a single number is passed,
  58747. * it will be used for both width and height. If an object is passed, the screenshot size
  58748. * will be derived from the parameters. The precision property is a multiplier allowing
  58749. * rendering at a higher or lower resolution
  58750. * @param successCallback The callback receives a single parameter which contains the
  58751. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58752. * src parameter of an <img> to display it
  58753. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58754. * Check your browser for supported MIME types
  58755. * @param samples Texture samples (default: 1)
  58756. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58757. * @param fileName A name for for the downloaded file.
  58758. */
  58759. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58760. }
  58761. }
  58762. declare module "babylonjs/Misc/index" {
  58763. export * from "babylonjs/Misc/andOrNotEvaluator";
  58764. export * from "babylonjs/Misc/assetsManager";
  58765. export * from "babylonjs/Misc/dds";
  58766. export * from "babylonjs/Misc/decorators";
  58767. export * from "babylonjs/Misc/deferred";
  58768. export * from "babylonjs/Misc/environmentTextureTools";
  58769. export * from "babylonjs/Misc/meshExploder";
  58770. export * from "babylonjs/Misc/filesInput";
  58771. export * from "babylonjs/Misc/HighDynamicRange/index";
  58772. export * from "babylonjs/Misc/khronosTextureContainer";
  58773. export * from "babylonjs/Misc/observable";
  58774. export * from "babylonjs/Misc/performanceMonitor";
  58775. export * from "babylonjs/Misc/promise";
  58776. export * from "babylonjs/Misc/sceneOptimizer";
  58777. export * from "babylonjs/Misc/sceneSerializer";
  58778. export * from "babylonjs/Misc/smartArray";
  58779. export * from "babylonjs/Misc/stringDictionary";
  58780. export * from "babylonjs/Misc/tags";
  58781. export * from "babylonjs/Misc/textureTools";
  58782. export * from "babylonjs/Misc/tga";
  58783. export * from "babylonjs/Misc/tools";
  58784. export * from "babylonjs/Misc/videoRecorder";
  58785. export * from "babylonjs/Misc/virtualJoystick";
  58786. export * from "babylonjs/Misc/workerPool";
  58787. export * from "babylonjs/Misc/logger";
  58788. export * from "babylonjs/Misc/typeStore";
  58789. export * from "babylonjs/Misc/filesInputStore";
  58790. export * from "babylonjs/Misc/deepCopier";
  58791. export * from "babylonjs/Misc/pivotTools";
  58792. export * from "babylonjs/Misc/precisionDate";
  58793. export * from "babylonjs/Misc/screenshotTools";
  58794. export * from "babylonjs/Misc/typeStore";
  58795. export * from "babylonjs/Misc/webRequest";
  58796. export * from "babylonjs/Misc/iInspectable";
  58797. }
  58798. declare module "babylonjs/index" {
  58799. export * from "babylonjs/abstractScene";
  58800. export * from "babylonjs/Actions/index";
  58801. export * from "babylonjs/Animations/index";
  58802. export * from "babylonjs/assetContainer";
  58803. export * from "babylonjs/Audio/index";
  58804. export * from "babylonjs/Behaviors/index";
  58805. export * from "babylonjs/Bones/index";
  58806. export * from "babylonjs/Cameras/index";
  58807. export * from "babylonjs/Collisions/index";
  58808. export * from "babylonjs/Culling/index";
  58809. export * from "babylonjs/Debug/index";
  58810. export * from "babylonjs/Engines/index";
  58811. export * from "babylonjs/Events/index";
  58812. export * from "babylonjs/Gamepads/index";
  58813. export * from "babylonjs/Gizmos/index";
  58814. export * from "babylonjs/Helpers/index";
  58815. export * from "babylonjs/Instrumentation/index";
  58816. export * from "babylonjs/Layers/index";
  58817. export * from "babylonjs/LensFlares/index";
  58818. export * from "babylonjs/Lights/index";
  58819. export * from "babylonjs/Loading/index";
  58820. export * from "babylonjs/Materials/index";
  58821. export * from "babylonjs/Maths/index";
  58822. export * from "babylonjs/Meshes/index";
  58823. export * from "babylonjs/Morph/index";
  58824. export * from "babylonjs/node";
  58825. export * from "babylonjs/Offline/index";
  58826. export * from "babylonjs/Particles/index";
  58827. export * from "babylonjs/Physics/index";
  58828. export * from "babylonjs/PostProcesses/index";
  58829. export * from "babylonjs/Probes/index";
  58830. export * from "babylonjs/Rendering/index";
  58831. export * from "babylonjs/scene";
  58832. export * from "babylonjs/sceneComponent";
  58833. export * from "babylonjs/Sprites/index";
  58834. export * from "babylonjs/States/index";
  58835. export * from "babylonjs/Misc/index";
  58836. export * from "babylonjs/types";
  58837. }
  58838. declare module "babylonjs/Animations/pathCursor" {
  58839. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58840. /**
  58841. * A cursor which tracks a point on a path
  58842. */
  58843. export class PathCursor {
  58844. private path;
  58845. /**
  58846. * Stores path cursor callbacks for when an onchange event is triggered
  58847. */
  58848. private _onchange;
  58849. /**
  58850. * The value of the path cursor
  58851. */
  58852. value: number;
  58853. /**
  58854. * The animation array of the path cursor
  58855. */
  58856. animations: Animation[];
  58857. /**
  58858. * Initializes the path cursor
  58859. * @param path The path to track
  58860. */
  58861. constructor(path: Path2);
  58862. /**
  58863. * Gets the cursor point on the path
  58864. * @returns A point on the path cursor at the cursor location
  58865. */
  58866. getPoint(): Vector3;
  58867. /**
  58868. * Moves the cursor ahead by the step amount
  58869. * @param step The amount to move the cursor forward
  58870. * @returns This path cursor
  58871. */
  58872. moveAhead(step?: number): PathCursor;
  58873. /**
  58874. * Moves the cursor behind by the step amount
  58875. * @param step The amount to move the cursor back
  58876. * @returns This path cursor
  58877. */
  58878. moveBack(step?: number): PathCursor;
  58879. /**
  58880. * Moves the cursor by the step amount
  58881. * If the step amount is greater than one, an exception is thrown
  58882. * @param step The amount to move the cursor
  58883. * @returns This path cursor
  58884. */
  58885. move(step: number): PathCursor;
  58886. /**
  58887. * Ensures that the value is limited between zero and one
  58888. * @returns This path cursor
  58889. */
  58890. private ensureLimits;
  58891. /**
  58892. * Runs onchange callbacks on change (used by the animation engine)
  58893. * @returns This path cursor
  58894. */
  58895. private raiseOnChange;
  58896. /**
  58897. * Executes a function on change
  58898. * @param f A path cursor onchange callback
  58899. * @returns This path cursor
  58900. */
  58901. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58902. }
  58903. }
  58904. declare module "babylonjs/Legacy/legacy" {
  58905. import * as Babylon from "babylonjs/index";
  58906. export * from "babylonjs/index";
  58907. }
  58908. declare module "babylonjs/Shaders/blur.fragment" {
  58909. /** @hidden */
  58910. export var blurPixelShader: {
  58911. name: string;
  58912. shader: string;
  58913. };
  58914. }
  58915. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58916. /** @hidden */
  58917. export var bones300Declaration: {
  58918. name: string;
  58919. shader: string;
  58920. };
  58921. }
  58922. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58923. /** @hidden */
  58924. export var instances300Declaration: {
  58925. name: string;
  58926. shader: string;
  58927. };
  58928. }
  58929. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58930. /** @hidden */
  58931. export var pointCloudVertexDeclaration: {
  58932. name: string;
  58933. shader: string;
  58934. };
  58935. }
  58936. // Mixins
  58937. interface Window {
  58938. mozIndexedDB: IDBFactory;
  58939. webkitIndexedDB: IDBFactory;
  58940. msIndexedDB: IDBFactory;
  58941. webkitURL: typeof URL;
  58942. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58943. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58944. WebGLRenderingContext: WebGLRenderingContext;
  58945. MSGesture: MSGesture;
  58946. CANNON: any;
  58947. AudioContext: AudioContext;
  58948. webkitAudioContext: AudioContext;
  58949. PointerEvent: any;
  58950. Math: Math;
  58951. Uint8Array: Uint8ArrayConstructor;
  58952. Float32Array: Float32ArrayConstructor;
  58953. mozURL: typeof URL;
  58954. msURL: typeof URL;
  58955. VRFrameData: any; // WebVR, from specs 1.1
  58956. DracoDecoderModule: any;
  58957. setImmediate(handler: (...args: any[]) => void): number;
  58958. }
  58959. interface HTMLCanvasElement {
  58960. requestPointerLock(): void;
  58961. msRequestPointerLock?(): void;
  58962. mozRequestPointerLock?(): void;
  58963. webkitRequestPointerLock?(): void;
  58964. /** Track wether a record is in progress */
  58965. isRecording: boolean;
  58966. /** Capture Stream method defined by some browsers */
  58967. captureStream(fps?: number): MediaStream;
  58968. }
  58969. interface CanvasRenderingContext2D {
  58970. msImageSmoothingEnabled: boolean;
  58971. }
  58972. interface MouseEvent {
  58973. mozMovementX: number;
  58974. mozMovementY: number;
  58975. webkitMovementX: number;
  58976. webkitMovementY: number;
  58977. msMovementX: number;
  58978. msMovementY: number;
  58979. }
  58980. interface Navigator {
  58981. mozGetVRDevices: (any: any) => any;
  58982. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58983. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58984. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58985. webkitGetGamepads(): Gamepad[];
  58986. msGetGamepads(): Gamepad[];
  58987. webkitGamepads(): Gamepad[];
  58988. }
  58989. interface HTMLVideoElement {
  58990. mozSrcObject: any;
  58991. }
  58992. interface Math {
  58993. fround(x: number): number;
  58994. imul(a: number, b: number): number;
  58995. }
  58996. interface WebGLProgram {
  58997. context?: WebGLRenderingContext;
  58998. vertexShader?: WebGLShader;
  58999. fragmentShader?: WebGLShader;
  59000. isParallelCompiled: boolean;
  59001. onCompiled?: () => void;
  59002. }
  59003. interface WebGLRenderingContext {
  59004. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59005. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59006. vertexAttribDivisor(index: number, divisor: number): void;
  59007. createVertexArray(): any;
  59008. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59009. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59010. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59011. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59012. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59013. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59014. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59015. // Queries
  59016. createQuery(): WebGLQuery;
  59017. deleteQuery(query: WebGLQuery): void;
  59018. beginQuery(target: number, query: WebGLQuery): void;
  59019. endQuery(target: number): void;
  59020. getQueryParameter(query: WebGLQuery, pname: number): any;
  59021. getQuery(target: number, pname: number): any;
  59022. MAX_SAMPLES: number;
  59023. RGBA8: number;
  59024. READ_FRAMEBUFFER: number;
  59025. DRAW_FRAMEBUFFER: number;
  59026. UNIFORM_BUFFER: number;
  59027. HALF_FLOAT_OES: number;
  59028. RGBA16F: number;
  59029. RGBA32F: number;
  59030. R32F: number;
  59031. RG32F: number;
  59032. RGB32F: number;
  59033. R16F: number;
  59034. RG16F: number;
  59035. RGB16F: number;
  59036. RED: number;
  59037. RG: number;
  59038. R8: number;
  59039. RG8: number;
  59040. UNSIGNED_INT_24_8: number;
  59041. DEPTH24_STENCIL8: number;
  59042. /* Multiple Render Targets */
  59043. drawBuffers(buffers: number[]): void;
  59044. readBuffer(src: number): void;
  59045. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59046. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59047. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59048. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59049. // Occlusion Query
  59050. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59051. ANY_SAMPLES_PASSED: number;
  59052. QUERY_RESULT_AVAILABLE: number;
  59053. QUERY_RESULT: number;
  59054. }
  59055. interface WebGLBuffer {
  59056. references: number;
  59057. capacity: number;
  59058. is32Bits: boolean;
  59059. }
  59060. interface WebGLProgram {
  59061. transformFeedback?: WebGLTransformFeedback | null;
  59062. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59063. }
  59064. interface EXT_disjoint_timer_query {
  59065. QUERY_COUNTER_BITS_EXT: number;
  59066. TIME_ELAPSED_EXT: number;
  59067. TIMESTAMP_EXT: number;
  59068. GPU_DISJOINT_EXT: number;
  59069. QUERY_RESULT_EXT: number;
  59070. QUERY_RESULT_AVAILABLE_EXT: number;
  59071. queryCounterEXT(query: WebGLQuery, target: number): void;
  59072. createQueryEXT(): WebGLQuery;
  59073. beginQueryEXT(target: number, query: WebGLQuery): void;
  59074. endQueryEXT(target: number): void;
  59075. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59076. deleteQueryEXT(query: WebGLQuery): void;
  59077. }
  59078. interface WebGLUniformLocation {
  59079. _currentState: any;
  59080. }
  59081. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59082. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59083. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59084. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59085. interface WebGLRenderingContext {
  59086. readonly RASTERIZER_DISCARD: number;
  59087. readonly DEPTH_COMPONENT24: number;
  59088. readonly TEXTURE_3D: number;
  59089. readonly TEXTURE_2D_ARRAY: number;
  59090. readonly TEXTURE_COMPARE_FUNC: number;
  59091. readonly TEXTURE_COMPARE_MODE: number;
  59092. readonly COMPARE_REF_TO_TEXTURE: number;
  59093. readonly TEXTURE_WRAP_R: number;
  59094. readonly HALF_FLOAT: number;
  59095. readonly RGB8: number;
  59096. readonly RED_INTEGER: number;
  59097. readonly RG_INTEGER: number;
  59098. readonly RGB_INTEGER: number;
  59099. readonly RGBA_INTEGER: number;
  59100. readonly R8_SNORM: number;
  59101. readonly RG8_SNORM: number;
  59102. readonly RGB8_SNORM: number;
  59103. readonly RGBA8_SNORM: number;
  59104. readonly R8I: number;
  59105. readonly RG8I: number;
  59106. readonly RGB8I: number;
  59107. readonly RGBA8I: number;
  59108. readonly R8UI: number;
  59109. readonly RG8UI: number;
  59110. readonly RGB8UI: number;
  59111. readonly RGBA8UI: number;
  59112. readonly R16I: number;
  59113. readonly RG16I: number;
  59114. readonly RGB16I: number;
  59115. readonly RGBA16I: number;
  59116. readonly R16UI: number;
  59117. readonly RG16UI: number;
  59118. readonly RGB16UI: number;
  59119. readonly RGBA16UI: number;
  59120. readonly R32I: number;
  59121. readonly RG32I: number;
  59122. readonly RGB32I: number;
  59123. readonly RGBA32I: number;
  59124. readonly R32UI: number;
  59125. readonly RG32UI: number;
  59126. readonly RGB32UI: number;
  59127. readonly RGBA32UI: number;
  59128. readonly RGB10_A2UI: number;
  59129. readonly R11F_G11F_B10F: number;
  59130. readonly RGB9_E5: number;
  59131. readonly RGB10_A2: number;
  59132. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59133. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59134. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59135. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59136. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59137. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59138. 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;
  59139. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59140. readonly TRANSFORM_FEEDBACK: number;
  59141. readonly INTERLEAVED_ATTRIBS: number;
  59142. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59143. createTransformFeedback(): WebGLTransformFeedback;
  59144. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59145. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59146. beginTransformFeedback(primitiveMode: number): void;
  59147. endTransformFeedback(): void;
  59148. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59149. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59150. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59151. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59152. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59153. }
  59154. interface ImageBitmap {
  59155. readonly width: number;
  59156. readonly height: number;
  59157. close(): void;
  59158. }
  59159. interface WebGLQuery extends WebGLObject {
  59160. }
  59161. declare var WebGLQuery: {
  59162. prototype: WebGLQuery;
  59163. new(): WebGLQuery;
  59164. };
  59165. interface WebGLSampler extends WebGLObject {
  59166. }
  59167. declare var WebGLSampler: {
  59168. prototype: WebGLSampler;
  59169. new(): WebGLSampler;
  59170. };
  59171. interface WebGLSync extends WebGLObject {
  59172. }
  59173. declare var WebGLSync: {
  59174. prototype: WebGLSync;
  59175. new(): WebGLSync;
  59176. };
  59177. interface WebGLTransformFeedback extends WebGLObject {
  59178. }
  59179. declare var WebGLTransformFeedback: {
  59180. prototype: WebGLTransformFeedback;
  59181. new(): WebGLTransformFeedback;
  59182. };
  59183. interface WebGLVertexArrayObject extends WebGLObject {
  59184. }
  59185. declare var WebGLVertexArrayObject: {
  59186. prototype: WebGLVertexArrayObject;
  59187. new(): WebGLVertexArrayObject;
  59188. };
  59189. // Type definitions for WebVR API
  59190. // Project: https://w3c.github.io/webvr/
  59191. // Definitions by: six a <https://github.com/lostfictions>
  59192. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59193. interface VRDisplay extends EventTarget {
  59194. /**
  59195. * Dictionary of capabilities describing the VRDisplay.
  59196. */
  59197. readonly capabilities: VRDisplayCapabilities;
  59198. /**
  59199. * z-depth defining the far plane of the eye view frustum
  59200. * enables mapping of values in the render target depth
  59201. * attachment to scene coordinates. Initially set to 10000.0.
  59202. */
  59203. depthFar: number;
  59204. /**
  59205. * z-depth defining the near plane of the eye view frustum
  59206. * enables mapping of values in the render target depth
  59207. * attachment to scene coordinates. Initially set to 0.01.
  59208. */
  59209. depthNear: number;
  59210. /**
  59211. * An identifier for this distinct VRDisplay. Used as an
  59212. * association point in the Gamepad API.
  59213. */
  59214. readonly displayId: number;
  59215. /**
  59216. * A display name, a user-readable name identifying it.
  59217. */
  59218. readonly displayName: string;
  59219. readonly isConnected: boolean;
  59220. readonly isPresenting: boolean;
  59221. /**
  59222. * If this VRDisplay supports room-scale experiences, the optional
  59223. * stage attribute contains details on the room-scale parameters.
  59224. */
  59225. readonly stageParameters: VRStageParameters | null;
  59226. /**
  59227. * Passing the value returned by `requestAnimationFrame` to
  59228. * `cancelAnimationFrame` will unregister the callback.
  59229. * @param handle Define the hanle of the request to cancel
  59230. */
  59231. cancelAnimationFrame(handle: number): void;
  59232. /**
  59233. * Stops presenting to the VRDisplay.
  59234. * @returns a promise to know when it stopped
  59235. */
  59236. exitPresent(): Promise<void>;
  59237. /**
  59238. * Return the current VREyeParameters for the given eye.
  59239. * @param whichEye Define the eye we want the parameter for
  59240. * @returns the eye parameters
  59241. */
  59242. getEyeParameters(whichEye: string): VREyeParameters;
  59243. /**
  59244. * Populates the passed VRFrameData with the information required to render
  59245. * the current frame.
  59246. * @param frameData Define the data structure to populate
  59247. * @returns true if ok otherwise false
  59248. */
  59249. getFrameData(frameData: VRFrameData): boolean;
  59250. /**
  59251. * Get the layers currently being presented.
  59252. * @returns the list of VR layers
  59253. */
  59254. getLayers(): VRLayer[];
  59255. /**
  59256. * Return a VRPose containing the future predicted pose of the VRDisplay
  59257. * when the current frame will be presented. The value returned will not
  59258. * change until JavaScript has returned control to the browser.
  59259. *
  59260. * The VRPose will contain the position, orientation, velocity,
  59261. * and acceleration of each of these properties.
  59262. * @returns the pose object
  59263. */
  59264. getPose(): VRPose;
  59265. /**
  59266. * Return the current instantaneous pose of the VRDisplay, with no
  59267. * prediction applied.
  59268. * @returns the current instantaneous pose
  59269. */
  59270. getImmediatePose(): VRPose;
  59271. /**
  59272. * The callback passed to `requestAnimationFrame` will be called
  59273. * any time a new frame should be rendered. When the VRDisplay is
  59274. * presenting the callback will be called at the native refresh
  59275. * rate of the HMD. When not presenting this function acts
  59276. * identically to how window.requestAnimationFrame acts. Content should
  59277. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59278. * asynchronously from other displays and at differing refresh rates.
  59279. * @param callback Define the eaction to run next frame
  59280. * @returns the request handle it
  59281. */
  59282. requestAnimationFrame(callback: FrameRequestCallback): number;
  59283. /**
  59284. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59285. * Repeat calls while already presenting will update the VRLayers being displayed.
  59286. * @param layers Define the list of layer to present
  59287. * @returns a promise to know when the request has been fulfilled
  59288. */
  59289. requestPresent(layers: VRLayer[]): Promise<void>;
  59290. /**
  59291. * Reset the pose for this display, treating its current position and
  59292. * orientation as the "origin/zero" values. VRPose.position,
  59293. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59294. * updated when calling resetPose(). This should be called in only
  59295. * sitting-space experiences.
  59296. */
  59297. resetPose(): void;
  59298. /**
  59299. * The VRLayer provided to the VRDisplay will be captured and presented
  59300. * in the HMD. Calling this function has the same effect on the source
  59301. * canvas as any other operation that uses its source image, and canvases
  59302. * created without preserveDrawingBuffer set to true will be cleared.
  59303. * @param pose Define the pose to submit
  59304. */
  59305. submitFrame(pose?: VRPose): void;
  59306. }
  59307. declare var VRDisplay: {
  59308. prototype: VRDisplay;
  59309. new(): VRDisplay;
  59310. };
  59311. interface VRLayer {
  59312. leftBounds?: number[] | Float32Array | null;
  59313. rightBounds?: number[] | Float32Array | null;
  59314. source?: HTMLCanvasElement | null;
  59315. }
  59316. interface VRDisplayCapabilities {
  59317. readonly canPresent: boolean;
  59318. readonly hasExternalDisplay: boolean;
  59319. readonly hasOrientation: boolean;
  59320. readonly hasPosition: boolean;
  59321. readonly maxLayers: number;
  59322. }
  59323. interface VREyeParameters {
  59324. /** @deprecated */
  59325. readonly fieldOfView: VRFieldOfView;
  59326. readonly offset: Float32Array;
  59327. readonly renderHeight: number;
  59328. readonly renderWidth: number;
  59329. }
  59330. interface VRFieldOfView {
  59331. readonly downDegrees: number;
  59332. readonly leftDegrees: number;
  59333. readonly rightDegrees: number;
  59334. readonly upDegrees: number;
  59335. }
  59336. interface VRFrameData {
  59337. readonly leftProjectionMatrix: Float32Array;
  59338. readonly leftViewMatrix: Float32Array;
  59339. readonly pose: VRPose;
  59340. readonly rightProjectionMatrix: Float32Array;
  59341. readonly rightViewMatrix: Float32Array;
  59342. readonly timestamp: number;
  59343. }
  59344. interface VRPose {
  59345. readonly angularAcceleration: Float32Array | null;
  59346. readonly angularVelocity: Float32Array | null;
  59347. readonly linearAcceleration: Float32Array | null;
  59348. readonly linearVelocity: Float32Array | null;
  59349. readonly orientation: Float32Array | null;
  59350. readonly position: Float32Array | null;
  59351. readonly timestamp: number;
  59352. }
  59353. interface VRStageParameters {
  59354. sittingToStandingTransform?: Float32Array;
  59355. sizeX?: number;
  59356. sizeY?: number;
  59357. }
  59358. interface Navigator {
  59359. getVRDisplays(): Promise<VRDisplay[]>;
  59360. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59361. }
  59362. interface Window {
  59363. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59364. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59365. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59366. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59367. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59368. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59369. }
  59370. interface Gamepad {
  59371. readonly displayId: number;
  59372. }
  59373. interface XRDevice {
  59374. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59375. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59376. }
  59377. interface XRSession {
  59378. getInputSources(): Array<any>;
  59379. baseLayer: XRWebGLLayer;
  59380. requestFrameOfReference(type: string): Promise<void>;
  59381. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59382. end(): Promise<void>;
  59383. requestAnimationFrame: Function;
  59384. addEventListener: Function;
  59385. }
  59386. interface XRSessionCreationOptions {
  59387. outputContext?: WebGLRenderingContext | null;
  59388. immersive?: boolean;
  59389. environmentIntegration?: boolean;
  59390. }
  59391. interface XRLayer {
  59392. getViewport: Function;
  59393. framebufferWidth: number;
  59394. framebufferHeight: number;
  59395. }
  59396. interface XRView {
  59397. projectionMatrix: Float32Array;
  59398. }
  59399. interface XRFrame {
  59400. getDevicePose: Function;
  59401. getInputPose: Function;
  59402. views: Array<XRView>;
  59403. baseLayer: XRLayer;
  59404. }
  59405. interface XRFrameOfReference {
  59406. }
  59407. interface XRWebGLLayer extends XRLayer {
  59408. framebuffer: WebGLFramebuffer;
  59409. }
  59410. declare var XRWebGLLayer: {
  59411. prototype: XRWebGLLayer;
  59412. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59413. };
  59414. declare module "babylonjs" {
  59415. export * from "babylonjs/Legacy/legacy";
  59416. }
  59417. declare module BABYLON {
  59418. /** Alias type for value that can be null */
  59419. export type Nullable<T> = T | null;
  59420. /**
  59421. * Alias type for number that are floats
  59422. * @ignorenaming
  59423. */
  59424. export type float = number;
  59425. /**
  59426. * Alias type for number that are doubles.
  59427. * @ignorenaming
  59428. */
  59429. export type double = number;
  59430. /**
  59431. * Alias type for number that are integer
  59432. * @ignorenaming
  59433. */
  59434. export type int = number;
  59435. /** Alias type for number array or Float32Array */
  59436. export type FloatArray = number[] | Float32Array;
  59437. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59438. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59439. /**
  59440. * Alias for types that can be used by a Buffer or VertexBuffer.
  59441. */
  59442. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59443. /**
  59444. * Alias type for primitive types
  59445. * @ignorenaming
  59446. */
  59447. type Primitive = undefined | null | boolean | string | number | Function;
  59448. /**
  59449. * Type modifier to make all the properties of an object Readonly
  59450. */
  59451. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59452. /**
  59453. * Type modifier to make all the properties of an object Readonly recursively
  59454. */
  59455. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59456. /** @hidden */
  59457. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59458. }
  59459. /** @hidden */
  59460. /** @hidden */
  59461. type DeepImmutableObject<T> = {
  59462. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59463. };
  59464. }
  59465. declare module BABYLON {
  59466. /**
  59467. * Class containing a set of static utilities functions for arrays.
  59468. */
  59469. export class ArrayTools {
  59470. /**
  59471. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59472. * @param size the number of element to construct and put in the array
  59473. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59474. * @returns a new array filled with new objects
  59475. */
  59476. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59477. }
  59478. }
  59479. declare module BABYLON {
  59480. /**
  59481. * Scalar computation library
  59482. */
  59483. export class Scalar {
  59484. /**
  59485. * Two pi constants convenient for computation.
  59486. */
  59487. static TwoPi: number;
  59488. /**
  59489. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59490. * @param a number
  59491. * @param b number
  59492. * @param epsilon (default = 1.401298E-45)
  59493. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59494. */
  59495. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59496. /**
  59497. * Returns a string : the upper case translation of the number i to hexadecimal.
  59498. * @param i number
  59499. * @returns the upper case translation of the number i to hexadecimal.
  59500. */
  59501. static ToHex(i: number): string;
  59502. /**
  59503. * Returns -1 if value is negative and +1 is value is positive.
  59504. * @param value the value
  59505. * @returns the value itself if it's equal to zero.
  59506. */
  59507. static Sign(value: number): number;
  59508. /**
  59509. * Returns the value itself if it's between min and max.
  59510. * Returns min if the value is lower than min.
  59511. * Returns max if the value is greater than max.
  59512. * @param value the value to clmap
  59513. * @param min the min value to clamp to (default: 0)
  59514. * @param max the max value to clamp to (default: 1)
  59515. * @returns the clamped value
  59516. */
  59517. static Clamp(value: number, min?: number, max?: number): number;
  59518. /**
  59519. * the log2 of value.
  59520. * @param value the value to compute log2 of
  59521. * @returns the log2 of value.
  59522. */
  59523. static Log2(value: number): number;
  59524. /**
  59525. * Loops the value, so that it is never larger than length and never smaller than 0.
  59526. *
  59527. * This is similar to the modulo operator but it works with floating point numbers.
  59528. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59529. * With t = 5 and length = 2.5, the result would be 0.0.
  59530. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59531. * @param value the value
  59532. * @param length the length
  59533. * @returns the looped value
  59534. */
  59535. static Repeat(value: number, length: number): number;
  59536. /**
  59537. * Normalize the value between 0.0 and 1.0 using min and max values
  59538. * @param value value to normalize
  59539. * @param min max to normalize between
  59540. * @param max min to normalize between
  59541. * @returns the normalized value
  59542. */
  59543. static Normalize(value: number, min: number, max: number): number;
  59544. /**
  59545. * Denormalize the value from 0.0 and 1.0 using min and max values
  59546. * @param normalized value to denormalize
  59547. * @param min max to denormalize between
  59548. * @param max min to denormalize between
  59549. * @returns the denormalized value
  59550. */
  59551. static Denormalize(normalized: number, min: number, max: number): number;
  59552. /**
  59553. * Calculates the shortest difference between two given angles given in degrees.
  59554. * @param current current angle in degrees
  59555. * @param target target angle in degrees
  59556. * @returns the delta
  59557. */
  59558. static DeltaAngle(current: number, target: number): number;
  59559. /**
  59560. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59561. * @param tx value
  59562. * @param length length
  59563. * @returns The returned value will move back and forth between 0 and length
  59564. */
  59565. static PingPong(tx: number, length: number): number;
  59566. /**
  59567. * Interpolates between min and max with smoothing at the limits.
  59568. *
  59569. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59570. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59571. * @param from from
  59572. * @param to to
  59573. * @param tx value
  59574. * @returns the smooth stepped value
  59575. */
  59576. static SmoothStep(from: number, to: number, tx: number): number;
  59577. /**
  59578. * Moves a value current towards target.
  59579. *
  59580. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59581. * Negative values of maxDelta pushes the value away from target.
  59582. * @param current current value
  59583. * @param target target value
  59584. * @param maxDelta max distance to move
  59585. * @returns resulting value
  59586. */
  59587. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59588. /**
  59589. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59590. *
  59591. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59592. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59593. * @param current current value
  59594. * @param target target value
  59595. * @param maxDelta max distance to move
  59596. * @returns resulting angle
  59597. */
  59598. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59599. /**
  59600. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59601. * @param start start value
  59602. * @param end target value
  59603. * @param amount amount to lerp between
  59604. * @returns the lerped value
  59605. */
  59606. static Lerp(start: number, end: number, amount: number): number;
  59607. /**
  59608. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59609. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59610. * @param start start value
  59611. * @param end target value
  59612. * @param amount amount to lerp between
  59613. * @returns the lerped value
  59614. */
  59615. static LerpAngle(start: number, end: number, amount: number): number;
  59616. /**
  59617. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59618. * @param a start value
  59619. * @param b target value
  59620. * @param value value between a and b
  59621. * @returns the inverseLerp value
  59622. */
  59623. static InverseLerp(a: number, b: number, value: number): number;
  59624. /**
  59625. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59626. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59627. * @param value1 spline value
  59628. * @param tangent1 spline value
  59629. * @param value2 spline value
  59630. * @param tangent2 spline value
  59631. * @param amount input value
  59632. * @returns hermite result
  59633. */
  59634. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59635. /**
  59636. * Returns a random float number between and min and max values
  59637. * @param min min value of random
  59638. * @param max max value of random
  59639. * @returns random value
  59640. */
  59641. static RandomRange(min: number, max: number): number;
  59642. /**
  59643. * This function returns percentage of a number in a given range.
  59644. *
  59645. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59646. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59647. * @param number to convert to percentage
  59648. * @param min min range
  59649. * @param max max range
  59650. * @returns the percentage
  59651. */
  59652. static RangeToPercent(number: number, min: number, max: number): number;
  59653. /**
  59654. * This function returns number that corresponds to the percentage in a given range.
  59655. *
  59656. * PercentToRange(0.34,0,100) will return 34.
  59657. * @param percent to convert to number
  59658. * @param min min range
  59659. * @param max max range
  59660. * @returns the number
  59661. */
  59662. static PercentToRange(percent: number, min: number, max: number): number;
  59663. /**
  59664. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59665. * @param angle The angle to normalize in radian.
  59666. * @return The converted angle.
  59667. */
  59668. static NormalizeRadians(angle: number): number;
  59669. }
  59670. }
  59671. declare module BABYLON {
  59672. /**
  59673. * Constant used to convert a value to gamma space
  59674. * @ignorenaming
  59675. */
  59676. export const ToGammaSpace: number;
  59677. /**
  59678. * Constant used to convert a value to linear space
  59679. * @ignorenaming
  59680. */
  59681. export const ToLinearSpace = 2.2;
  59682. /**
  59683. * Constant used to define the minimal number value in Babylon.js
  59684. * @ignorenaming
  59685. */
  59686. let Epsilon: number;
  59687. /**
  59688. * Class used to hold a RBG color
  59689. */
  59690. export class Color3 {
  59691. /**
  59692. * Defines the red component (between 0 and 1, default is 0)
  59693. */
  59694. r: number;
  59695. /**
  59696. * Defines the green component (between 0 and 1, default is 0)
  59697. */
  59698. g: number;
  59699. /**
  59700. * Defines the blue component (between 0 and 1, default is 0)
  59701. */
  59702. b: number;
  59703. /**
  59704. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  59705. * @param r defines the red component (between 0 and 1, default is 0)
  59706. * @param g defines the green component (between 0 and 1, default is 0)
  59707. * @param b defines the blue component (between 0 and 1, default is 0)
  59708. */
  59709. constructor(
  59710. /**
  59711. * Defines the red component (between 0 and 1, default is 0)
  59712. */
  59713. r?: number,
  59714. /**
  59715. * Defines the green component (between 0 and 1, default is 0)
  59716. */
  59717. g?: number,
  59718. /**
  59719. * Defines the blue component (between 0 and 1, default is 0)
  59720. */
  59721. b?: number);
  59722. /**
  59723. * Creates a string with the Color3 current values
  59724. * @returns the string representation of the Color3 object
  59725. */
  59726. toString(): string;
  59727. /**
  59728. * Returns the string "Color3"
  59729. * @returns "Color3"
  59730. */
  59731. getClassName(): string;
  59732. /**
  59733. * Compute the Color3 hash code
  59734. * @returns an unique number that can be used to hash Color3 objects
  59735. */
  59736. getHashCode(): number;
  59737. /**
  59738. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  59739. * @param array defines the array where to store the r,g,b components
  59740. * @param index defines an optional index in the target array to define where to start storing values
  59741. * @returns the current Color3 object
  59742. */
  59743. toArray(array: FloatArray, index?: number): Color3;
  59744. /**
  59745. * Returns a new Color4 object from the current Color3 and the given alpha
  59746. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  59747. * @returns a new Color4 object
  59748. */
  59749. toColor4(alpha?: number): Color4;
  59750. /**
  59751. * Returns a new array populated with 3 numeric elements : red, green and blue values
  59752. * @returns the new array
  59753. */
  59754. asArray(): number[];
  59755. /**
  59756. * Returns the luminance value
  59757. * @returns a float value
  59758. */
  59759. toLuminance(): number;
  59760. /**
  59761. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  59762. * @param otherColor defines the second operand
  59763. * @returns the new Color3 object
  59764. */
  59765. multiply(otherColor: DeepImmutable<Color3>): Color3;
  59766. /**
  59767. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  59768. * @param otherColor defines the second operand
  59769. * @param result defines the Color3 object where to store the result
  59770. * @returns the current Color3
  59771. */
  59772. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59773. /**
  59774. * Determines equality between Color3 objects
  59775. * @param otherColor defines the second operand
  59776. * @returns true if the rgb values are equal to the given ones
  59777. */
  59778. equals(otherColor: DeepImmutable<Color3>): boolean;
  59779. /**
  59780. * Determines equality between the current Color3 object and a set of r,b,g values
  59781. * @param r defines the red component to check
  59782. * @param g defines the green component to check
  59783. * @param b defines the blue component to check
  59784. * @returns true if the rgb values are equal to the given ones
  59785. */
  59786. equalsFloats(r: number, g: number, b: number): boolean;
  59787. /**
  59788. * Multiplies in place each rgb value by scale
  59789. * @param scale defines the scaling factor
  59790. * @returns the updated Color3
  59791. */
  59792. scale(scale: number): Color3;
  59793. /**
  59794. * Multiplies the rgb values by scale and stores the result into "result"
  59795. * @param scale defines the scaling factor
  59796. * @param result defines the Color3 object where to store the result
  59797. * @returns the unmodified current Color3
  59798. */
  59799. scaleToRef(scale: number, result: Color3): Color3;
  59800. /**
  59801. * Scale the current Color3 values by a factor and add the result to a given Color3
  59802. * @param scale defines the scale factor
  59803. * @param result defines color to store the result into
  59804. * @returns the unmodified current Color3
  59805. */
  59806. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59807. /**
  59808. * Clamps the rgb values by the min and max values and stores the result into "result"
  59809. * @param min defines minimum clamping value (default is 0)
  59810. * @param max defines maximum clamping value (default is 1)
  59811. * @param result defines color to store the result into
  59812. * @returns the original Color3
  59813. */
  59814. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59815. /**
  59816. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59817. * @param otherColor defines the second operand
  59818. * @returns the new Color3
  59819. */
  59820. add(otherColor: DeepImmutable<Color3>): Color3;
  59821. /**
  59822. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59823. * @param otherColor defines the second operand
  59824. * @param result defines Color3 object to store the result into
  59825. * @returns the unmodified current Color3
  59826. */
  59827. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59828. /**
  59829. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59830. * @param otherColor defines the second operand
  59831. * @returns the new Color3
  59832. */
  59833. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59834. /**
  59835. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59836. * @param otherColor defines the second operand
  59837. * @param result defines Color3 object to store the result into
  59838. * @returns the unmodified current Color3
  59839. */
  59840. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59841. /**
  59842. * Copy the current object
  59843. * @returns a new Color3 copied the current one
  59844. */
  59845. clone(): Color3;
  59846. /**
  59847. * Copies the rgb values from the source in the current Color3
  59848. * @param source defines the source Color3 object
  59849. * @returns the updated Color3 object
  59850. */
  59851. copyFrom(source: DeepImmutable<Color3>): Color3;
  59852. /**
  59853. * Updates the Color3 rgb values from the given floats
  59854. * @param r defines the red component to read from
  59855. * @param g defines the green component to read from
  59856. * @param b defines the blue component to read from
  59857. * @returns the current Color3 object
  59858. */
  59859. copyFromFloats(r: number, g: number, b: number): Color3;
  59860. /**
  59861. * Updates the Color3 rgb values from the given floats
  59862. * @param r defines the red component to read from
  59863. * @param g defines the green component to read from
  59864. * @param b defines the blue component to read from
  59865. * @returns the current Color3 object
  59866. */
  59867. set(r: number, g: number, b: number): Color3;
  59868. /**
  59869. * Compute the Color3 hexadecimal code as a string
  59870. * @returns a string containing the hexadecimal representation of the Color3 object
  59871. */
  59872. toHexString(): string;
  59873. /**
  59874. * Computes a new Color3 converted from the current one to linear space
  59875. * @returns a new Color3 object
  59876. */
  59877. toLinearSpace(): Color3;
  59878. /**
  59879. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  59880. * @param convertedColor defines the Color3 object where to store the linear space version
  59881. * @returns the unmodified Color3
  59882. */
  59883. toLinearSpaceToRef(convertedColor: Color3): Color3;
  59884. /**
  59885. * Computes a new Color3 converted from the current one to gamma space
  59886. * @returns a new Color3 object
  59887. */
  59888. toGammaSpace(): Color3;
  59889. /**
  59890. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  59891. * @param convertedColor defines the Color3 object where to store the gamma space version
  59892. * @returns the unmodified Color3
  59893. */
  59894. toGammaSpaceToRef(convertedColor: Color3): Color3;
  59895. private static _BlackReadOnly;
  59896. /**
  59897. * Creates a new Color3 from the string containing valid hexadecimal values
  59898. * @param hex defines a string containing valid hexadecimal values
  59899. * @returns a new Color3 object
  59900. */
  59901. static FromHexString(hex: string): Color3;
  59902. /**
  59903. * Creates a new Vector3 from the starting index of the given array
  59904. * @param array defines the source array
  59905. * @param offset defines an offset in the source array
  59906. * @returns a new Color3 object
  59907. */
  59908. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  59909. /**
  59910. * Creates a new Color3 from integer values (< 256)
  59911. * @param r defines the red component to read from (value between 0 and 255)
  59912. * @param g defines the green component to read from (value between 0 and 255)
  59913. * @param b defines the blue component to read from (value between 0 and 255)
  59914. * @returns a new Color3 object
  59915. */
  59916. static FromInts(r: number, g: number, b: number): Color3;
  59917. /**
  59918. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59919. * @param start defines the start Color3 value
  59920. * @param end defines the end Color3 value
  59921. * @param amount defines the gradient value between start and end
  59922. * @returns a new Color3 object
  59923. */
  59924. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59925. /**
  59926. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59927. * @param left defines the start value
  59928. * @param right defines the end value
  59929. * @param amount defines the gradient factor
  59930. * @param result defines the Color3 object where to store the result
  59931. */
  59932. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59933. /**
  59934. * Returns a Color3 value containing a red color
  59935. * @returns a new Color3 object
  59936. */
  59937. static Red(): Color3;
  59938. /**
  59939. * Returns a Color3 value containing a green color
  59940. * @returns a new Color3 object
  59941. */
  59942. static Green(): Color3;
  59943. /**
  59944. * Returns a Color3 value containing a blue color
  59945. * @returns a new Color3 object
  59946. */
  59947. static Blue(): Color3;
  59948. /**
  59949. * Returns a Color3 value containing a black color
  59950. * @returns a new Color3 object
  59951. */
  59952. static Black(): Color3;
  59953. /**
  59954. * Gets a Color3 value containing a black color that must not be updated
  59955. */
  59956. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59957. /**
  59958. * Returns a Color3 value containing a white color
  59959. * @returns a new Color3 object
  59960. */
  59961. static White(): Color3;
  59962. /**
  59963. * Returns a Color3 value containing a purple color
  59964. * @returns a new Color3 object
  59965. */
  59966. static Purple(): Color3;
  59967. /**
  59968. * Returns a Color3 value containing a magenta color
  59969. * @returns a new Color3 object
  59970. */
  59971. static Magenta(): Color3;
  59972. /**
  59973. * Returns a Color3 value containing a yellow color
  59974. * @returns a new Color3 object
  59975. */
  59976. static Yellow(): Color3;
  59977. /**
  59978. * Returns a Color3 value containing a gray color
  59979. * @returns a new Color3 object
  59980. */
  59981. static Gray(): Color3;
  59982. /**
  59983. * Returns a Color3 value containing a teal color
  59984. * @returns a new Color3 object
  59985. */
  59986. static Teal(): Color3;
  59987. /**
  59988. * Returns a Color3 value containing a random color
  59989. * @returns a new Color3 object
  59990. */
  59991. static Random(): Color3;
  59992. }
  59993. /**
  59994. * Class used to hold a RBGA color
  59995. */
  59996. export class Color4 {
  59997. /**
  59998. * Defines the red component (between 0 and 1, default is 0)
  59999. */
  60000. r: number;
  60001. /**
  60002. * Defines the green component (between 0 and 1, default is 0)
  60003. */
  60004. g: number;
  60005. /**
  60006. * Defines the blue component (between 0 and 1, default is 0)
  60007. */
  60008. b: number;
  60009. /**
  60010. * Defines the alpha component (between 0 and 1, default is 1)
  60011. */
  60012. a: number;
  60013. /**
  60014. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60015. * @param r defines the red component (between 0 and 1, default is 0)
  60016. * @param g defines the green component (between 0 and 1, default is 0)
  60017. * @param b defines the blue component (between 0 and 1, default is 0)
  60018. * @param a defines the alpha component (between 0 and 1, default is 1)
  60019. */
  60020. constructor(
  60021. /**
  60022. * Defines the red component (between 0 and 1, default is 0)
  60023. */
  60024. r?: number,
  60025. /**
  60026. * Defines the green component (between 0 and 1, default is 0)
  60027. */
  60028. g?: number,
  60029. /**
  60030. * Defines the blue component (between 0 and 1, default is 0)
  60031. */
  60032. b?: number,
  60033. /**
  60034. * Defines the alpha component (between 0 and 1, default is 1)
  60035. */
  60036. a?: number);
  60037. /**
  60038. * Adds in place the given Color4 values to the current Color4 object
  60039. * @param right defines the second operand
  60040. * @returns the current updated Color4 object
  60041. */
  60042. addInPlace(right: DeepImmutable<Color4>): Color4;
  60043. /**
  60044. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60045. * @returns the new array
  60046. */
  60047. asArray(): number[];
  60048. /**
  60049. * Stores from the starting index in the given array the Color4 successive values
  60050. * @param array defines the array where to store the r,g,b components
  60051. * @param index defines an optional index in the target array to define where to start storing values
  60052. * @returns the current Color4 object
  60053. */
  60054. toArray(array: number[], index?: number): Color4;
  60055. /**
  60056. * Determines equality between Color4 objects
  60057. * @param otherColor defines the second operand
  60058. * @returns true if the rgba values are equal to the given ones
  60059. */
  60060. equals(otherColor: DeepImmutable<Color4>): boolean;
  60061. /**
  60062. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60063. * @param right defines the second operand
  60064. * @returns a new Color4 object
  60065. */
  60066. add(right: DeepImmutable<Color4>): Color4;
  60067. /**
  60068. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60069. * @param right defines the second operand
  60070. * @returns a new Color4 object
  60071. */
  60072. subtract(right: DeepImmutable<Color4>): Color4;
  60073. /**
  60074. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60075. * @param right defines the second operand
  60076. * @param result defines the Color4 object where to store the result
  60077. * @returns the current Color4 object
  60078. */
  60079. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60080. /**
  60081. * Creates a new Color4 with the current Color4 values multiplied by scale
  60082. * @param scale defines the scaling factor to apply
  60083. * @returns a new Color4 object
  60084. */
  60085. scale(scale: number): Color4;
  60086. /**
  60087. * Multiplies the current Color4 values by scale and stores the result in "result"
  60088. * @param scale defines the scaling factor to apply
  60089. * @param result defines the Color4 object where to store the result
  60090. * @returns the current unmodified Color4
  60091. */
  60092. scaleToRef(scale: number, result: Color4): Color4;
  60093. /**
  60094. * Scale the current Color4 values by a factor and add the result to a given Color4
  60095. * @param scale defines the scale factor
  60096. * @param result defines the Color4 object where to store the result
  60097. * @returns the unmodified current Color4
  60098. */
  60099. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60100. /**
  60101. * Clamps the rgb values by the min and max values and stores the result into "result"
  60102. * @param min defines minimum clamping value (default is 0)
  60103. * @param max defines maximum clamping value (default is 1)
  60104. * @param result defines color to store the result into.
  60105. * @returns the cuurent Color4
  60106. */
  60107. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60108. /**
  60109. * Multipy an Color4 value by another and return a new Color4 object
  60110. * @param color defines the Color4 value to multiply by
  60111. * @returns a new Color4 object
  60112. */
  60113. multiply(color: Color4): Color4;
  60114. /**
  60115. * Multipy a Color4 value by another and push the result in a reference value
  60116. * @param color defines the Color4 value to multiply by
  60117. * @param result defines the Color4 to fill the result in
  60118. * @returns the result Color4
  60119. */
  60120. multiplyToRef(color: Color4, result: Color4): Color4;
  60121. /**
  60122. * Creates a string with the Color4 current values
  60123. * @returns the string representation of the Color4 object
  60124. */
  60125. toString(): string;
  60126. /**
  60127. * Returns the string "Color4"
  60128. * @returns "Color4"
  60129. */
  60130. getClassName(): string;
  60131. /**
  60132. * Compute the Color4 hash code
  60133. * @returns an unique number that can be used to hash Color4 objects
  60134. */
  60135. getHashCode(): number;
  60136. /**
  60137. * Creates a new Color4 copied from the current one
  60138. * @returns a new Color4 object
  60139. */
  60140. clone(): Color4;
  60141. /**
  60142. * Copies the given Color4 values into the current one
  60143. * @param source defines the source Color4 object
  60144. * @returns the current updated Color4 object
  60145. */
  60146. copyFrom(source: Color4): Color4;
  60147. /**
  60148. * Copies the given float values into the current one
  60149. * @param r defines the red component to read from
  60150. * @param g defines the green component to read from
  60151. * @param b defines the blue component to read from
  60152. * @param a defines the alpha component to read from
  60153. * @returns the current updated Color4 object
  60154. */
  60155. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60156. /**
  60157. * Copies the given float values into the current one
  60158. * @param r defines the red component to read from
  60159. * @param g defines the green component to read from
  60160. * @param b defines the blue component to read from
  60161. * @param a defines the alpha component to read from
  60162. * @returns the current updated Color4 object
  60163. */
  60164. set(r: number, g: number, b: number, a: number): Color4;
  60165. /**
  60166. * Compute the Color4 hexadecimal code as a string
  60167. * @returns a string containing the hexadecimal representation of the Color4 object
  60168. */
  60169. toHexString(): string;
  60170. /**
  60171. * Computes a new Color4 converted from the current one to linear space
  60172. * @returns a new Color4 object
  60173. */
  60174. toLinearSpace(): Color4;
  60175. /**
  60176. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60177. * @param convertedColor defines the Color4 object where to store the linear space version
  60178. * @returns the unmodified Color4
  60179. */
  60180. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60181. /**
  60182. * Computes a new Color4 converted from the current one to gamma space
  60183. * @returns a new Color4 object
  60184. */
  60185. toGammaSpace(): Color4;
  60186. /**
  60187. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60188. * @param convertedColor defines the Color4 object where to store the gamma space version
  60189. * @returns the unmodified Color4
  60190. */
  60191. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60192. /**
  60193. * Creates a new Color4 from the string containing valid hexadecimal values
  60194. * @param hex defines a string containing valid hexadecimal values
  60195. * @returns a new Color4 object
  60196. */
  60197. static FromHexString(hex: string): Color4;
  60198. /**
  60199. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60200. * @param left defines the start value
  60201. * @param right defines the end value
  60202. * @param amount defines the gradient factor
  60203. * @returns a new Color4 object
  60204. */
  60205. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60206. /**
  60207. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60208. * @param left defines the start value
  60209. * @param right defines the end value
  60210. * @param amount defines the gradient factor
  60211. * @param result defines the Color4 object where to store data
  60212. */
  60213. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60214. /**
  60215. * Creates a new Color4 from a Color3 and an alpha value
  60216. * @param color3 defines the source Color3 to read from
  60217. * @param alpha defines the alpha component (1.0 by default)
  60218. * @returns a new Color4 object
  60219. */
  60220. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60221. /**
  60222. * Creates a new Color4 from the starting index element of the given array
  60223. * @param array defines the source array to read from
  60224. * @param offset defines the offset in the source array
  60225. * @returns a new Color4 object
  60226. */
  60227. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60228. /**
  60229. * Creates a new Color3 from integer values (< 256)
  60230. * @param r defines the red component to read from (value between 0 and 255)
  60231. * @param g defines the green component to read from (value between 0 and 255)
  60232. * @param b defines the blue component to read from (value between 0 and 255)
  60233. * @param a defines the alpha component to read from (value between 0 and 255)
  60234. * @returns a new Color3 object
  60235. */
  60236. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60237. /**
  60238. * Check the content of a given array and convert it to an array containing RGBA data
  60239. * If the original array was already containing count * 4 values then it is returned directly
  60240. * @param colors defines the array to check
  60241. * @param count defines the number of RGBA data to expect
  60242. * @returns an array containing count * 4 values (RGBA)
  60243. */
  60244. static CheckColors4(colors: number[], count: number): number[];
  60245. }
  60246. /**
  60247. * Class representing a vector containing 2 coordinates
  60248. */
  60249. export class Vector2 {
  60250. /** defines the first coordinate */
  60251. x: number;
  60252. /** defines the second coordinate */
  60253. y: number;
  60254. /**
  60255. * Creates a new Vector2 from the given x and y coordinates
  60256. * @param x defines the first coordinate
  60257. * @param y defines the second coordinate
  60258. */
  60259. constructor(
  60260. /** defines the first coordinate */
  60261. x?: number,
  60262. /** defines the second coordinate */
  60263. y?: number);
  60264. /**
  60265. * Gets a string with the Vector2 coordinates
  60266. * @returns a string with the Vector2 coordinates
  60267. */
  60268. toString(): string;
  60269. /**
  60270. * Gets class name
  60271. * @returns the string "Vector2"
  60272. */
  60273. getClassName(): string;
  60274. /**
  60275. * Gets current vector hash code
  60276. * @returns the Vector2 hash code as a number
  60277. */
  60278. getHashCode(): number;
  60279. /**
  60280. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60281. * @param array defines the source array
  60282. * @param index defines the offset in source array
  60283. * @returns the current Vector2
  60284. */
  60285. toArray(array: FloatArray, index?: number): Vector2;
  60286. /**
  60287. * Copy the current vector to an array
  60288. * @returns a new array with 2 elements: the Vector2 coordinates.
  60289. */
  60290. asArray(): number[];
  60291. /**
  60292. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60293. * @param source defines the source Vector2
  60294. * @returns the current updated Vector2
  60295. */
  60296. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60297. /**
  60298. * Sets the Vector2 coordinates with the given floats
  60299. * @param x defines the first coordinate
  60300. * @param y defines the second coordinate
  60301. * @returns the current updated Vector2
  60302. */
  60303. copyFromFloats(x: number, y: number): Vector2;
  60304. /**
  60305. * Sets the Vector2 coordinates with the given floats
  60306. * @param x defines the first coordinate
  60307. * @param y defines the second coordinate
  60308. * @returns the current updated Vector2
  60309. */
  60310. set(x: number, y: number): Vector2;
  60311. /**
  60312. * Add another vector with the current one
  60313. * @param otherVector defines the other vector
  60314. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60315. */
  60316. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60317. /**
  60318. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60319. * @param otherVector defines the other vector
  60320. * @param result defines the target vector
  60321. * @returns the unmodified current Vector2
  60322. */
  60323. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60324. /**
  60325. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60326. * @param otherVector defines the other vector
  60327. * @returns the current updated Vector2
  60328. */
  60329. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60330. /**
  60331. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60332. * @param otherVector defines the other vector
  60333. * @returns a new Vector2
  60334. */
  60335. addVector3(otherVector: Vector3): Vector2;
  60336. /**
  60337. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60338. * @param otherVector defines the other vector
  60339. * @returns a new Vector2
  60340. */
  60341. subtract(otherVector: Vector2): Vector2;
  60342. /**
  60343. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60344. * @param otherVector defines the other vector
  60345. * @param result defines the target vector
  60346. * @returns the unmodified current Vector2
  60347. */
  60348. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60349. /**
  60350. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60351. * @param otherVector defines the other vector
  60352. * @returns the current updated Vector2
  60353. */
  60354. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60355. /**
  60356. * Multiplies in place the current Vector2 coordinates by the given ones
  60357. * @param otherVector defines the other vector
  60358. * @returns the current updated Vector2
  60359. */
  60360. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60361. /**
  60362. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60363. * @param otherVector defines the other vector
  60364. * @returns a new Vector2
  60365. */
  60366. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60367. /**
  60368. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60369. * @param otherVector defines the other vector
  60370. * @param result defines the target vector
  60371. * @returns the unmodified current Vector2
  60372. */
  60373. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60374. /**
  60375. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60376. * @param x defines the first coordinate
  60377. * @param y defines the second coordinate
  60378. * @returns a new Vector2
  60379. */
  60380. multiplyByFloats(x: number, y: number): Vector2;
  60381. /**
  60382. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60383. * @param otherVector defines the other vector
  60384. * @returns a new Vector2
  60385. */
  60386. divide(otherVector: Vector2): Vector2;
  60387. /**
  60388. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60389. * @param otherVector defines the other vector
  60390. * @param result defines the target vector
  60391. * @returns the unmodified current Vector2
  60392. */
  60393. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60394. /**
  60395. * Divides the current Vector2 coordinates by the given ones
  60396. * @param otherVector defines the other vector
  60397. * @returns the current updated Vector2
  60398. */
  60399. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60400. /**
  60401. * Gets a new Vector2 with current Vector2 negated coordinates
  60402. * @returns a new Vector2
  60403. */
  60404. negate(): Vector2;
  60405. /**
  60406. * Multiply the Vector2 coordinates by scale
  60407. * @param scale defines the scaling factor
  60408. * @returns the current updated Vector2
  60409. */
  60410. scaleInPlace(scale: number): Vector2;
  60411. /**
  60412. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60413. * @param scale defines the scaling factor
  60414. * @returns a new Vector2
  60415. */
  60416. scale(scale: number): Vector2;
  60417. /**
  60418. * Scale the current Vector2 values by a factor to a given Vector2
  60419. * @param scale defines the scale factor
  60420. * @param result defines the Vector2 object where to store the result
  60421. * @returns the unmodified current Vector2
  60422. */
  60423. scaleToRef(scale: number, result: Vector2): Vector2;
  60424. /**
  60425. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60426. * @param scale defines the scale factor
  60427. * @param result defines the Vector2 object where to store the result
  60428. * @returns the unmodified current Vector2
  60429. */
  60430. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60431. /**
  60432. * Gets a boolean if two vectors are equals
  60433. * @param otherVector defines the other vector
  60434. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60435. */
  60436. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60437. /**
  60438. * Gets a boolean if two vectors are equals (using an epsilon value)
  60439. * @param otherVector defines the other vector
  60440. * @param epsilon defines the minimal distance to consider equality
  60441. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60442. */
  60443. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60444. /**
  60445. * Gets a new Vector2 from current Vector2 floored values
  60446. * @returns a new Vector2
  60447. */
  60448. floor(): Vector2;
  60449. /**
  60450. * Gets a new Vector2 from current Vector2 floored values
  60451. * @returns a new Vector2
  60452. */
  60453. fract(): Vector2;
  60454. /**
  60455. * Gets the length of the vector
  60456. * @returns the vector length (float)
  60457. */
  60458. length(): number;
  60459. /**
  60460. * Gets the vector squared length
  60461. * @returns the vector squared length (float)
  60462. */
  60463. lengthSquared(): number;
  60464. /**
  60465. * Normalize the vector
  60466. * @returns the current updated Vector2
  60467. */
  60468. normalize(): Vector2;
  60469. /**
  60470. * Gets a new Vector2 copied from the Vector2
  60471. * @returns a new Vector2
  60472. */
  60473. clone(): Vector2;
  60474. /**
  60475. * Gets a new Vector2(0, 0)
  60476. * @returns a new Vector2
  60477. */
  60478. static Zero(): Vector2;
  60479. /**
  60480. * Gets a new Vector2(1, 1)
  60481. * @returns a new Vector2
  60482. */
  60483. static One(): Vector2;
  60484. /**
  60485. * Gets a new Vector2 set from the given index element of the given array
  60486. * @param array defines the data source
  60487. * @param offset defines the offset in the data source
  60488. * @returns a new Vector2
  60489. */
  60490. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60491. /**
  60492. * Sets "result" from the given index element of the given array
  60493. * @param array defines the data source
  60494. * @param offset defines the offset in the data source
  60495. * @param result defines the target vector
  60496. */
  60497. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60498. /**
  60499. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60500. * @param value1 defines 1st point of control
  60501. * @param value2 defines 2nd point of control
  60502. * @param value3 defines 3rd point of control
  60503. * @param value4 defines 4th point of control
  60504. * @param amount defines the interpolation factor
  60505. * @returns a new Vector2
  60506. */
  60507. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60508. /**
  60509. * 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".
  60510. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60511. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60512. * @param value defines the value to clamp
  60513. * @param min defines the lower limit
  60514. * @param max defines the upper limit
  60515. * @returns a new Vector2
  60516. */
  60517. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60518. /**
  60519. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60520. * @param value1 defines the 1st control point
  60521. * @param tangent1 defines the outgoing tangent
  60522. * @param value2 defines the 2nd control point
  60523. * @param tangent2 defines the incoming tangent
  60524. * @param amount defines the interpolation factor
  60525. * @returns a new Vector2
  60526. */
  60527. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60528. /**
  60529. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60530. * @param start defines the start vector
  60531. * @param end defines the end vector
  60532. * @param amount defines the interpolation factor
  60533. * @returns a new Vector2
  60534. */
  60535. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60536. /**
  60537. * Gets the dot product of the vector "left" and the vector "right"
  60538. * @param left defines first vector
  60539. * @param right defines second vector
  60540. * @returns the dot product (float)
  60541. */
  60542. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60543. /**
  60544. * Returns a new Vector2 equal to the normalized given vector
  60545. * @param vector defines the vector to normalize
  60546. * @returns a new Vector2
  60547. */
  60548. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60549. /**
  60550. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60551. * @param left defines 1st vector
  60552. * @param right defines 2nd vector
  60553. * @returns a new Vector2
  60554. */
  60555. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60556. /**
  60557. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60558. * @param left defines 1st vector
  60559. * @param right defines 2nd vector
  60560. * @returns a new Vector2
  60561. */
  60562. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60563. /**
  60564. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60565. * @param vector defines the vector to transform
  60566. * @param transformation defines the matrix to apply
  60567. * @returns a new Vector2
  60568. */
  60569. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60570. /**
  60571. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60572. * @param vector defines the vector to transform
  60573. * @param transformation defines the matrix to apply
  60574. * @param result defines the target vector
  60575. */
  60576. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60577. /**
  60578. * Determines if a given vector is included in a triangle
  60579. * @param p defines the vector to test
  60580. * @param p0 defines 1st triangle point
  60581. * @param p1 defines 2nd triangle point
  60582. * @param p2 defines 3rd triangle point
  60583. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60584. */
  60585. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60586. /**
  60587. * Gets the distance between the vectors "value1" and "value2"
  60588. * @param value1 defines first vector
  60589. * @param value2 defines second vector
  60590. * @returns the distance between vectors
  60591. */
  60592. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60593. /**
  60594. * Returns the squared distance between the vectors "value1" and "value2"
  60595. * @param value1 defines first vector
  60596. * @param value2 defines second vector
  60597. * @returns the squared distance between vectors
  60598. */
  60599. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60600. /**
  60601. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60602. * @param value1 defines first vector
  60603. * @param value2 defines second vector
  60604. * @returns a new Vector2
  60605. */
  60606. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60607. /**
  60608. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60609. * @param p defines the middle point
  60610. * @param segA defines one point of the segment
  60611. * @param segB defines the other point of the segment
  60612. * @returns the shortest distance
  60613. */
  60614. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60615. }
  60616. /**
  60617. * Classed used to store (x,y,z) vector representation
  60618. * A Vector3 is the main object used in 3D geometry
  60619. * It can represent etiher the coordinates of a point the space, either a direction
  60620. * Reminder: js uses a left handed forward facing system
  60621. */
  60622. export class Vector3 {
  60623. /**
  60624. * Defines the first coordinates (on X axis)
  60625. */
  60626. x: number;
  60627. /**
  60628. * Defines the second coordinates (on Y axis)
  60629. */
  60630. y: number;
  60631. /**
  60632. * Defines the third coordinates (on Z axis)
  60633. */
  60634. z: number;
  60635. private static _UpReadOnly;
  60636. /**
  60637. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60638. * @param x defines the first coordinates (on X axis)
  60639. * @param y defines the second coordinates (on Y axis)
  60640. * @param z defines the third coordinates (on Z axis)
  60641. */
  60642. constructor(
  60643. /**
  60644. * Defines the first coordinates (on X axis)
  60645. */
  60646. x?: number,
  60647. /**
  60648. * Defines the second coordinates (on Y axis)
  60649. */
  60650. y?: number,
  60651. /**
  60652. * Defines the third coordinates (on Z axis)
  60653. */
  60654. z?: number);
  60655. /**
  60656. * Creates a string representation of the Vector3
  60657. * @returns a string with the Vector3 coordinates.
  60658. */
  60659. toString(): string;
  60660. /**
  60661. * Gets the class name
  60662. * @returns the string "Vector3"
  60663. */
  60664. getClassName(): string;
  60665. /**
  60666. * Creates the Vector3 hash code
  60667. * @returns a number which tends to be unique between Vector3 instances
  60668. */
  60669. getHashCode(): number;
  60670. /**
  60671. * Creates an array containing three elements : the coordinates of the Vector3
  60672. * @returns a new array of numbers
  60673. */
  60674. asArray(): number[];
  60675. /**
  60676. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60677. * @param array defines the destination array
  60678. * @param index defines the offset in the destination array
  60679. * @returns the current Vector3
  60680. */
  60681. toArray(array: FloatArray, index?: number): Vector3;
  60682. /**
  60683. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60684. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60685. */
  60686. toQuaternion(): Quaternion;
  60687. /**
  60688. * Adds the given vector to the current Vector3
  60689. * @param otherVector defines the second operand
  60690. * @returns the current updated Vector3
  60691. */
  60692. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60693. /**
  60694. * Adds the given coordinates to the current Vector3
  60695. * @param x defines the x coordinate of the operand
  60696. * @param y defines the y coordinate of the operand
  60697. * @param z defines the z coordinate of the operand
  60698. * @returns the current updated Vector3
  60699. */
  60700. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60701. /**
  60702. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  60703. * @param otherVector defines the second operand
  60704. * @returns the resulting Vector3
  60705. */
  60706. add(otherVector: DeepImmutable<Vector3>): Vector3;
  60707. /**
  60708. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  60709. * @param otherVector defines the second operand
  60710. * @param result defines the Vector3 object where to store the result
  60711. * @returns the current Vector3
  60712. */
  60713. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60714. /**
  60715. * Subtract the given vector from the current Vector3
  60716. * @param otherVector defines the second operand
  60717. * @returns the current updated Vector3
  60718. */
  60719. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60720. /**
  60721. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  60722. * @param otherVector defines the second operand
  60723. * @returns the resulting Vector3
  60724. */
  60725. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  60726. /**
  60727. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  60728. * @param otherVector defines the second operand
  60729. * @param result defines the Vector3 object where to store the result
  60730. * @returns the current Vector3
  60731. */
  60732. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60733. /**
  60734. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  60735. * @param x defines the x coordinate of the operand
  60736. * @param y defines the y coordinate of the operand
  60737. * @param z defines the z coordinate of the operand
  60738. * @returns the resulting Vector3
  60739. */
  60740. subtractFromFloats(x: number, y: number, z: number): Vector3;
  60741. /**
  60742. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  60743. * @param x defines the x coordinate of the operand
  60744. * @param y defines the y coordinate of the operand
  60745. * @param z defines the z coordinate of the operand
  60746. * @param result defines the Vector3 object where to store the result
  60747. * @returns the current Vector3
  60748. */
  60749. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  60750. /**
  60751. * Gets a new Vector3 set with the current Vector3 negated coordinates
  60752. * @returns a new Vector3
  60753. */
  60754. negate(): Vector3;
  60755. /**
  60756. * Multiplies the Vector3 coordinates by the float "scale"
  60757. * @param scale defines the multiplier factor
  60758. * @returns the current updated Vector3
  60759. */
  60760. scaleInPlace(scale: number): Vector3;
  60761. /**
  60762. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  60763. * @param scale defines the multiplier factor
  60764. * @returns a new Vector3
  60765. */
  60766. scale(scale: number): Vector3;
  60767. /**
  60768. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  60769. * @param scale defines the multiplier factor
  60770. * @param result defines the Vector3 object where to store the result
  60771. * @returns the current Vector3
  60772. */
  60773. scaleToRef(scale: number, result: Vector3): Vector3;
  60774. /**
  60775. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60776. * @param scale defines the scale factor
  60777. * @param result defines the Vector3 object where to store the result
  60778. * @returns the unmodified current Vector3
  60779. */
  60780. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  60781. /**
  60782. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  60783. * @param otherVector defines the second operand
  60784. * @returns true if both vectors are equals
  60785. */
  60786. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60787. /**
  60788. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60789. * @param otherVector defines the second operand
  60790. * @param epsilon defines the minimal distance to define values as equals
  60791. * @returns true if both vectors are distant less than epsilon
  60792. */
  60793. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60794. /**
  60795. * Returns true if the current Vector3 coordinates equals the given floats
  60796. * @param x defines the x coordinate of the operand
  60797. * @param y defines the y coordinate of the operand
  60798. * @param z defines the z coordinate of the operand
  60799. * @returns true if both vectors are equals
  60800. */
  60801. equalsToFloats(x: number, y: number, z: number): boolean;
  60802. /**
  60803. * Multiplies the current Vector3 coordinates by the given ones
  60804. * @param otherVector defines the second operand
  60805. * @returns the current updated Vector3
  60806. */
  60807. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60808. /**
  60809. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60810. * @param otherVector defines the second operand
  60811. * @returns the new Vector3
  60812. */
  60813. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60814. /**
  60815. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60816. * @param otherVector defines the second operand
  60817. * @param result defines the Vector3 object where to store the result
  60818. * @returns the current Vector3
  60819. */
  60820. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60821. /**
  60822. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60823. * @param x defines the x coordinate of the operand
  60824. * @param y defines the y coordinate of the operand
  60825. * @param z defines the z coordinate of the operand
  60826. * @returns the new Vector3
  60827. */
  60828. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60829. /**
  60830. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60831. * @param otherVector defines the second operand
  60832. * @returns the new Vector3
  60833. */
  60834. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60835. /**
  60836. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60837. * @param otherVector defines the second operand
  60838. * @param result defines the Vector3 object where to store the result
  60839. * @returns the current Vector3
  60840. */
  60841. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60842. /**
  60843. * Divides the current Vector3 coordinates by the given ones.
  60844. * @param otherVector defines the second operand
  60845. * @returns the current updated Vector3
  60846. */
  60847. divideInPlace(otherVector: Vector3): Vector3;
  60848. /**
  60849. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60850. * @param other defines the second operand
  60851. * @returns the current updated Vector3
  60852. */
  60853. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60854. /**
  60855. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60856. * @param other defines the second operand
  60857. * @returns the current updated Vector3
  60858. */
  60859. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60860. /**
  60861. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  60862. * @param x defines the x coordinate of the operand
  60863. * @param y defines the y coordinate of the operand
  60864. * @param z defines the z coordinate of the operand
  60865. * @returns the current updated Vector3
  60866. */
  60867. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60868. /**
  60869. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  60870. * @param x defines the x coordinate of the operand
  60871. * @param y defines the y coordinate of the operand
  60872. * @param z defines the z coordinate of the operand
  60873. * @returns the current updated Vector3
  60874. */
  60875. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60876. /**
  60877. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  60878. * Check if is non uniform within a certain amount of decimal places to account for this
  60879. * @param epsilon the amount the values can differ
  60880. * @returns if the the vector is non uniform to a certain number of decimal places
  60881. */
  60882. isNonUniformWithinEpsilon(epsilon: number): boolean;
  60883. /**
  60884. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  60885. */
  60886. readonly isNonUniform: boolean;
  60887. /**
  60888. * Gets a new Vector3 from current Vector3 floored values
  60889. * @returns a new Vector3
  60890. */
  60891. floor(): Vector3;
  60892. /**
  60893. * Gets a new Vector3 from current Vector3 floored values
  60894. * @returns a new Vector3
  60895. */
  60896. fract(): Vector3;
  60897. /**
  60898. * Gets the length of the Vector3
  60899. * @returns the length of the Vecto3
  60900. */
  60901. length(): number;
  60902. /**
  60903. * Gets the squared length of the Vector3
  60904. * @returns squared length of the Vector3
  60905. */
  60906. lengthSquared(): number;
  60907. /**
  60908. * Normalize the current Vector3.
  60909. * Please note that this is an in place operation.
  60910. * @returns the current updated Vector3
  60911. */
  60912. normalize(): Vector3;
  60913. /**
  60914. * Reorders the x y z properties of the vector in place
  60915. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60916. * @returns the current updated vector
  60917. */
  60918. reorderInPlace(order: string): this;
  60919. /**
  60920. * Rotates the vector around 0,0,0 by a quaternion
  60921. * @param quaternion the rotation quaternion
  60922. * @param result vector to store the result
  60923. * @returns the resulting vector
  60924. */
  60925. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60926. /**
  60927. * Rotates a vector around a given point
  60928. * @param quaternion the rotation quaternion
  60929. * @param point the point to rotate around
  60930. * @param result vector to store the result
  60931. * @returns the resulting vector
  60932. */
  60933. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60934. /**
  60935. * Normalize the current Vector3 with the given input length.
  60936. * Please note that this is an in place operation.
  60937. * @param len the length of the vector
  60938. * @returns the current updated Vector3
  60939. */
  60940. normalizeFromLength(len: number): Vector3;
  60941. /**
  60942. * Normalize the current Vector3 to a new vector
  60943. * @returns the new Vector3
  60944. */
  60945. normalizeToNew(): Vector3;
  60946. /**
  60947. * Normalize the current Vector3 to the reference
  60948. * @param reference define the Vector3 to update
  60949. * @returns the updated Vector3
  60950. */
  60951. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60952. /**
  60953. * Creates a new Vector3 copied from the current Vector3
  60954. * @returns the new Vector3
  60955. */
  60956. clone(): Vector3;
  60957. /**
  60958. * Copies the given vector coordinates to the current Vector3 ones
  60959. * @param source defines the source Vector3
  60960. * @returns the current updated Vector3
  60961. */
  60962. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60963. /**
  60964. * Copies the given floats to the current Vector3 coordinates
  60965. * @param x defines the x coordinate of the operand
  60966. * @param y defines the y coordinate of the operand
  60967. * @param z defines the z coordinate of the operand
  60968. * @returns the current updated Vector3
  60969. */
  60970. copyFromFloats(x: number, y: number, z: number): Vector3;
  60971. /**
  60972. * Copies the given floats to the current Vector3 coordinates
  60973. * @param x defines the x coordinate of the operand
  60974. * @param y defines the y coordinate of the operand
  60975. * @param z defines the z coordinate of the operand
  60976. * @returns the current updated Vector3
  60977. */
  60978. set(x: number, y: number, z: number): Vector3;
  60979. /**
  60980. * Copies the given float to the current Vector3 coordinates
  60981. * @param v defines the x, y and z coordinates of the operand
  60982. * @returns the current updated Vector3
  60983. */
  60984. setAll(v: number): Vector3;
  60985. /**
  60986. * Get the clip factor between two vectors
  60987. * @param vector0 defines the first operand
  60988. * @param vector1 defines the second operand
  60989. * @param axis defines the axis to use
  60990. * @param size defines the size along the axis
  60991. * @returns the clip factor
  60992. */
  60993. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60994. /**
  60995. * Get angle between two vectors
  60996. * @param vector0 angle between vector0 and vector1
  60997. * @param vector1 angle between vector0 and vector1
  60998. * @param normal direction of the normal
  60999. * @return the angle between vector0 and vector1
  61000. */
  61001. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61002. /**
  61003. * Returns a new Vector3 set from the index "offset" of the given array
  61004. * @param array defines the source array
  61005. * @param offset defines the offset in the source array
  61006. * @returns the new Vector3
  61007. */
  61008. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61009. /**
  61010. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61011. * This function is deprecated. Use FromArray instead
  61012. * @param array defines the source array
  61013. * @param offset defines the offset in the source array
  61014. * @returns the new Vector3
  61015. */
  61016. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61017. /**
  61018. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61019. * @param array defines the source array
  61020. * @param offset defines the offset in the source array
  61021. * @param result defines the Vector3 where to store the result
  61022. */
  61023. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61024. /**
  61025. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61026. * This function is deprecated. Use FromArrayToRef instead.
  61027. * @param array defines the source array
  61028. * @param offset defines the offset in the source array
  61029. * @param result defines the Vector3 where to store the result
  61030. */
  61031. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61032. /**
  61033. * Sets the given vector "result" with the given floats.
  61034. * @param x defines the x coordinate of the source
  61035. * @param y defines the y coordinate of the source
  61036. * @param z defines the z coordinate of the source
  61037. * @param result defines the Vector3 where to store the result
  61038. */
  61039. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61040. /**
  61041. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61042. * @returns a new empty Vector3
  61043. */
  61044. static Zero(): Vector3;
  61045. /**
  61046. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61047. * @returns a new unit Vector3
  61048. */
  61049. static One(): Vector3;
  61050. /**
  61051. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61052. * @returns a new up Vector3
  61053. */
  61054. static Up(): Vector3;
  61055. /**
  61056. * Gets a up Vector3 that must not be updated
  61057. */
  61058. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61059. /**
  61060. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61061. * @returns a new down Vector3
  61062. */
  61063. static Down(): Vector3;
  61064. /**
  61065. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61066. * @returns a new forward Vector3
  61067. */
  61068. static Forward(): Vector3;
  61069. /**
  61070. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61071. * @returns a new forward Vector3
  61072. */
  61073. static Backward(): Vector3;
  61074. /**
  61075. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61076. * @returns a new right Vector3
  61077. */
  61078. static Right(): Vector3;
  61079. /**
  61080. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61081. * @returns a new left Vector3
  61082. */
  61083. static Left(): Vector3;
  61084. /**
  61085. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61086. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61087. * @param vector defines the Vector3 to transform
  61088. * @param transformation defines the transformation matrix
  61089. * @returns the transformed Vector3
  61090. */
  61091. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61092. /**
  61093. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61094. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61095. * @param vector defines the Vector3 to transform
  61096. * @param transformation defines the transformation matrix
  61097. * @param result defines the Vector3 where to store the result
  61098. */
  61099. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61100. /**
  61101. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61102. * This method computes tranformed coordinates only, not transformed direction vectors
  61103. * @param x define the x coordinate of the source vector
  61104. * @param y define the y coordinate of the source vector
  61105. * @param z define the z coordinate of the source vector
  61106. * @param transformation defines the transformation matrix
  61107. * @param result defines the Vector3 where to store the result
  61108. */
  61109. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61110. /**
  61111. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61112. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61113. * @param vector defines the Vector3 to transform
  61114. * @param transformation defines the transformation matrix
  61115. * @returns the new Vector3
  61116. */
  61117. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61118. /**
  61119. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61120. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61121. * @param vector defines the Vector3 to transform
  61122. * @param transformation defines the transformation matrix
  61123. * @param result defines the Vector3 where to store the result
  61124. */
  61125. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61126. /**
  61127. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61128. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61129. * @param x define the x coordinate of the source vector
  61130. * @param y define the y coordinate of the source vector
  61131. * @param z define the z coordinate of the source vector
  61132. * @param transformation defines the transformation matrix
  61133. * @param result defines the Vector3 where to store the result
  61134. */
  61135. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61136. /**
  61137. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61138. * @param value1 defines the first control point
  61139. * @param value2 defines the second control point
  61140. * @param value3 defines the third control point
  61141. * @param value4 defines the fourth control point
  61142. * @param amount defines the amount on the spline to use
  61143. * @returns the new Vector3
  61144. */
  61145. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61146. /**
  61147. * 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"
  61148. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61149. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61150. * @param value defines the current value
  61151. * @param min defines the lower range value
  61152. * @param max defines the upper range value
  61153. * @returns the new Vector3
  61154. */
  61155. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61156. /**
  61157. * 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"
  61158. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61159. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61160. * @param value defines the current value
  61161. * @param min defines the lower range value
  61162. * @param max defines the upper range value
  61163. * @param result defines the Vector3 where to store the result
  61164. */
  61165. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61166. /**
  61167. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61168. * @param value1 defines the first control point
  61169. * @param tangent1 defines the first tangent vector
  61170. * @param value2 defines the second control point
  61171. * @param tangent2 defines the second tangent vector
  61172. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61173. * @returns the new Vector3
  61174. */
  61175. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61176. /**
  61177. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61178. * @param start defines the start value
  61179. * @param end defines the end value
  61180. * @param amount max defines amount between both (between 0 and 1)
  61181. * @returns the new Vector3
  61182. */
  61183. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61184. /**
  61185. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61186. * @param start defines the start value
  61187. * @param end defines the end value
  61188. * @param amount max defines amount between both (between 0 and 1)
  61189. * @param result defines the Vector3 where to store the result
  61190. */
  61191. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61192. /**
  61193. * Returns the dot product (float) between the vectors "left" and "right"
  61194. * @param left defines the left operand
  61195. * @param right defines the right operand
  61196. * @returns the dot product
  61197. */
  61198. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61199. /**
  61200. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61201. * The cross product is then orthogonal to both "left" and "right"
  61202. * @param left defines the left operand
  61203. * @param right defines the right operand
  61204. * @returns the cross product
  61205. */
  61206. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61207. /**
  61208. * Sets the given vector "result" with the cross product of "left" and "right"
  61209. * The cross product is then orthogonal to both "left" and "right"
  61210. * @param left defines the left operand
  61211. * @param right defines the right operand
  61212. * @param result defines the Vector3 where to store the result
  61213. */
  61214. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61215. /**
  61216. * Returns a new Vector3 as the normalization of the given vector
  61217. * @param vector defines the Vector3 to normalize
  61218. * @returns the new Vector3
  61219. */
  61220. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61221. /**
  61222. * Sets the given vector "result" with the normalization of the given first vector
  61223. * @param vector defines the Vector3 to normalize
  61224. * @param result defines the Vector3 where to store the result
  61225. */
  61226. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61227. /**
  61228. * Project a Vector3 onto screen space
  61229. * @param vector defines the Vector3 to project
  61230. * @param world defines the world matrix to use
  61231. * @param transform defines the transform (view x projection) matrix to use
  61232. * @param viewport defines the screen viewport to use
  61233. * @returns the new Vector3
  61234. */
  61235. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61236. /** @hidden */
  61237. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61238. /**
  61239. * Unproject from screen space to object space
  61240. * @param source defines the screen space Vector3 to use
  61241. * @param viewportWidth defines the current width of the viewport
  61242. * @param viewportHeight defines the current height of the viewport
  61243. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61244. * @param transform defines the transform (view x projection) matrix to use
  61245. * @returns the new Vector3
  61246. */
  61247. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61248. /**
  61249. * Unproject from screen space to object space
  61250. * @param source defines the screen space Vector3 to use
  61251. * @param viewportWidth defines the current width of the viewport
  61252. * @param viewportHeight defines the current height of the viewport
  61253. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61254. * @param view defines the view matrix to use
  61255. * @param projection defines the projection matrix to use
  61256. * @returns the new Vector3
  61257. */
  61258. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61259. /**
  61260. * Unproject from screen space to object space
  61261. * @param source defines the screen space Vector3 to use
  61262. * @param viewportWidth defines the current width of the viewport
  61263. * @param viewportHeight defines the current height of the viewport
  61264. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61265. * @param view defines the view matrix to use
  61266. * @param projection defines the projection matrix to use
  61267. * @param result defines the Vector3 where to store the result
  61268. */
  61269. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61270. /**
  61271. * Unproject from screen space to object space
  61272. * @param sourceX defines the screen space x coordinate to use
  61273. * @param sourceY defines the screen space y coordinate to use
  61274. * @param sourceZ defines the screen space z coordinate to use
  61275. * @param viewportWidth defines the current width of the viewport
  61276. * @param viewportHeight defines the current height of the viewport
  61277. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61278. * @param view defines the view matrix to use
  61279. * @param projection defines the projection matrix to use
  61280. * @param result defines the Vector3 where to store the result
  61281. */
  61282. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61283. /**
  61284. * Gets the minimal coordinate values between two Vector3
  61285. * @param left defines the first operand
  61286. * @param right defines the second operand
  61287. * @returns the new Vector3
  61288. */
  61289. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61290. /**
  61291. * Gets the maximal coordinate values between two Vector3
  61292. * @param left defines the first operand
  61293. * @param right defines the second operand
  61294. * @returns the new Vector3
  61295. */
  61296. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61297. /**
  61298. * Returns the distance between the vectors "value1" and "value2"
  61299. * @param value1 defines the first operand
  61300. * @param value2 defines the second operand
  61301. * @returns the distance
  61302. */
  61303. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61304. /**
  61305. * Returns the squared distance between the vectors "value1" and "value2"
  61306. * @param value1 defines the first operand
  61307. * @param value2 defines the second operand
  61308. * @returns the squared distance
  61309. */
  61310. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61311. /**
  61312. * Returns a new Vector3 located at the center between "value1" and "value2"
  61313. * @param value1 defines the first operand
  61314. * @param value2 defines the second operand
  61315. * @returns the new Vector3
  61316. */
  61317. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61318. /**
  61319. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61320. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61321. * to something in order to rotate it from its local system to the given target system
  61322. * Note: axis1, axis2 and axis3 are normalized during this operation
  61323. * @param axis1 defines the first axis
  61324. * @param axis2 defines the second axis
  61325. * @param axis3 defines the third axis
  61326. * @returns a new Vector3
  61327. */
  61328. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61329. /**
  61330. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61331. * @param axis1 defines the first axis
  61332. * @param axis2 defines the second axis
  61333. * @param axis3 defines the third axis
  61334. * @param ref defines the Vector3 where to store the result
  61335. */
  61336. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61337. }
  61338. /**
  61339. * Vector4 class created for EulerAngle class conversion to Quaternion
  61340. */
  61341. export class Vector4 {
  61342. /** x value of the vector */
  61343. x: number;
  61344. /** y value of the vector */
  61345. y: number;
  61346. /** z value of the vector */
  61347. z: number;
  61348. /** w value of the vector */
  61349. w: number;
  61350. /**
  61351. * Creates a Vector4 object from the given floats.
  61352. * @param x x value of the vector
  61353. * @param y y value of the vector
  61354. * @param z z value of the vector
  61355. * @param w w value of the vector
  61356. */
  61357. constructor(
  61358. /** x value of the vector */
  61359. x: number,
  61360. /** y value of the vector */
  61361. y: number,
  61362. /** z value of the vector */
  61363. z: number,
  61364. /** w value of the vector */
  61365. w: number);
  61366. /**
  61367. * Returns the string with the Vector4 coordinates.
  61368. * @returns a string containing all the vector values
  61369. */
  61370. toString(): string;
  61371. /**
  61372. * Returns the string "Vector4".
  61373. * @returns "Vector4"
  61374. */
  61375. getClassName(): string;
  61376. /**
  61377. * Returns the Vector4 hash code.
  61378. * @returns a unique hash code
  61379. */
  61380. getHashCode(): number;
  61381. /**
  61382. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61383. * @returns the resulting array
  61384. */
  61385. asArray(): number[];
  61386. /**
  61387. * Populates the given array from the given index with the Vector4 coordinates.
  61388. * @param array array to populate
  61389. * @param index index of the array to start at (default: 0)
  61390. * @returns the Vector4.
  61391. */
  61392. toArray(array: FloatArray, index?: number): Vector4;
  61393. /**
  61394. * Adds the given vector to the current Vector4.
  61395. * @param otherVector the vector to add
  61396. * @returns the updated Vector4.
  61397. */
  61398. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61399. /**
  61400. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61401. * @param otherVector the vector to add
  61402. * @returns the resulting vector
  61403. */
  61404. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61405. /**
  61406. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61407. * @param otherVector the vector to add
  61408. * @param result the vector to store the result
  61409. * @returns the current Vector4.
  61410. */
  61411. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61412. /**
  61413. * Subtract in place the given vector from the current Vector4.
  61414. * @param otherVector the vector to subtract
  61415. * @returns the updated Vector4.
  61416. */
  61417. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61418. /**
  61419. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61420. * @param otherVector the vector to add
  61421. * @returns the new vector with the result
  61422. */
  61423. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61424. /**
  61425. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61426. * @param otherVector the vector to subtract
  61427. * @param result the vector to store the result
  61428. * @returns the current Vector4.
  61429. */
  61430. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61431. /**
  61432. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61433. */
  61434. /**
  61435. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61436. * @param x value to subtract
  61437. * @param y value to subtract
  61438. * @param z value to subtract
  61439. * @param w value to subtract
  61440. * @returns new vector containing the result
  61441. */
  61442. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61443. /**
  61444. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61445. * @param x value to subtract
  61446. * @param y value to subtract
  61447. * @param z value to subtract
  61448. * @param w value to subtract
  61449. * @param result the vector to store the result in
  61450. * @returns the current Vector4.
  61451. */
  61452. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61453. /**
  61454. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61455. * @returns a new vector with the negated values
  61456. */
  61457. negate(): Vector4;
  61458. /**
  61459. * Multiplies the current Vector4 coordinates by scale (float).
  61460. * @param scale the number to scale with
  61461. * @returns the updated Vector4.
  61462. */
  61463. scaleInPlace(scale: number): Vector4;
  61464. /**
  61465. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61466. * @param scale the number to scale with
  61467. * @returns a new vector with the result
  61468. */
  61469. scale(scale: number): Vector4;
  61470. /**
  61471. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61472. * @param scale the number to scale with
  61473. * @param result a vector to store the result in
  61474. * @returns the current Vector4.
  61475. */
  61476. scaleToRef(scale: number, result: Vector4): Vector4;
  61477. /**
  61478. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61479. * @param scale defines the scale factor
  61480. * @param result defines the Vector4 object where to store the result
  61481. * @returns the unmodified current Vector4
  61482. */
  61483. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61484. /**
  61485. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61486. * @param otherVector the vector to compare against
  61487. * @returns true if they are equal
  61488. */
  61489. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61490. /**
  61491. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61492. * @param otherVector vector to compare against
  61493. * @param epsilon (Default: very small number)
  61494. * @returns true if they are equal
  61495. */
  61496. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61497. /**
  61498. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61499. * @param x x value to compare against
  61500. * @param y y value to compare against
  61501. * @param z z value to compare against
  61502. * @param w w value to compare against
  61503. * @returns true if equal
  61504. */
  61505. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61506. /**
  61507. * Multiplies in place the current Vector4 by the given one.
  61508. * @param otherVector vector to multiple with
  61509. * @returns the updated Vector4.
  61510. */
  61511. multiplyInPlace(otherVector: Vector4): Vector4;
  61512. /**
  61513. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61514. * @param otherVector vector to multiple with
  61515. * @returns resulting new vector
  61516. */
  61517. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61518. /**
  61519. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61520. * @param otherVector vector to multiple with
  61521. * @param result vector to store the result
  61522. * @returns the current Vector4.
  61523. */
  61524. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61525. /**
  61526. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61527. * @param x x value multiply with
  61528. * @param y y value multiply with
  61529. * @param z z value multiply with
  61530. * @param w w value multiply with
  61531. * @returns resulting new vector
  61532. */
  61533. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61534. /**
  61535. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61536. * @param otherVector vector to devide with
  61537. * @returns resulting new vector
  61538. */
  61539. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61540. /**
  61541. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61542. * @param otherVector vector to devide with
  61543. * @param result vector to store the result
  61544. * @returns the current Vector4.
  61545. */
  61546. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61547. /**
  61548. * Divides the current Vector3 coordinates by the given ones.
  61549. * @param otherVector vector to devide with
  61550. * @returns the updated Vector3.
  61551. */
  61552. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61553. /**
  61554. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61555. * @param other defines the second operand
  61556. * @returns the current updated Vector4
  61557. */
  61558. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61559. /**
  61560. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61561. * @param other defines the second operand
  61562. * @returns the current updated Vector4
  61563. */
  61564. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61565. /**
  61566. * Gets a new Vector4 from current Vector4 floored values
  61567. * @returns a new Vector4
  61568. */
  61569. floor(): Vector4;
  61570. /**
  61571. * Gets a new Vector4 from current Vector3 floored values
  61572. * @returns a new Vector4
  61573. */
  61574. fract(): Vector4;
  61575. /**
  61576. * Returns the Vector4 length (float).
  61577. * @returns the length
  61578. */
  61579. length(): number;
  61580. /**
  61581. * Returns the Vector4 squared length (float).
  61582. * @returns the length squared
  61583. */
  61584. lengthSquared(): number;
  61585. /**
  61586. * Normalizes in place the Vector4.
  61587. * @returns the updated Vector4.
  61588. */
  61589. normalize(): Vector4;
  61590. /**
  61591. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61592. * @returns this converted to a new vector3
  61593. */
  61594. toVector3(): Vector3;
  61595. /**
  61596. * Returns a new Vector4 copied from the current one.
  61597. * @returns the new cloned vector
  61598. */
  61599. clone(): Vector4;
  61600. /**
  61601. * Updates the current Vector4 with the given one coordinates.
  61602. * @param source the source vector to copy from
  61603. * @returns the updated Vector4.
  61604. */
  61605. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61606. /**
  61607. * Updates the current Vector4 coordinates with the given floats.
  61608. * @param x float to copy from
  61609. * @param y float to copy from
  61610. * @param z float to copy from
  61611. * @param w float to copy from
  61612. * @returns the updated Vector4.
  61613. */
  61614. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61615. /**
  61616. * Updates the current Vector4 coordinates with the given floats.
  61617. * @param x float to set from
  61618. * @param y float to set from
  61619. * @param z float to set from
  61620. * @param w float to set from
  61621. * @returns the updated Vector4.
  61622. */
  61623. set(x: number, y: number, z: number, w: number): Vector4;
  61624. /**
  61625. * Copies the given float to the current Vector3 coordinates
  61626. * @param v defines the x, y, z and w coordinates of the operand
  61627. * @returns the current updated Vector3
  61628. */
  61629. setAll(v: number): Vector4;
  61630. /**
  61631. * Returns a new Vector4 set from the starting index of the given array.
  61632. * @param array the array to pull values from
  61633. * @param offset the offset into the array to start at
  61634. * @returns the new vector
  61635. */
  61636. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61637. /**
  61638. * Updates the given vector "result" from the starting index of the given array.
  61639. * @param array the array to pull values from
  61640. * @param offset the offset into the array to start at
  61641. * @param result the vector to store the result in
  61642. */
  61643. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61644. /**
  61645. * Updates the given vector "result" from the starting index of the given Float32Array.
  61646. * @param array the array to pull values from
  61647. * @param offset the offset into the array to start at
  61648. * @param result the vector to store the result in
  61649. */
  61650. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61651. /**
  61652. * Updates the given vector "result" coordinates from the given floats.
  61653. * @param x float to set from
  61654. * @param y float to set from
  61655. * @param z float to set from
  61656. * @param w float to set from
  61657. * @param result the vector to the floats in
  61658. */
  61659. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61660. /**
  61661. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61662. * @returns the new vector
  61663. */
  61664. static Zero(): Vector4;
  61665. /**
  61666. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61667. * @returns the new vector
  61668. */
  61669. static One(): Vector4;
  61670. /**
  61671. * Returns a new normalized Vector4 from the given one.
  61672. * @param vector the vector to normalize
  61673. * @returns the vector
  61674. */
  61675. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61676. /**
  61677. * Updates the given vector "result" from the normalization of the given one.
  61678. * @param vector the vector to normalize
  61679. * @param result the vector to store the result in
  61680. */
  61681. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61682. /**
  61683. * Returns a vector with the minimum values from the left and right vectors
  61684. * @param left left vector to minimize
  61685. * @param right right vector to minimize
  61686. * @returns a new vector with the minimum of the left and right vector values
  61687. */
  61688. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61689. /**
  61690. * Returns a vector with the maximum values from the left and right vectors
  61691. * @param left left vector to maximize
  61692. * @param right right vector to maximize
  61693. * @returns a new vector with the maximum of the left and right vector values
  61694. */
  61695. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61696. /**
  61697. * Returns the distance (float) between the vectors "value1" and "value2".
  61698. * @param value1 value to calulate the distance between
  61699. * @param value2 value to calulate the distance between
  61700. * @return the distance between the two vectors
  61701. */
  61702. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61703. /**
  61704. * Returns the squared distance (float) between the vectors "value1" and "value2".
  61705. * @param value1 value to calulate the distance between
  61706. * @param value2 value to calulate the distance between
  61707. * @return the distance between the two vectors squared
  61708. */
  61709. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61710. /**
  61711. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  61712. * @param value1 value to calulate the center between
  61713. * @param value2 value to calulate the center between
  61714. * @return the center between the two vectors
  61715. */
  61716. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  61717. /**
  61718. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  61719. * This methods computes transformed normalized direction vectors only.
  61720. * @param vector the vector to transform
  61721. * @param transformation the transformation matrix to apply
  61722. * @returns the new vector
  61723. */
  61724. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  61725. /**
  61726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  61727. * This methods computes transformed normalized direction vectors only.
  61728. * @param vector the vector to transform
  61729. * @param transformation the transformation matrix to apply
  61730. * @param result the vector to store the result in
  61731. */
  61732. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61733. /**
  61734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  61735. * This methods computes transformed normalized direction vectors only.
  61736. * @param x value to transform
  61737. * @param y value to transform
  61738. * @param z value to transform
  61739. * @param w value to transform
  61740. * @param transformation the transformation matrix to apply
  61741. * @param result the vector to store the results in
  61742. */
  61743. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61744. /**
  61745. * Creates a new Vector4 from a Vector3
  61746. * @param source defines the source data
  61747. * @param w defines the 4th component (default is 0)
  61748. * @returns a new Vector4
  61749. */
  61750. static FromVector3(source: Vector3, w?: number): Vector4;
  61751. }
  61752. /**
  61753. * Interface for the size containing width and height
  61754. */
  61755. export interface ISize {
  61756. /**
  61757. * Width
  61758. */
  61759. width: number;
  61760. /**
  61761. * Heighht
  61762. */
  61763. height: number;
  61764. }
  61765. /**
  61766. * Size containing widht and height
  61767. */
  61768. export class Size implements ISize {
  61769. /**
  61770. * Width
  61771. */
  61772. width: number;
  61773. /**
  61774. * Height
  61775. */
  61776. height: number;
  61777. /**
  61778. * Creates a Size object from the given width and height (floats).
  61779. * @param width width of the new size
  61780. * @param height height of the new size
  61781. */
  61782. constructor(width: number, height: number);
  61783. /**
  61784. * Returns a string with the Size width and height
  61785. * @returns a string with the Size width and height
  61786. */
  61787. toString(): string;
  61788. /**
  61789. * "Size"
  61790. * @returns the string "Size"
  61791. */
  61792. getClassName(): string;
  61793. /**
  61794. * Returns the Size hash code.
  61795. * @returns a hash code for a unique width and height
  61796. */
  61797. getHashCode(): number;
  61798. /**
  61799. * Updates the current size from the given one.
  61800. * @param src the given size
  61801. */
  61802. copyFrom(src: Size): void;
  61803. /**
  61804. * Updates in place the current Size from the given floats.
  61805. * @param width width of the new size
  61806. * @param height height of the new size
  61807. * @returns the updated Size.
  61808. */
  61809. copyFromFloats(width: number, height: number): Size;
  61810. /**
  61811. * Updates in place the current Size from the given floats.
  61812. * @param width width to set
  61813. * @param height height to set
  61814. * @returns the updated Size.
  61815. */
  61816. set(width: number, height: number): Size;
  61817. /**
  61818. * Multiplies the width and height by numbers
  61819. * @param w factor to multiple the width by
  61820. * @param h factor to multiple the height by
  61821. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61822. */
  61823. multiplyByFloats(w: number, h: number): Size;
  61824. /**
  61825. * Clones the size
  61826. * @returns a new Size copied from the given one.
  61827. */
  61828. clone(): Size;
  61829. /**
  61830. * True if the current Size and the given one width and height are strictly equal.
  61831. * @param other the other size to compare against
  61832. * @returns True if the current Size and the given one width and height are strictly equal.
  61833. */
  61834. equals(other: Size): boolean;
  61835. /**
  61836. * The surface of the Size : width * height (float).
  61837. */
  61838. readonly surface: number;
  61839. /**
  61840. * Create a new size of zero
  61841. * @returns a new Size set to (0.0, 0.0)
  61842. */
  61843. static Zero(): Size;
  61844. /**
  61845. * Sums the width and height of two sizes
  61846. * @param otherSize size to add to this size
  61847. * @returns a new Size set as the addition result of the current Size and the given one.
  61848. */
  61849. add(otherSize: Size): Size;
  61850. /**
  61851. * Subtracts the width and height of two
  61852. * @param otherSize size to subtract to this size
  61853. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61854. */
  61855. subtract(otherSize: Size): Size;
  61856. /**
  61857. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  61858. * @param start starting size to lerp between
  61859. * @param end end size to lerp between
  61860. * @param amount amount to lerp between the start and end values
  61861. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  61862. */
  61863. static Lerp(start: Size, end: Size, amount: number): Size;
  61864. }
  61865. /**
  61866. * Class used to store quaternion data
  61867. * @see https://en.wikipedia.org/wiki/Quaternion
  61868. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  61869. */
  61870. export class Quaternion {
  61871. /** defines the first component (0 by default) */
  61872. x: number;
  61873. /** defines the second component (0 by default) */
  61874. y: number;
  61875. /** defines the third component (0 by default) */
  61876. z: number;
  61877. /** defines the fourth component (1.0 by default) */
  61878. w: number;
  61879. /**
  61880. * Creates a new Quaternion from the given floats
  61881. * @param x defines the first component (0 by default)
  61882. * @param y defines the second component (0 by default)
  61883. * @param z defines the third component (0 by default)
  61884. * @param w defines the fourth component (1.0 by default)
  61885. */
  61886. constructor(
  61887. /** defines the first component (0 by default) */
  61888. x?: number,
  61889. /** defines the second component (0 by default) */
  61890. y?: number,
  61891. /** defines the third component (0 by default) */
  61892. z?: number,
  61893. /** defines the fourth component (1.0 by default) */
  61894. w?: number);
  61895. /**
  61896. * Gets a string representation for the current quaternion
  61897. * @returns a string with the Quaternion coordinates
  61898. */
  61899. toString(): string;
  61900. /**
  61901. * Gets the class name of the quaternion
  61902. * @returns the string "Quaternion"
  61903. */
  61904. getClassName(): string;
  61905. /**
  61906. * Gets a hash code for this quaternion
  61907. * @returns the quaternion hash code
  61908. */
  61909. getHashCode(): number;
  61910. /**
  61911. * Copy the quaternion to an array
  61912. * @returns a new array populated with 4 elements from the quaternion coordinates
  61913. */
  61914. asArray(): number[];
  61915. /**
  61916. * Check if two quaternions are equals
  61917. * @param otherQuaternion defines the second operand
  61918. * @return true if the current quaternion and the given one coordinates are strictly equals
  61919. */
  61920. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61921. /**
  61922. * Clone the current quaternion
  61923. * @returns a new quaternion copied from the current one
  61924. */
  61925. clone(): Quaternion;
  61926. /**
  61927. * Copy a quaternion to the current one
  61928. * @param other defines the other quaternion
  61929. * @returns the updated current quaternion
  61930. */
  61931. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61932. /**
  61933. * Updates the current quaternion with the given float coordinates
  61934. * @param x defines the x coordinate
  61935. * @param y defines the y coordinate
  61936. * @param z defines the z coordinate
  61937. * @param w defines the w coordinate
  61938. * @returns the updated current quaternion
  61939. */
  61940. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61941. /**
  61942. * Updates the current quaternion from the given float coordinates
  61943. * @param x defines the x coordinate
  61944. * @param y defines the y coordinate
  61945. * @param z defines the z coordinate
  61946. * @param w defines the w coordinate
  61947. * @returns the updated current quaternion
  61948. */
  61949. set(x: number, y: number, z: number, w: number): Quaternion;
  61950. /**
  61951. * Adds two quaternions
  61952. * @param other defines the second operand
  61953. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61954. */
  61955. add(other: DeepImmutable<Quaternion>): Quaternion;
  61956. /**
  61957. * Add a quaternion to the current one
  61958. * @param other defines the quaternion to add
  61959. * @returns the current quaternion
  61960. */
  61961. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61962. /**
  61963. * Subtract two quaternions
  61964. * @param other defines the second operand
  61965. * @returns a new quaternion as the subtraction result of the given one from the current one
  61966. */
  61967. subtract(other: Quaternion): Quaternion;
  61968. /**
  61969. * Multiplies the current quaternion by a scale factor
  61970. * @param value defines the scale factor
  61971. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61972. */
  61973. scale(value: number): Quaternion;
  61974. /**
  61975. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61976. * @param scale defines the scale factor
  61977. * @param result defines the Quaternion object where to store the result
  61978. * @returns the unmodified current quaternion
  61979. */
  61980. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61981. /**
  61982. * Multiplies in place the current quaternion by a scale factor
  61983. * @param value defines the scale factor
  61984. * @returns the current modified quaternion
  61985. */
  61986. scaleInPlace(value: number): Quaternion;
  61987. /**
  61988. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61989. * @param scale defines the scale factor
  61990. * @param result defines the Quaternion object where to store the result
  61991. * @returns the unmodified current quaternion
  61992. */
  61993. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61994. /**
  61995. * Multiplies two quaternions
  61996. * @param q1 defines the second operand
  61997. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61998. */
  61999. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62000. /**
  62001. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62002. * @param q1 defines the second operand
  62003. * @param result defines the target quaternion
  62004. * @returns the current quaternion
  62005. */
  62006. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62007. /**
  62008. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62009. * @param q1 defines the second operand
  62010. * @returns the currentupdated quaternion
  62011. */
  62012. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62013. /**
  62014. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62015. * @param ref defines the target quaternion
  62016. * @returns the current quaternion
  62017. */
  62018. conjugateToRef(ref: Quaternion): Quaternion;
  62019. /**
  62020. * Conjugates in place (1-q) the current quaternion
  62021. * @returns the current updated quaternion
  62022. */
  62023. conjugateInPlace(): Quaternion;
  62024. /**
  62025. * Conjugates in place (1-q) the current quaternion
  62026. * @returns a new quaternion
  62027. */
  62028. conjugate(): Quaternion;
  62029. /**
  62030. * Gets length of current quaternion
  62031. * @returns the quaternion length (float)
  62032. */
  62033. length(): number;
  62034. /**
  62035. * Normalize in place the current quaternion
  62036. * @returns the current updated quaternion
  62037. */
  62038. normalize(): Quaternion;
  62039. /**
  62040. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62041. * @param order is a reserved parameter and is ignore for now
  62042. * @returns a new Vector3 containing the Euler angles
  62043. */
  62044. toEulerAngles(order?: string): Vector3;
  62045. /**
  62046. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62047. * @param result defines the vector which will be filled with the Euler angles
  62048. * @param order is a reserved parameter and is ignore for now
  62049. * @returns the current unchanged quaternion
  62050. */
  62051. toEulerAnglesToRef(result: Vector3): Quaternion;
  62052. /**
  62053. * Updates the given rotation matrix with the current quaternion values
  62054. * @param result defines the target matrix
  62055. * @returns the current unchanged quaternion
  62056. */
  62057. toRotationMatrix(result: Matrix): Quaternion;
  62058. /**
  62059. * Updates the current quaternion from the given rotation matrix values
  62060. * @param matrix defines the source matrix
  62061. * @returns the current updated quaternion
  62062. */
  62063. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62064. /**
  62065. * Creates a new quaternion from a rotation matrix
  62066. * @param matrix defines the source matrix
  62067. * @returns a new quaternion created from the given rotation matrix values
  62068. */
  62069. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62070. /**
  62071. * Updates the given quaternion with the given rotation matrix values
  62072. * @param matrix defines the source matrix
  62073. * @param result defines the target quaternion
  62074. */
  62075. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62076. /**
  62077. * Returns the dot product (float) between the quaternions "left" and "right"
  62078. * @param left defines the left operand
  62079. * @param right defines the right operand
  62080. * @returns the dot product
  62081. */
  62082. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62083. /**
  62084. * Checks if the two quaternions are close to each other
  62085. * @param quat0 defines the first quaternion to check
  62086. * @param quat1 defines the second quaternion to check
  62087. * @returns true if the two quaternions are close to each other
  62088. */
  62089. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62090. /**
  62091. * Creates an empty quaternion
  62092. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62093. */
  62094. static Zero(): Quaternion;
  62095. /**
  62096. * Inverse a given quaternion
  62097. * @param q defines the source quaternion
  62098. * @returns a new quaternion as the inverted current quaternion
  62099. */
  62100. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62101. /**
  62102. * Inverse a given quaternion
  62103. * @param q defines the source quaternion
  62104. * @param result the quaternion the result will be stored in
  62105. * @returns the result quaternion
  62106. */
  62107. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62108. /**
  62109. * Creates an identity quaternion
  62110. * @returns the identity quaternion
  62111. */
  62112. static Identity(): Quaternion;
  62113. /**
  62114. * Gets a boolean indicating if the given quaternion is identity
  62115. * @param quaternion defines the quaternion to check
  62116. * @returns true if the quaternion is identity
  62117. */
  62118. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62119. /**
  62120. * Creates a quaternion from a rotation around an axis
  62121. * @param axis defines the axis to use
  62122. * @param angle defines the angle to use
  62123. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62124. */
  62125. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62126. /**
  62127. * Creates a rotation around an axis and stores it into the given quaternion
  62128. * @param axis defines the axis to use
  62129. * @param angle defines the angle to use
  62130. * @param result defines the target quaternion
  62131. * @returns the target quaternion
  62132. */
  62133. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62134. /**
  62135. * Creates a new quaternion from data stored into an array
  62136. * @param array defines the data source
  62137. * @param offset defines the offset in the source array where the data starts
  62138. * @returns a new quaternion
  62139. */
  62140. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62141. /**
  62142. * Create a quaternion from Euler rotation angles
  62143. * @param x Pitch
  62144. * @param y Yaw
  62145. * @param z Roll
  62146. * @returns the new Quaternion
  62147. */
  62148. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62149. /**
  62150. * Updates a quaternion from Euler rotation angles
  62151. * @param x Pitch
  62152. * @param y Yaw
  62153. * @param z Roll
  62154. * @param result the quaternion to store the result
  62155. * @returns the updated quaternion
  62156. */
  62157. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62158. /**
  62159. * Create a quaternion from Euler rotation vector
  62160. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62161. * @returns the new Quaternion
  62162. */
  62163. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62164. /**
  62165. * Updates a quaternion from Euler rotation vector
  62166. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62167. * @param result the quaternion to store the result
  62168. * @returns the updated quaternion
  62169. */
  62170. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62171. /**
  62172. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62173. * @param yaw defines the rotation around Y axis
  62174. * @param pitch defines the rotation around X axis
  62175. * @param roll defines the rotation around Z axis
  62176. * @returns the new quaternion
  62177. */
  62178. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62179. /**
  62180. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62181. * @param yaw defines the rotation around Y axis
  62182. * @param pitch defines the rotation around X axis
  62183. * @param roll defines the rotation around Z axis
  62184. * @param result defines the target quaternion
  62185. */
  62186. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62187. /**
  62188. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62189. * @param alpha defines the rotation around first axis
  62190. * @param beta defines the rotation around second axis
  62191. * @param gamma defines the rotation around third axis
  62192. * @returns the new quaternion
  62193. */
  62194. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62195. /**
  62196. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62197. * @param alpha defines the rotation around first axis
  62198. * @param beta defines the rotation around second axis
  62199. * @param gamma defines the rotation around third axis
  62200. * @param result defines the target quaternion
  62201. */
  62202. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62203. /**
  62204. * 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)
  62205. * @param axis1 defines the first axis
  62206. * @param axis2 defines the second axis
  62207. * @param axis3 defines the third axis
  62208. * @returns the new quaternion
  62209. */
  62210. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62211. /**
  62212. * 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
  62213. * @param axis1 defines the first axis
  62214. * @param axis2 defines the second axis
  62215. * @param axis3 defines the third axis
  62216. * @param ref defines the target quaternion
  62217. */
  62218. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62219. /**
  62220. * Interpolates between two quaternions
  62221. * @param left defines first quaternion
  62222. * @param right defines second quaternion
  62223. * @param amount defines the gradient to use
  62224. * @returns the new interpolated quaternion
  62225. */
  62226. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62227. /**
  62228. * Interpolates between two quaternions and stores it into a target quaternion
  62229. * @param left defines first quaternion
  62230. * @param right defines second quaternion
  62231. * @param amount defines the gradient to use
  62232. * @param result defines the target quaternion
  62233. */
  62234. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62235. /**
  62236. * Interpolate between two quaternions using Hermite interpolation
  62237. * @param value1 defines first quaternion
  62238. * @param tangent1 defines the incoming tangent
  62239. * @param value2 defines second quaternion
  62240. * @param tangent2 defines the outgoing tangent
  62241. * @param amount defines the target quaternion
  62242. * @returns the new interpolated quaternion
  62243. */
  62244. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62245. }
  62246. /**
  62247. * Class used to store matrix data (4x4)
  62248. */
  62249. export class Matrix {
  62250. private static _updateFlagSeed;
  62251. private static _identityReadOnly;
  62252. private _isIdentity;
  62253. private _isIdentityDirty;
  62254. private _isIdentity3x2;
  62255. private _isIdentity3x2Dirty;
  62256. /**
  62257. * Gets the update flag of the matrix which is an unique number for the matrix.
  62258. * It will be incremented every time the matrix data change.
  62259. * You can use it to speed the comparison between two versions of the same matrix.
  62260. */
  62261. updateFlag: number;
  62262. private readonly _m;
  62263. /**
  62264. * Gets the internal data of the matrix
  62265. */
  62266. readonly m: DeepImmutable<Float32Array>;
  62267. /** @hidden */
  62268. _markAsUpdated(): void;
  62269. /** @hidden */
  62270. private _updateIdentityStatus;
  62271. /**
  62272. * Creates an empty matrix (filled with zeros)
  62273. */
  62274. constructor();
  62275. /**
  62276. * Check if the current matrix is identity
  62277. * @returns true is the matrix is the identity matrix
  62278. */
  62279. isIdentity(): boolean;
  62280. /**
  62281. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62282. * @returns true is the matrix is the identity matrix
  62283. */
  62284. isIdentityAs3x2(): boolean;
  62285. /**
  62286. * Gets the determinant of the matrix
  62287. * @returns the matrix determinant
  62288. */
  62289. determinant(): number;
  62290. /**
  62291. * Returns the matrix as a Float32Array
  62292. * @returns the matrix underlying array
  62293. */
  62294. toArray(): DeepImmutable<Float32Array>;
  62295. /**
  62296. * Returns the matrix as a Float32Array
  62297. * @returns the matrix underlying array.
  62298. */
  62299. asArray(): DeepImmutable<Float32Array>;
  62300. /**
  62301. * Inverts the current matrix in place
  62302. * @returns the current inverted matrix
  62303. */
  62304. invert(): Matrix;
  62305. /**
  62306. * Sets all the matrix elements to zero
  62307. * @returns the current matrix
  62308. */
  62309. reset(): Matrix;
  62310. /**
  62311. * Adds the current matrix with a second one
  62312. * @param other defines the matrix to add
  62313. * @returns a new matrix as the addition of the current matrix and the given one
  62314. */
  62315. add(other: DeepImmutable<Matrix>): Matrix;
  62316. /**
  62317. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62318. * @param other defines the matrix to add
  62319. * @param result defines the target matrix
  62320. * @returns the current matrix
  62321. */
  62322. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62323. /**
  62324. * Adds in place the given matrix to the current matrix
  62325. * @param other defines the second operand
  62326. * @returns the current updated matrix
  62327. */
  62328. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62329. /**
  62330. * Sets the given matrix to the current inverted Matrix
  62331. * @param other defines the target matrix
  62332. * @returns the unmodified current matrix
  62333. */
  62334. invertToRef(other: Matrix): Matrix;
  62335. /**
  62336. * add a value at the specified position in the current Matrix
  62337. * @param index the index of the value within the matrix. between 0 and 15.
  62338. * @param value the value to be added
  62339. * @returns the current updated matrix
  62340. */
  62341. addAtIndex(index: number, value: number): Matrix;
  62342. /**
  62343. * mutiply the specified position in the current Matrix by a value
  62344. * @param index the index of the value within the matrix. between 0 and 15.
  62345. * @param value the value to be added
  62346. * @returns the current updated matrix
  62347. */
  62348. multiplyAtIndex(index: number, value: number): Matrix;
  62349. /**
  62350. * Inserts the translation vector (using 3 floats) in the current matrix
  62351. * @param x defines the 1st component of the translation
  62352. * @param y defines the 2nd component of the translation
  62353. * @param z defines the 3rd component of the translation
  62354. * @returns the current updated matrix
  62355. */
  62356. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62357. /**
  62358. * Adds the translation vector (using 3 floats) in the current matrix
  62359. * @param x defines the 1st component of the translation
  62360. * @param y defines the 2nd component of the translation
  62361. * @param z defines the 3rd component of the translation
  62362. * @returns the current updated matrix
  62363. */
  62364. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62365. /**
  62366. * Inserts the translation vector in the current matrix
  62367. * @param vector3 defines the translation to insert
  62368. * @returns the current updated matrix
  62369. */
  62370. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62371. /**
  62372. * Gets the translation value of the current matrix
  62373. * @returns a new Vector3 as the extracted translation from the matrix
  62374. */
  62375. getTranslation(): Vector3;
  62376. /**
  62377. * Fill a Vector3 with the extracted translation from the matrix
  62378. * @param result defines the Vector3 where to store the translation
  62379. * @returns the current matrix
  62380. */
  62381. getTranslationToRef(result: Vector3): Matrix;
  62382. /**
  62383. * Remove rotation and scaling part from the matrix
  62384. * @returns the updated matrix
  62385. */
  62386. removeRotationAndScaling(): Matrix;
  62387. /**
  62388. * Multiply two matrices
  62389. * @param other defines the second operand
  62390. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62391. */
  62392. multiply(other: DeepImmutable<Matrix>): Matrix;
  62393. /**
  62394. * Copy the current matrix from the given one
  62395. * @param other defines the source matrix
  62396. * @returns the current updated matrix
  62397. */
  62398. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62399. /**
  62400. * Populates the given array from the starting index with the current matrix values
  62401. * @param array defines the target array
  62402. * @param offset defines the offset in the target array where to start storing values
  62403. * @returns the current matrix
  62404. */
  62405. copyToArray(array: Float32Array, offset?: number): Matrix;
  62406. /**
  62407. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62408. * @param other defines the second operand
  62409. * @param result defines the matrix where to store the multiplication
  62410. * @returns the current matrix
  62411. */
  62412. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62413. /**
  62414. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62415. * @param other defines the second operand
  62416. * @param result defines the array where to store the multiplication
  62417. * @param offset defines the offset in the target array where to start storing values
  62418. * @returns the current matrix
  62419. */
  62420. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62421. /**
  62422. * Check equality between this matrix and a second one
  62423. * @param value defines the second matrix to compare
  62424. * @returns true is the current matrix and the given one values are strictly equal
  62425. */
  62426. equals(value: DeepImmutable<Matrix>): boolean;
  62427. /**
  62428. * Clone the current matrix
  62429. * @returns a new matrix from the current matrix
  62430. */
  62431. clone(): Matrix;
  62432. /**
  62433. * Returns the name of the current matrix class
  62434. * @returns the string "Matrix"
  62435. */
  62436. getClassName(): string;
  62437. /**
  62438. * Gets the hash code of the current matrix
  62439. * @returns the hash code
  62440. */
  62441. getHashCode(): number;
  62442. /**
  62443. * Decomposes the current Matrix into a translation, rotation and scaling components
  62444. * @param scale defines the scale vector3 given as a reference to update
  62445. * @param rotation defines the rotation quaternion given as a reference to update
  62446. * @param translation defines the translation vector3 given as a reference to update
  62447. * @returns true if operation was successful
  62448. */
  62449. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62450. /**
  62451. * Gets specific row of the matrix
  62452. * @param index defines the number of the row to get
  62453. * @returns the index-th row of the current matrix as a new Vector4
  62454. */
  62455. getRow(index: number): Nullable<Vector4>;
  62456. /**
  62457. * Sets the index-th row of the current matrix to the vector4 values
  62458. * @param index defines the number of the row to set
  62459. * @param row defines the target vector4
  62460. * @returns the updated current matrix
  62461. */
  62462. setRow(index: number, row: Vector4): Matrix;
  62463. /**
  62464. * Compute the transpose of the matrix
  62465. * @returns the new transposed matrix
  62466. */
  62467. transpose(): Matrix;
  62468. /**
  62469. * Compute the transpose of the matrix and store it in a given matrix
  62470. * @param result defines the target matrix
  62471. * @returns the current matrix
  62472. */
  62473. transposeToRef(result: Matrix): Matrix;
  62474. /**
  62475. * Sets the index-th row of the current matrix with the given 4 x float values
  62476. * @param index defines the row index
  62477. * @param x defines the x component to set
  62478. * @param y defines the y component to set
  62479. * @param z defines the z component to set
  62480. * @param w defines the w component to set
  62481. * @returns the updated current matrix
  62482. */
  62483. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62484. /**
  62485. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62486. * @param scale defines the scale factor
  62487. * @returns a new matrix
  62488. */
  62489. scale(scale: number): Matrix;
  62490. /**
  62491. * Scale the current matrix values by a factor to a given result matrix
  62492. * @param scale defines the scale factor
  62493. * @param result defines the matrix to store the result
  62494. * @returns the current matrix
  62495. */
  62496. scaleToRef(scale: number, result: Matrix): Matrix;
  62497. /**
  62498. * Scale the current matrix values by a factor and add the result to a given matrix
  62499. * @param scale defines the scale factor
  62500. * @param result defines the Matrix to store the result
  62501. * @returns the current matrix
  62502. */
  62503. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62504. /**
  62505. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62506. * @param ref matrix to store the result
  62507. */
  62508. toNormalMatrix(ref: Matrix): void;
  62509. /**
  62510. * Gets only rotation part of the current matrix
  62511. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62512. */
  62513. getRotationMatrix(): Matrix;
  62514. /**
  62515. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62516. * @param result defines the target matrix to store data to
  62517. * @returns the current matrix
  62518. */
  62519. getRotationMatrixToRef(result: Matrix): Matrix;
  62520. /**
  62521. * Toggles model matrix from being right handed to left handed in place and vice versa
  62522. */
  62523. toggleModelMatrixHandInPlace(): void;
  62524. /**
  62525. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62526. */
  62527. toggleProjectionMatrixHandInPlace(): void;
  62528. /**
  62529. * Creates a matrix from an array
  62530. * @param array defines the source array
  62531. * @param offset defines an offset in the source array
  62532. * @returns a new Matrix set from the starting index of the given array
  62533. */
  62534. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62535. /**
  62536. * Copy the content of an array into a given matrix
  62537. * @param array defines the source array
  62538. * @param offset defines an offset in the source array
  62539. * @param result defines the target matrix
  62540. */
  62541. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62542. /**
  62543. * Stores an array into a matrix after having multiplied each component by a given factor
  62544. * @param array defines the source array
  62545. * @param offset defines the offset in the source array
  62546. * @param scale defines the scaling factor
  62547. * @param result defines the target matrix
  62548. */
  62549. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62550. /**
  62551. * Gets an identity matrix that must not be updated
  62552. */
  62553. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62554. /**
  62555. * Stores a list of values (16) inside a given matrix
  62556. * @param initialM11 defines 1st value of 1st row
  62557. * @param initialM12 defines 2nd value of 1st row
  62558. * @param initialM13 defines 3rd value of 1st row
  62559. * @param initialM14 defines 4th value of 1st row
  62560. * @param initialM21 defines 1st value of 2nd row
  62561. * @param initialM22 defines 2nd value of 2nd row
  62562. * @param initialM23 defines 3rd value of 2nd row
  62563. * @param initialM24 defines 4th value of 2nd row
  62564. * @param initialM31 defines 1st value of 3rd row
  62565. * @param initialM32 defines 2nd value of 3rd row
  62566. * @param initialM33 defines 3rd value of 3rd row
  62567. * @param initialM34 defines 4th value of 3rd row
  62568. * @param initialM41 defines 1st value of 4th row
  62569. * @param initialM42 defines 2nd value of 4th row
  62570. * @param initialM43 defines 3rd value of 4th row
  62571. * @param initialM44 defines 4th value of 4th row
  62572. * @param result defines the target matrix
  62573. */
  62574. 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;
  62575. /**
  62576. * Creates new matrix from a list of values (16)
  62577. * @param initialM11 defines 1st value of 1st row
  62578. * @param initialM12 defines 2nd value of 1st row
  62579. * @param initialM13 defines 3rd value of 1st row
  62580. * @param initialM14 defines 4th value of 1st row
  62581. * @param initialM21 defines 1st value of 2nd row
  62582. * @param initialM22 defines 2nd value of 2nd row
  62583. * @param initialM23 defines 3rd value of 2nd row
  62584. * @param initialM24 defines 4th value of 2nd row
  62585. * @param initialM31 defines 1st value of 3rd row
  62586. * @param initialM32 defines 2nd value of 3rd row
  62587. * @param initialM33 defines 3rd value of 3rd row
  62588. * @param initialM34 defines 4th value of 3rd row
  62589. * @param initialM41 defines 1st value of 4th row
  62590. * @param initialM42 defines 2nd value of 4th row
  62591. * @param initialM43 defines 3rd value of 4th row
  62592. * @param initialM44 defines 4th value of 4th row
  62593. * @returns the new matrix
  62594. */
  62595. 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;
  62596. /**
  62597. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62598. * @param scale defines the scale vector3
  62599. * @param rotation defines the rotation quaternion
  62600. * @param translation defines the translation vector3
  62601. * @returns a new matrix
  62602. */
  62603. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62604. /**
  62605. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62606. * @param scale defines the scale vector3
  62607. * @param rotation defines the rotation quaternion
  62608. * @param translation defines the translation vector3
  62609. * @param result defines the target matrix
  62610. */
  62611. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62612. /**
  62613. * Creates a new identity matrix
  62614. * @returns a new identity matrix
  62615. */
  62616. static Identity(): Matrix;
  62617. /**
  62618. * Creates a new identity matrix and stores the result in a given matrix
  62619. * @param result defines the target matrix
  62620. */
  62621. static IdentityToRef(result: Matrix): void;
  62622. /**
  62623. * Creates a new zero matrix
  62624. * @returns a new zero matrix
  62625. */
  62626. static Zero(): Matrix;
  62627. /**
  62628. * Creates a new rotation matrix for "angle" radians around the X axis
  62629. * @param angle defines the angle (in radians) to use
  62630. * @return the new matrix
  62631. */
  62632. static RotationX(angle: number): Matrix;
  62633. /**
  62634. * Creates a new matrix as the invert of a given matrix
  62635. * @param source defines the source matrix
  62636. * @returns the new matrix
  62637. */
  62638. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62639. /**
  62640. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62641. * @param angle defines the angle (in radians) to use
  62642. * @param result defines the target matrix
  62643. */
  62644. static RotationXToRef(angle: number, result: Matrix): void;
  62645. /**
  62646. * Creates a new rotation matrix for "angle" radians around the Y axis
  62647. * @param angle defines the angle (in radians) to use
  62648. * @return the new matrix
  62649. */
  62650. static RotationY(angle: number): Matrix;
  62651. /**
  62652. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62653. * @param angle defines the angle (in radians) to use
  62654. * @param result defines the target matrix
  62655. */
  62656. static RotationYToRef(angle: number, result: Matrix): void;
  62657. /**
  62658. * Creates a new rotation matrix for "angle" radians around the Z axis
  62659. * @param angle defines the angle (in radians) to use
  62660. * @return the new matrix
  62661. */
  62662. static RotationZ(angle: number): Matrix;
  62663. /**
  62664. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62665. * @param angle defines the angle (in radians) to use
  62666. * @param result defines the target matrix
  62667. */
  62668. static RotationZToRef(angle: number, result: Matrix): void;
  62669. /**
  62670. * Creates a new rotation matrix for "angle" radians around the given axis
  62671. * @param axis defines the axis to use
  62672. * @param angle defines the angle (in radians) to use
  62673. * @return the new matrix
  62674. */
  62675. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62676. /**
  62677. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62678. * @param axis defines the axis to use
  62679. * @param angle defines the angle (in radians) to use
  62680. * @param result defines the target matrix
  62681. */
  62682. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62683. /**
  62684. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  62685. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  62686. * @param from defines the vector to align
  62687. * @param to defines the vector to align to
  62688. * @param result defines the target matrix
  62689. */
  62690. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  62691. /**
  62692. * Creates a rotation matrix
  62693. * @param yaw defines the yaw angle in radians (Y axis)
  62694. * @param pitch defines the pitch angle in radians (X axis)
  62695. * @param roll defines the roll angle in radians (X axis)
  62696. * @returns the new rotation matrix
  62697. */
  62698. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  62699. /**
  62700. * Creates a rotation matrix and stores it in a given matrix
  62701. * @param yaw defines the yaw angle in radians (Y axis)
  62702. * @param pitch defines the pitch angle in radians (X axis)
  62703. * @param roll defines the roll angle in radians (X axis)
  62704. * @param result defines the target matrix
  62705. */
  62706. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  62707. /**
  62708. * Creates a scaling matrix
  62709. * @param x defines the scale factor on X axis
  62710. * @param y defines the scale factor on Y axis
  62711. * @param z defines the scale factor on Z axis
  62712. * @returns the new matrix
  62713. */
  62714. static Scaling(x: number, y: number, z: number): Matrix;
  62715. /**
  62716. * Creates a scaling matrix and stores it in a given matrix
  62717. * @param x defines the scale factor on X axis
  62718. * @param y defines the scale factor on Y axis
  62719. * @param z defines the scale factor on Z axis
  62720. * @param result defines the target matrix
  62721. */
  62722. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  62723. /**
  62724. * Creates a translation matrix
  62725. * @param x defines the translation on X axis
  62726. * @param y defines the translation on Y axis
  62727. * @param z defines the translationon Z axis
  62728. * @returns the new matrix
  62729. */
  62730. static Translation(x: number, y: number, z: number): Matrix;
  62731. /**
  62732. * Creates a translation matrix and stores it in a given matrix
  62733. * @param x defines the translation on X axis
  62734. * @param y defines the translation on Y axis
  62735. * @param z defines the translationon Z axis
  62736. * @param result defines the target matrix
  62737. */
  62738. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  62739. /**
  62740. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62741. * @param startValue defines the start value
  62742. * @param endValue defines the end value
  62743. * @param gradient defines the gradient factor
  62744. * @returns the new matrix
  62745. */
  62746. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62747. /**
  62748. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62749. * @param startValue defines the start value
  62750. * @param endValue defines the end value
  62751. * @param gradient defines the gradient factor
  62752. * @param result defines the Matrix object where to store data
  62753. */
  62754. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62755. /**
  62756. * Builds a new matrix whose values are computed by:
  62757. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62758. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62759. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62760. * @param startValue defines the first matrix
  62761. * @param endValue defines the second matrix
  62762. * @param gradient defines the gradient between the two matrices
  62763. * @returns the new matrix
  62764. */
  62765. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62766. /**
  62767. * Update a matrix to values which are computed by:
  62768. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62769. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62770. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62771. * @param startValue defines the first matrix
  62772. * @param endValue defines the second matrix
  62773. * @param gradient defines the gradient between the two matrices
  62774. * @param result defines the target matrix
  62775. */
  62776. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62777. /**
  62778. * 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"
  62779. * This function works in left handed mode
  62780. * @param eye defines the final position of the entity
  62781. * @param target defines where the entity should look at
  62782. * @param up defines the up vector for the entity
  62783. * @returns the new matrix
  62784. */
  62785. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62786. /**
  62787. * 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".
  62788. * This function works in left handed mode
  62789. * @param eye defines the final position of the entity
  62790. * @param target defines where the entity should look at
  62791. * @param up defines the up vector for the entity
  62792. * @param result defines the target matrix
  62793. */
  62794. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62795. /**
  62796. * 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"
  62797. * This function works in right handed mode
  62798. * @param eye defines the final position of the entity
  62799. * @param target defines where the entity should look at
  62800. * @param up defines the up vector for the entity
  62801. * @returns the new matrix
  62802. */
  62803. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62804. /**
  62805. * 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".
  62806. * This function works in right handed mode
  62807. * @param eye defines the final position of the entity
  62808. * @param target defines where the entity should look at
  62809. * @param up defines the up vector for the entity
  62810. * @param result defines the target matrix
  62811. */
  62812. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62813. /**
  62814. * Create a left-handed orthographic projection matrix
  62815. * @param width defines the viewport width
  62816. * @param height defines the viewport height
  62817. * @param znear defines the near clip plane
  62818. * @param zfar defines the far clip plane
  62819. * @returns a new matrix as a left-handed orthographic projection matrix
  62820. */
  62821. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62822. /**
  62823. * Store a left-handed orthographic projection to a given matrix
  62824. * @param width defines the viewport width
  62825. * @param height defines the viewport height
  62826. * @param znear defines the near clip plane
  62827. * @param zfar defines the far clip plane
  62828. * @param result defines the target matrix
  62829. */
  62830. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62831. /**
  62832. * Create a left-handed orthographic projection matrix
  62833. * @param left defines the viewport left coordinate
  62834. * @param right defines the viewport right coordinate
  62835. * @param bottom defines the viewport bottom coordinate
  62836. * @param top defines the viewport top coordinate
  62837. * @param znear defines the near clip plane
  62838. * @param zfar defines the far clip plane
  62839. * @returns a new matrix as a left-handed orthographic projection matrix
  62840. */
  62841. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62842. /**
  62843. * Stores a left-handed orthographic projection into a given matrix
  62844. * @param left defines the viewport left coordinate
  62845. * @param right defines the viewport right coordinate
  62846. * @param bottom defines the viewport bottom coordinate
  62847. * @param top defines the viewport top coordinate
  62848. * @param znear defines the near clip plane
  62849. * @param zfar defines the far clip plane
  62850. * @param result defines the target matrix
  62851. */
  62852. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62853. /**
  62854. * Creates a right-handed orthographic projection matrix
  62855. * @param left defines the viewport left coordinate
  62856. * @param right defines the viewport right coordinate
  62857. * @param bottom defines the viewport bottom coordinate
  62858. * @param top defines the viewport top coordinate
  62859. * @param znear defines the near clip plane
  62860. * @param zfar defines the far clip plane
  62861. * @returns a new matrix as a right-handed orthographic projection matrix
  62862. */
  62863. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62864. /**
  62865. * Stores a right-handed orthographic projection into a given matrix
  62866. * @param left defines the viewport left coordinate
  62867. * @param right defines the viewport right coordinate
  62868. * @param bottom defines the viewport bottom coordinate
  62869. * @param top defines the viewport top coordinate
  62870. * @param znear defines the near clip plane
  62871. * @param zfar defines the far clip plane
  62872. * @param result defines the target matrix
  62873. */
  62874. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62875. /**
  62876. * Creates a left-handed perspective projection matrix
  62877. * @param width defines the viewport width
  62878. * @param height defines the viewport height
  62879. * @param znear defines the near clip plane
  62880. * @param zfar defines the far clip plane
  62881. * @returns a new matrix as a left-handed perspective projection matrix
  62882. */
  62883. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62884. /**
  62885. * Creates a left-handed perspective projection matrix
  62886. * @param fov defines the horizontal field of view
  62887. * @param aspect defines the aspect ratio
  62888. * @param znear defines the near clip plane
  62889. * @param zfar defines the far clip plane
  62890. * @returns a new matrix as a left-handed perspective projection matrix
  62891. */
  62892. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62893. /**
  62894. * Stores a left-handed perspective projection into a given matrix
  62895. * @param fov defines the horizontal field of view
  62896. * @param aspect defines the aspect ratio
  62897. * @param znear defines the near clip plane
  62898. * @param zfar defines the far clip plane
  62899. * @param result defines the target matrix
  62900. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62901. */
  62902. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62903. /**
  62904. * Creates a right-handed perspective projection matrix
  62905. * @param fov defines the horizontal field of view
  62906. * @param aspect defines the aspect ratio
  62907. * @param znear defines the near clip plane
  62908. * @param zfar defines the far clip plane
  62909. * @returns a new matrix as a right-handed perspective projection matrix
  62910. */
  62911. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62912. /**
  62913. * Stores a right-handed perspective projection into a given matrix
  62914. * @param fov defines the horizontal field of view
  62915. * @param aspect defines the aspect ratio
  62916. * @param znear defines the near clip plane
  62917. * @param zfar defines the far clip plane
  62918. * @param result defines the target matrix
  62919. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62920. */
  62921. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62922. /**
  62923. * Stores a perspective projection for WebVR info a given matrix
  62924. * @param fov defines the field of view
  62925. * @param znear defines the near clip plane
  62926. * @param zfar defines the far clip plane
  62927. * @param result defines the target matrix
  62928. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62929. */
  62930. static PerspectiveFovWebVRToRef(fov: {
  62931. upDegrees: number;
  62932. downDegrees: number;
  62933. leftDegrees: number;
  62934. rightDegrees: number;
  62935. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62936. /**
  62937. * Computes a complete transformation matrix
  62938. * @param viewport defines the viewport to use
  62939. * @param world defines the world matrix
  62940. * @param view defines the view matrix
  62941. * @param projection defines the projection matrix
  62942. * @param zmin defines the near clip plane
  62943. * @param zmax defines the far clip plane
  62944. * @returns the transformation matrix
  62945. */
  62946. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62947. /**
  62948. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62949. * @param matrix defines the matrix to use
  62950. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62951. */
  62952. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62953. /**
  62954. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62955. * @param matrix defines the matrix to use
  62956. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62957. */
  62958. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62959. /**
  62960. * Compute the transpose of a given matrix
  62961. * @param matrix defines the matrix to transpose
  62962. * @returns the new matrix
  62963. */
  62964. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62965. /**
  62966. * Compute the transpose of a matrix and store it in a target matrix
  62967. * @param matrix defines the matrix to transpose
  62968. * @param result defines the target matrix
  62969. */
  62970. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62971. /**
  62972. * Computes a reflection matrix from a plane
  62973. * @param plane defines the reflection plane
  62974. * @returns a new matrix
  62975. */
  62976. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62977. /**
  62978. * Computes a reflection matrix from a plane
  62979. * @param plane defines the reflection plane
  62980. * @param result defines the target matrix
  62981. */
  62982. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62983. /**
  62984. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62985. * @param xaxis defines the value of the 1st axis
  62986. * @param yaxis defines the value of the 2nd axis
  62987. * @param zaxis defines the value of the 3rd axis
  62988. * @param result defines the target matrix
  62989. */
  62990. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62991. /**
  62992. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62993. * @param quat defines the quaternion to use
  62994. * @param result defines the target matrix
  62995. */
  62996. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62997. }
  62998. /**
  62999. * Represens a plane by the equation ax + by + cz + d = 0
  63000. */
  63001. export class Plane {
  63002. /**
  63003. * Normal of the plane (a,b,c)
  63004. */
  63005. normal: Vector3;
  63006. /**
  63007. * d component of the plane
  63008. */
  63009. d: number;
  63010. /**
  63011. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63012. * @param a a component of the plane
  63013. * @param b b component of the plane
  63014. * @param c c component of the plane
  63015. * @param d d component of the plane
  63016. */
  63017. constructor(a: number, b: number, c: number, d: number);
  63018. /**
  63019. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63020. */
  63021. asArray(): number[];
  63022. /**
  63023. * @returns a new plane copied from the current Plane.
  63024. */
  63025. clone(): Plane;
  63026. /**
  63027. * @returns the string "Plane".
  63028. */
  63029. getClassName(): string;
  63030. /**
  63031. * @returns the Plane hash code.
  63032. */
  63033. getHashCode(): number;
  63034. /**
  63035. * Normalize the current Plane in place.
  63036. * @returns the updated Plane.
  63037. */
  63038. normalize(): Plane;
  63039. /**
  63040. * Applies a transformation the plane and returns the result
  63041. * @param transformation the transformation matrix to be applied to the plane
  63042. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63043. */
  63044. transform(transformation: DeepImmutable<Matrix>): Plane;
  63045. /**
  63046. * Calcualtte the dot product between the point and the plane normal
  63047. * @param point point to calculate the dot product with
  63048. * @returns the dot product (float) of the point coordinates and the plane normal.
  63049. */
  63050. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63051. /**
  63052. * Updates the current Plane from the plane defined by the three given points.
  63053. * @param point1 one of the points used to contruct the plane
  63054. * @param point2 one of the points used to contruct the plane
  63055. * @param point3 one of the points used to contruct the plane
  63056. * @returns the updated Plane.
  63057. */
  63058. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63059. /**
  63060. * Checks if the plane is facing a given direction
  63061. * @param direction the direction to check if the plane is facing
  63062. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63063. * @returns True is the vector "direction" is the same side than the plane normal.
  63064. */
  63065. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63066. /**
  63067. * Calculates the distance to a point
  63068. * @param point point to calculate distance to
  63069. * @returns the signed distance (float) from the given point to the Plane.
  63070. */
  63071. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63072. /**
  63073. * Creates a plane from an array
  63074. * @param array the array to create a plane from
  63075. * @returns a new Plane from the given array.
  63076. */
  63077. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63078. /**
  63079. * Creates a plane from three points
  63080. * @param point1 point used to create the plane
  63081. * @param point2 point used to create the plane
  63082. * @param point3 point used to create the plane
  63083. * @returns a new Plane defined by the three given points.
  63084. */
  63085. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63086. /**
  63087. * Creates a plane from an origin point and a normal
  63088. * @param origin origin of the plane to be constructed
  63089. * @param normal normal of the plane to be constructed
  63090. * @returns a new Plane the normal vector to this plane at the given origin point.
  63091. * Note : the vector "normal" is updated because normalized.
  63092. */
  63093. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63094. /**
  63095. * Calculates the distance from a plane and a point
  63096. * @param origin origin of the plane to be constructed
  63097. * @param normal normal of the plane to be constructed
  63098. * @param point point to calculate distance to
  63099. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63100. */
  63101. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63102. }
  63103. /**
  63104. * Class used to represent a viewport on screen
  63105. */
  63106. export class Viewport {
  63107. /** viewport left coordinate */
  63108. x: number;
  63109. /** viewport top coordinate */
  63110. y: number;
  63111. /**viewport width */
  63112. width: number;
  63113. /** viewport height */
  63114. height: number;
  63115. /**
  63116. * Creates a Viewport object located at (x, y) and sized (width, height)
  63117. * @param x defines viewport left coordinate
  63118. * @param y defines viewport top coordinate
  63119. * @param width defines the viewport width
  63120. * @param height defines the viewport height
  63121. */
  63122. constructor(
  63123. /** viewport left coordinate */
  63124. x: number,
  63125. /** viewport top coordinate */
  63126. y: number,
  63127. /**viewport width */
  63128. width: number,
  63129. /** viewport height */
  63130. height: number);
  63131. /**
  63132. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63133. * @param renderWidth defines the rendering width
  63134. * @param renderHeight defines the rendering height
  63135. * @returns a new Viewport
  63136. */
  63137. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63138. /**
  63139. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63140. * @param renderWidth defines the rendering width
  63141. * @param renderHeight defines the rendering height
  63142. * @param ref defines the target viewport
  63143. * @returns the current viewport
  63144. */
  63145. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63146. /**
  63147. * Returns a new Viewport copied from the current one
  63148. * @returns a new Viewport
  63149. */
  63150. clone(): Viewport;
  63151. }
  63152. /**
  63153. * Reprasents a camera frustum
  63154. */
  63155. export class Frustum {
  63156. /**
  63157. * Gets the planes representing the frustum
  63158. * @param transform matrix to be applied to the returned planes
  63159. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63160. */
  63161. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63162. /**
  63163. * Gets the near frustum plane transformed by the transform matrix
  63164. * @param transform transformation matrix to be applied to the resulting frustum plane
  63165. * @param frustumPlane the resuling frustum plane
  63166. */
  63167. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63168. /**
  63169. * Gets the far frustum plane transformed by the transform matrix
  63170. * @param transform transformation matrix to be applied to the resulting frustum plane
  63171. * @param frustumPlane the resuling frustum plane
  63172. */
  63173. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63174. /**
  63175. * Gets the left frustum plane transformed by the transform matrix
  63176. * @param transform transformation matrix to be applied to the resulting frustum plane
  63177. * @param frustumPlane the resuling frustum plane
  63178. */
  63179. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63180. /**
  63181. * Gets the right frustum plane transformed by the transform matrix
  63182. * @param transform transformation matrix to be applied to the resulting frustum plane
  63183. * @param frustumPlane the resuling frustum plane
  63184. */
  63185. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63186. /**
  63187. * Gets the top frustum plane transformed by the transform matrix
  63188. * @param transform transformation matrix to be applied to the resulting frustum plane
  63189. * @param frustumPlane the resuling frustum plane
  63190. */
  63191. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63192. /**
  63193. * Gets the bottom frustum plane transformed by the transform matrix
  63194. * @param transform transformation matrix to be applied to the resulting frustum plane
  63195. * @param frustumPlane the resuling frustum plane
  63196. */
  63197. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63198. /**
  63199. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63200. * @param transform transformation matrix to be applied to the resulting frustum planes
  63201. * @param frustumPlanes the resuling frustum planes
  63202. */
  63203. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63204. }
  63205. /** Defines supported spaces */
  63206. export enum Space {
  63207. /** Local (object) space */
  63208. LOCAL = 0,
  63209. /** World space */
  63210. WORLD = 1,
  63211. /** Bone space */
  63212. BONE = 2
  63213. }
  63214. /** Defines the 3 main axes */
  63215. export class Axis {
  63216. /** X axis */
  63217. static X: Vector3;
  63218. /** Y axis */
  63219. static Y: Vector3;
  63220. /** Z axis */
  63221. static Z: Vector3;
  63222. }
  63223. /** Class used to represent a Bezier curve */
  63224. export class BezierCurve {
  63225. /**
  63226. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63227. * @param t defines the time
  63228. * @param x1 defines the left coordinate on X axis
  63229. * @param y1 defines the left coordinate on Y axis
  63230. * @param x2 defines the right coordinate on X axis
  63231. * @param y2 defines the right coordinate on Y axis
  63232. * @returns the interpolated value
  63233. */
  63234. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63235. }
  63236. /**
  63237. * Defines potential orientation for back face culling
  63238. */
  63239. export enum Orientation {
  63240. /**
  63241. * Clockwise
  63242. */
  63243. CW = 0,
  63244. /** Counter clockwise */
  63245. CCW = 1
  63246. }
  63247. /**
  63248. * Defines angle representation
  63249. */
  63250. export class Angle {
  63251. private _radians;
  63252. /**
  63253. * Creates an Angle object of "radians" radians (float).
  63254. * @param radians the angle in radians
  63255. */
  63256. constructor(radians: number);
  63257. /**
  63258. * Get value in degrees
  63259. * @returns the Angle value in degrees (float)
  63260. */
  63261. degrees(): number;
  63262. /**
  63263. * Get value in radians
  63264. * @returns the Angle value in radians (float)
  63265. */
  63266. radians(): number;
  63267. /**
  63268. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63269. * @param a defines first vector
  63270. * @param b defines second vector
  63271. * @returns a new Angle
  63272. */
  63273. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63274. /**
  63275. * Gets a new Angle object from the given float in radians
  63276. * @param radians defines the angle value in radians
  63277. * @returns a new Angle
  63278. */
  63279. static FromRadians(radians: number): Angle;
  63280. /**
  63281. * Gets a new Angle object from the given float in degrees
  63282. * @param degrees defines the angle value in degrees
  63283. * @returns a new Angle
  63284. */
  63285. static FromDegrees(degrees: number): Angle;
  63286. }
  63287. /**
  63288. * This represents an arc in a 2d space.
  63289. */
  63290. export class Arc2 {
  63291. /** Defines the start point of the arc */
  63292. startPoint: Vector2;
  63293. /** Defines the mid point of the arc */
  63294. midPoint: Vector2;
  63295. /** Defines the end point of the arc */
  63296. endPoint: Vector2;
  63297. /**
  63298. * Defines the center point of the arc.
  63299. */
  63300. centerPoint: Vector2;
  63301. /**
  63302. * Defines the radius of the arc.
  63303. */
  63304. radius: number;
  63305. /**
  63306. * Defines the angle of the arc (from mid point to end point).
  63307. */
  63308. angle: Angle;
  63309. /**
  63310. * Defines the start angle of the arc (from start point to middle point).
  63311. */
  63312. startAngle: Angle;
  63313. /**
  63314. * Defines the orientation of the arc (clock wise/counter clock wise).
  63315. */
  63316. orientation: Orientation;
  63317. /**
  63318. * Creates an Arc object from the three given points : start, middle and end.
  63319. * @param startPoint Defines the start point of the arc
  63320. * @param midPoint Defines the midlle point of the arc
  63321. * @param endPoint Defines the end point of the arc
  63322. */
  63323. constructor(
  63324. /** Defines the start point of the arc */
  63325. startPoint: Vector2,
  63326. /** Defines the mid point of the arc */
  63327. midPoint: Vector2,
  63328. /** Defines the end point of the arc */
  63329. endPoint: Vector2);
  63330. }
  63331. /**
  63332. * Represents a 2D path made up of multiple 2D points
  63333. */
  63334. export class Path2 {
  63335. private _points;
  63336. private _length;
  63337. /**
  63338. * If the path start and end point are the same
  63339. */
  63340. closed: boolean;
  63341. /**
  63342. * Creates a Path2 object from the starting 2D coordinates x and y.
  63343. * @param x the starting points x value
  63344. * @param y the starting points y value
  63345. */
  63346. constructor(x: number, y: number);
  63347. /**
  63348. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63349. * @param x the added points x value
  63350. * @param y the added points y value
  63351. * @returns the updated Path2.
  63352. */
  63353. addLineTo(x: number, y: number): Path2;
  63354. /**
  63355. * 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.
  63356. * @param midX middle point x value
  63357. * @param midY middle point y value
  63358. * @param endX end point x value
  63359. * @param endY end point y value
  63360. * @param numberOfSegments (default: 36)
  63361. * @returns the updated Path2.
  63362. */
  63363. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63364. /**
  63365. * Closes the Path2.
  63366. * @returns the Path2.
  63367. */
  63368. close(): Path2;
  63369. /**
  63370. * Gets the sum of the distance between each sequential point in the path
  63371. * @returns the Path2 total length (float).
  63372. */
  63373. length(): number;
  63374. /**
  63375. * Gets the points which construct the path
  63376. * @returns the Path2 internal array of points.
  63377. */
  63378. getPoints(): Vector2[];
  63379. /**
  63380. * Retreives the point at the distance aways from the starting point
  63381. * @param normalizedLengthPosition the length along the path to retreive the point from
  63382. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63383. */
  63384. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63385. /**
  63386. * Creates a new path starting from an x and y position
  63387. * @param x starting x value
  63388. * @param y starting y value
  63389. * @returns a new Path2 starting at the coordinates (x, y).
  63390. */
  63391. static StartingAt(x: number, y: number): Path2;
  63392. }
  63393. /**
  63394. * Represents a 3D path made up of multiple 3D points
  63395. */
  63396. export class Path3D {
  63397. /**
  63398. * an array of Vector3, the curve axis of the Path3D
  63399. */
  63400. path: Vector3[];
  63401. private _curve;
  63402. private _distances;
  63403. private _tangents;
  63404. private _normals;
  63405. private _binormals;
  63406. private _raw;
  63407. /**
  63408. * new Path3D(path, normal, raw)
  63409. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63410. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63411. * @param path an array of Vector3, the curve axis of the Path3D
  63412. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63413. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63414. */
  63415. constructor(
  63416. /**
  63417. * an array of Vector3, the curve axis of the Path3D
  63418. */
  63419. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63420. /**
  63421. * Returns the Path3D array of successive Vector3 designing its curve.
  63422. * @returns the Path3D array of successive Vector3 designing its curve.
  63423. */
  63424. getCurve(): Vector3[];
  63425. /**
  63426. * Returns an array populated with tangent vectors on each Path3D curve point.
  63427. * @returns an array populated with tangent vectors on each Path3D curve point.
  63428. */
  63429. getTangents(): Vector3[];
  63430. /**
  63431. * Returns an array populated with normal vectors on each Path3D curve point.
  63432. * @returns an array populated with normal vectors on each Path3D curve point.
  63433. */
  63434. getNormals(): Vector3[];
  63435. /**
  63436. * Returns an array populated with binormal vectors on each Path3D curve point.
  63437. * @returns an array populated with binormal vectors on each Path3D curve point.
  63438. */
  63439. getBinormals(): Vector3[];
  63440. /**
  63441. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63442. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63443. */
  63444. getDistances(): number[];
  63445. /**
  63446. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63447. * @param path path which all values are copied into the curves points
  63448. * @param firstNormal which should be projected onto the curve
  63449. * @returns the same object updated.
  63450. */
  63451. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63452. private _compute;
  63453. private _getFirstNonNullVector;
  63454. private _getLastNonNullVector;
  63455. private _normalVector;
  63456. }
  63457. /**
  63458. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63459. * A Curve3 is designed from a series of successive Vector3.
  63460. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63461. */
  63462. export class Curve3 {
  63463. private _points;
  63464. private _length;
  63465. /**
  63466. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63467. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63468. * @param v1 (Vector3) the control point
  63469. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63470. * @param nbPoints (integer) the wanted number of points in the curve
  63471. * @returns the created Curve3
  63472. */
  63473. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63474. /**
  63475. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63476. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63477. * @param v1 (Vector3) the first control point
  63478. * @param v2 (Vector3) the second control point
  63479. * @param v3 (Vector3) the end point of the Cubic Bezier
  63480. * @param nbPoints (integer) the wanted number of points in the curve
  63481. * @returns the created Curve3
  63482. */
  63483. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63484. /**
  63485. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63486. * @param p1 (Vector3) the origin point of the Hermite Spline
  63487. * @param t1 (Vector3) the tangent vector at the origin point
  63488. * @param p2 (Vector3) the end point of the Hermite Spline
  63489. * @param t2 (Vector3) the tangent vector at the end point
  63490. * @param nbPoints (integer) the wanted number of points in the curve
  63491. * @returns the created Curve3
  63492. */
  63493. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63494. /**
  63495. * Returns a Curve3 object along a CatmullRom Spline curve :
  63496. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63497. * @param nbPoints (integer) the wanted number of points between each curve control points
  63498. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63499. * @returns the created Curve3
  63500. */
  63501. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63502. /**
  63503. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63504. * A Curve3 is designed from a series of successive Vector3.
  63505. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63506. * @param points points which make up the curve
  63507. */
  63508. constructor(points: Vector3[]);
  63509. /**
  63510. * @returns the Curve3 stored array of successive Vector3
  63511. */
  63512. getPoints(): Vector3[];
  63513. /**
  63514. * @returns the computed length (float) of the curve.
  63515. */
  63516. length(): number;
  63517. /**
  63518. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63519. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63520. * curveA and curveB keep unchanged.
  63521. * @param curve the curve to continue from this curve
  63522. * @returns the newly constructed curve
  63523. */
  63524. continue(curve: DeepImmutable<Curve3>): Curve3;
  63525. private _computeLength;
  63526. }
  63527. /**
  63528. * Contains position and normal vectors for a vertex
  63529. */
  63530. export class PositionNormalVertex {
  63531. /** the position of the vertex (defaut: 0,0,0) */
  63532. position: Vector3;
  63533. /** the normal of the vertex (defaut: 0,1,0) */
  63534. normal: Vector3;
  63535. /**
  63536. * Creates a PositionNormalVertex
  63537. * @param position the position of the vertex (defaut: 0,0,0)
  63538. * @param normal the normal of the vertex (defaut: 0,1,0)
  63539. */
  63540. constructor(
  63541. /** the position of the vertex (defaut: 0,0,0) */
  63542. position?: Vector3,
  63543. /** the normal of the vertex (defaut: 0,1,0) */
  63544. normal?: Vector3);
  63545. /**
  63546. * Clones the PositionNormalVertex
  63547. * @returns the cloned PositionNormalVertex
  63548. */
  63549. clone(): PositionNormalVertex;
  63550. }
  63551. /**
  63552. * Contains position, normal and uv vectors for a vertex
  63553. */
  63554. export class PositionNormalTextureVertex {
  63555. /** the position of the vertex (defaut: 0,0,0) */
  63556. position: Vector3;
  63557. /** the normal of the vertex (defaut: 0,1,0) */
  63558. normal: Vector3;
  63559. /** the uv of the vertex (default: 0,0) */
  63560. uv: Vector2;
  63561. /**
  63562. * Creates a PositionNormalTextureVertex
  63563. * @param position the position of the vertex (defaut: 0,0,0)
  63564. * @param normal the normal of the vertex (defaut: 0,1,0)
  63565. * @param uv the uv of the vertex (default: 0,0)
  63566. */
  63567. constructor(
  63568. /** the position of the vertex (defaut: 0,0,0) */
  63569. position?: Vector3,
  63570. /** the normal of the vertex (defaut: 0,1,0) */
  63571. normal?: Vector3,
  63572. /** the uv of the vertex (default: 0,0) */
  63573. uv?: Vector2);
  63574. /**
  63575. * Clones the PositionNormalTextureVertex
  63576. * @returns the cloned PositionNormalTextureVertex
  63577. */
  63578. clone(): PositionNormalTextureVertex;
  63579. }
  63580. /**
  63581. * @hidden
  63582. */
  63583. export class Tmp {
  63584. static Color3: Color3[];
  63585. static Color4: Color4[];
  63586. static Vector2: Vector2[];
  63587. static Vector3: Vector3[];
  63588. static Vector4: Vector4[];
  63589. static Quaternion: Quaternion[];
  63590. static Matrix: Matrix[];
  63591. }
  63592. }
  63593. declare module BABYLON {
  63594. /**
  63595. * Class used to enable access to offline support
  63596. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63597. */
  63598. export interface IOfflineProvider {
  63599. /**
  63600. * Gets a boolean indicating if scene must be saved in the database
  63601. */
  63602. enableSceneOffline: boolean;
  63603. /**
  63604. * Gets a boolean indicating if textures must be saved in the database
  63605. */
  63606. enableTexturesOffline: boolean;
  63607. /**
  63608. * Open the offline support and make it available
  63609. * @param successCallback defines the callback to call on success
  63610. * @param errorCallback defines the callback to call on error
  63611. */
  63612. open(successCallback: () => void, errorCallback: () => void): void;
  63613. /**
  63614. * Loads an image from the offline support
  63615. * @param url defines the url to load from
  63616. * @param image defines the target DOM image
  63617. */
  63618. loadImage(url: string, image: HTMLImageElement): void;
  63619. /**
  63620. * Loads a file from offline support
  63621. * @param url defines the URL to load from
  63622. * @param sceneLoaded defines a callback to call on success
  63623. * @param progressCallBack defines a callback to call when progress changed
  63624. * @param errorCallback defines a callback to call on error
  63625. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63626. */
  63627. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63628. }
  63629. }
  63630. declare module BABYLON {
  63631. /**
  63632. * A class serves as a medium between the observable and its observers
  63633. */
  63634. export class EventState {
  63635. /**
  63636. * Create a new EventState
  63637. * @param mask defines the mask associated with this state
  63638. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63639. * @param target defines the original target of the state
  63640. * @param currentTarget defines the current target of the state
  63641. */
  63642. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63643. /**
  63644. * Initialize the current event state
  63645. * @param mask defines the mask associated with this state
  63646. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63647. * @param target defines the original target of the state
  63648. * @param currentTarget defines the current target of the state
  63649. * @returns the current event state
  63650. */
  63651. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63652. /**
  63653. * An Observer can set this property to true to prevent subsequent observers of being notified
  63654. */
  63655. skipNextObservers: boolean;
  63656. /**
  63657. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63658. */
  63659. mask: number;
  63660. /**
  63661. * The object that originally notified the event
  63662. */
  63663. target?: any;
  63664. /**
  63665. * The current object in the bubbling phase
  63666. */
  63667. currentTarget?: any;
  63668. /**
  63669. * This will be populated with the return value of the last function that was executed.
  63670. * If it is the first function in the callback chain it will be the event data.
  63671. */
  63672. lastReturnValue?: any;
  63673. }
  63674. /**
  63675. * Represent an Observer registered to a given Observable object.
  63676. */
  63677. export class Observer<T> {
  63678. /**
  63679. * Defines the callback to call when the observer is notified
  63680. */
  63681. callback: (eventData: T, eventState: EventState) => void;
  63682. /**
  63683. * Defines the mask of the observer (used to filter notifications)
  63684. */
  63685. mask: number;
  63686. /**
  63687. * Defines the current scope used to restore the JS context
  63688. */
  63689. scope: any;
  63690. /** @hidden */
  63691. _willBeUnregistered: boolean;
  63692. /**
  63693. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63694. */
  63695. unregisterOnNextCall: boolean;
  63696. /**
  63697. * Creates a new observer
  63698. * @param callback defines the callback to call when the observer is notified
  63699. * @param mask defines the mask of the observer (used to filter notifications)
  63700. * @param scope defines the current scope used to restore the JS context
  63701. */
  63702. constructor(
  63703. /**
  63704. * Defines the callback to call when the observer is notified
  63705. */
  63706. callback: (eventData: T, eventState: EventState) => void,
  63707. /**
  63708. * Defines the mask of the observer (used to filter notifications)
  63709. */
  63710. mask: number,
  63711. /**
  63712. * Defines the current scope used to restore the JS context
  63713. */
  63714. scope?: any);
  63715. }
  63716. /**
  63717. * Represent a list of observers registered to multiple Observables object.
  63718. */
  63719. export class MultiObserver<T> {
  63720. private _observers;
  63721. private _observables;
  63722. /**
  63723. * Release associated resources
  63724. */
  63725. dispose(): void;
  63726. /**
  63727. * Raise a callback when one of the observable will notify
  63728. * @param observables defines a list of observables to watch
  63729. * @param callback defines the callback to call on notification
  63730. * @param mask defines the mask used to filter notifications
  63731. * @param scope defines the current scope used to restore the JS context
  63732. * @returns the new MultiObserver
  63733. */
  63734. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63735. }
  63736. /**
  63737. * The Observable class is a simple implementation of the Observable pattern.
  63738. *
  63739. * 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.
  63740. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63741. * 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).
  63742. * 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.
  63743. */
  63744. export class Observable<T> {
  63745. private _observers;
  63746. private _eventState;
  63747. private _onObserverAdded;
  63748. /**
  63749. * Creates a new observable
  63750. * @param onObserverAdded defines a callback to call when a new observer is added
  63751. */
  63752. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63753. /**
  63754. * Create a new Observer with the specified callback
  63755. * @param callback the callback that will be executed for that Observer
  63756. * @param mask the mask used to filter observers
  63757. * @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.
  63758. * @param scope optional scope for the callback to be called from
  63759. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63760. * @returns the new observer created for the callback
  63761. */
  63762. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63763. /**
  63764. * Create a new Observer with the specified callback and unregisters after the next notification
  63765. * @param callback the callback that will be executed for that Observer
  63766. * @returns the new observer created for the callback
  63767. */
  63768. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63769. /**
  63770. * Remove an Observer from the Observable object
  63771. * @param observer the instance of the Observer to remove
  63772. * @returns false if it doesn't belong to this Observable
  63773. */
  63774. remove(observer: Nullable<Observer<T>>): boolean;
  63775. /**
  63776. * Remove a callback from the Observable object
  63777. * @param callback the callback to remove
  63778. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63779. * @returns false if it doesn't belong to this Observable
  63780. */
  63781. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63782. private _deferUnregister;
  63783. private _remove;
  63784. /**
  63785. * Moves the observable to the top of the observer list making it get called first when notified
  63786. * @param observer the observer to move
  63787. */
  63788. makeObserverTopPriority(observer: Observer<T>): void;
  63789. /**
  63790. * Moves the observable to the bottom of the observer list making it get called last when notified
  63791. * @param observer the observer to move
  63792. */
  63793. makeObserverBottomPriority(observer: Observer<T>): void;
  63794. /**
  63795. * Notify all Observers by calling their respective callback with the given data
  63796. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63797. * @param eventData defines the data to send to all observers
  63798. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63799. * @param target defines the original target of the state
  63800. * @param currentTarget defines the current target of the state
  63801. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63802. */
  63803. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63804. /**
  63805. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63806. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63807. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63808. * and it is crucial that all callbacks will be executed.
  63809. * The order of the callbacks is kept, callbacks are not executed parallel.
  63810. *
  63811. * @param eventData The data to be sent to each callback
  63812. * @param mask is used to filter observers defaults to -1
  63813. * @param target defines the callback target (see EventState)
  63814. * @param currentTarget defines he current object in the bubbling phase
  63815. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63816. */
  63817. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63818. /**
  63819. * Notify a specific observer
  63820. * @param observer defines the observer to notify
  63821. * @param eventData defines the data to be sent to each callback
  63822. * @param mask is used to filter observers defaults to -1
  63823. */
  63824. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63825. /**
  63826. * Gets a boolean indicating if the observable has at least one observer
  63827. * @returns true is the Observable has at least one Observer registered
  63828. */
  63829. hasObservers(): boolean;
  63830. /**
  63831. * Clear the list of observers
  63832. */
  63833. clear(): void;
  63834. /**
  63835. * Clone the current observable
  63836. * @returns a new observable
  63837. */
  63838. clone(): Observable<T>;
  63839. /**
  63840. * Does this observable handles observer registered with a given mask
  63841. * @param mask defines the mask to be tested
  63842. * @return whether or not one observer registered with the given mask is handeled
  63843. **/
  63844. hasSpecificMask(mask?: number): boolean;
  63845. }
  63846. }
  63847. declare module BABYLON {
  63848. /**
  63849. * Class used to help managing file picking and drag'n'drop
  63850. * File Storage
  63851. */
  63852. export class FilesInputStore {
  63853. /**
  63854. * List of files ready to be loaded
  63855. */
  63856. static FilesToLoad: {
  63857. [key: string]: File;
  63858. };
  63859. }
  63860. }
  63861. declare module BABYLON {
  63862. /** Defines the cross module used constants to avoid circular dependncies */
  63863. export class Constants {
  63864. /** Defines that alpha blending is disabled */
  63865. static readonly ALPHA_DISABLE: number;
  63866. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  63867. static readonly ALPHA_ADD: number;
  63868. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  63869. static readonly ALPHA_COMBINE: number;
  63870. /** Defines that alpha blending to DEST - SRC * DEST */
  63871. static readonly ALPHA_SUBTRACT: number;
  63872. /** Defines that alpha blending to SRC * DEST */
  63873. static readonly ALPHA_MULTIPLY: number;
  63874. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  63875. static readonly ALPHA_MAXIMIZED: number;
  63876. /** Defines that alpha blending to SRC + DEST */
  63877. static readonly ALPHA_ONEONE: number;
  63878. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  63879. static readonly ALPHA_PREMULTIPLIED: number;
  63880. /**
  63881. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  63882. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  63883. */
  63884. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  63885. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  63886. static readonly ALPHA_INTERPOLATE: number;
  63887. /**
  63888. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  63889. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  63890. */
  63891. static readonly ALPHA_SCREENMODE: number;
  63892. /** Defines that the ressource is not delayed*/
  63893. static readonly DELAYLOADSTATE_NONE: number;
  63894. /** Defines that the ressource was successfully delay loaded */
  63895. static readonly DELAYLOADSTATE_LOADED: number;
  63896. /** Defines that the ressource is currently delay loading */
  63897. static readonly DELAYLOADSTATE_LOADING: number;
  63898. /** Defines that the ressource is delayed and has not started loading */
  63899. static readonly DELAYLOADSTATE_NOTLOADED: number;
  63900. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  63901. static readonly NEVER: number;
  63902. /** 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 */
  63903. static readonly ALWAYS: number;
  63904. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  63905. static readonly LESS: number;
  63906. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  63907. static readonly EQUAL: number;
  63908. /** 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 */
  63909. static readonly LEQUAL: number;
  63910. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  63911. static readonly GREATER: number;
  63912. /** 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 */
  63913. static readonly GEQUAL: number;
  63914. /** 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 */
  63915. static readonly NOTEQUAL: number;
  63916. /** Passed to stencilOperation to specify that stencil value must be kept */
  63917. static readonly KEEP: number;
  63918. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63919. static readonly REPLACE: number;
  63920. /** Passed to stencilOperation to specify that stencil value must be incremented */
  63921. static readonly INCR: number;
  63922. /** Passed to stencilOperation to specify that stencil value must be decremented */
  63923. static readonly DECR: number;
  63924. /** Passed to stencilOperation to specify that stencil value must be inverted */
  63925. static readonly INVERT: number;
  63926. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  63927. static readonly INCR_WRAP: number;
  63928. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63929. static readonly DECR_WRAP: number;
  63930. /** Texture is not repeating outside of 0..1 UVs */
  63931. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63932. /** Texture is repeating outside of 0..1 UVs */
  63933. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63934. /** Texture is repeating and mirrored */
  63935. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63936. /** ALPHA */
  63937. static readonly TEXTUREFORMAT_ALPHA: number;
  63938. /** LUMINANCE */
  63939. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63940. /** LUMINANCE_ALPHA */
  63941. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63942. /** RGB */
  63943. static readonly TEXTUREFORMAT_RGB: number;
  63944. /** RGBA */
  63945. static readonly TEXTUREFORMAT_RGBA: number;
  63946. /** RED */
  63947. static readonly TEXTUREFORMAT_RED: number;
  63948. /** RED (2nd reference) */
  63949. static readonly TEXTUREFORMAT_R: number;
  63950. /** RG */
  63951. static readonly TEXTUREFORMAT_RG: number;
  63952. /** RED_INTEGER */
  63953. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63954. /** RED_INTEGER (2nd reference) */
  63955. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63956. /** RG_INTEGER */
  63957. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63958. /** RGB_INTEGER */
  63959. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63960. /** RGBA_INTEGER */
  63961. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63962. /** UNSIGNED_BYTE */
  63963. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63964. /** UNSIGNED_BYTE (2nd reference) */
  63965. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63966. /** FLOAT */
  63967. static readonly TEXTURETYPE_FLOAT: number;
  63968. /** HALF_FLOAT */
  63969. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63970. /** BYTE */
  63971. static readonly TEXTURETYPE_BYTE: number;
  63972. /** SHORT */
  63973. static readonly TEXTURETYPE_SHORT: number;
  63974. /** UNSIGNED_SHORT */
  63975. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63976. /** INT */
  63977. static readonly TEXTURETYPE_INT: number;
  63978. /** UNSIGNED_INT */
  63979. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63980. /** UNSIGNED_SHORT_4_4_4_4 */
  63981. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63982. /** UNSIGNED_SHORT_5_5_5_1 */
  63983. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63984. /** UNSIGNED_SHORT_5_6_5 */
  63985. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63986. /** UNSIGNED_INT_2_10_10_10_REV */
  63987. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63988. /** UNSIGNED_INT_24_8 */
  63989. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63990. /** UNSIGNED_INT_10F_11F_11F_REV */
  63991. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63992. /** UNSIGNED_INT_5_9_9_9_REV */
  63993. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63994. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63995. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63996. /** nearest is mag = nearest and min = nearest and mip = linear */
  63997. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63998. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63999. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64000. /** Trilinear is mag = linear and min = linear and mip = linear */
  64001. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64002. /** nearest is mag = nearest and min = nearest and mip = linear */
  64003. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64004. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64005. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64006. /** Trilinear is mag = linear and min = linear and mip = linear */
  64007. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64008. /** mag = nearest and min = nearest and mip = nearest */
  64009. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64010. /** mag = nearest and min = linear and mip = nearest */
  64011. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64012. /** mag = nearest and min = linear and mip = linear */
  64013. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64014. /** mag = nearest and min = linear and mip = none */
  64015. static readonly TEXTURE_NEAREST_LINEAR: number;
  64016. /** mag = nearest and min = nearest and mip = none */
  64017. static readonly TEXTURE_NEAREST_NEAREST: number;
  64018. /** mag = linear and min = nearest and mip = nearest */
  64019. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64020. /** mag = linear and min = nearest and mip = linear */
  64021. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64022. /** mag = linear and min = linear and mip = none */
  64023. static readonly TEXTURE_LINEAR_LINEAR: number;
  64024. /** mag = linear and min = nearest and mip = none */
  64025. static readonly TEXTURE_LINEAR_NEAREST: number;
  64026. /** Explicit coordinates mode */
  64027. static readonly TEXTURE_EXPLICIT_MODE: number;
  64028. /** Spherical coordinates mode */
  64029. static readonly TEXTURE_SPHERICAL_MODE: number;
  64030. /** Planar coordinates mode */
  64031. static readonly TEXTURE_PLANAR_MODE: number;
  64032. /** Cubic coordinates mode */
  64033. static readonly TEXTURE_CUBIC_MODE: number;
  64034. /** Projection coordinates mode */
  64035. static readonly TEXTURE_PROJECTION_MODE: number;
  64036. /** Skybox coordinates mode */
  64037. static readonly TEXTURE_SKYBOX_MODE: number;
  64038. /** Inverse Cubic coordinates mode */
  64039. static readonly TEXTURE_INVCUBIC_MODE: number;
  64040. /** Equirectangular coordinates mode */
  64041. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64042. /** Equirectangular Fixed coordinates mode */
  64043. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64044. /** Equirectangular Fixed Mirrored coordinates mode */
  64045. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64046. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64047. static readonly SCALEMODE_FLOOR: number;
  64048. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64049. static readonly SCALEMODE_NEAREST: number;
  64050. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64051. static readonly SCALEMODE_CEILING: number;
  64052. /**
  64053. * The dirty texture flag value
  64054. */
  64055. static readonly MATERIAL_TextureDirtyFlag: number;
  64056. /**
  64057. * The dirty light flag value
  64058. */
  64059. static readonly MATERIAL_LightDirtyFlag: number;
  64060. /**
  64061. * The dirty fresnel flag value
  64062. */
  64063. static readonly MATERIAL_FresnelDirtyFlag: number;
  64064. /**
  64065. * The dirty attribute flag value
  64066. */
  64067. static readonly MATERIAL_AttributesDirtyFlag: number;
  64068. /**
  64069. * The dirty misc flag value
  64070. */
  64071. static readonly MATERIAL_MiscDirtyFlag: number;
  64072. /**
  64073. * The all dirty flag value
  64074. */
  64075. static readonly MATERIAL_AllDirtyFlag: number;
  64076. /**
  64077. * Returns the triangle fill mode
  64078. */
  64079. static readonly MATERIAL_TriangleFillMode: number;
  64080. /**
  64081. * Returns the wireframe mode
  64082. */
  64083. static readonly MATERIAL_WireFrameFillMode: number;
  64084. /**
  64085. * Returns the point fill mode
  64086. */
  64087. static readonly MATERIAL_PointFillMode: number;
  64088. /**
  64089. * Returns the point list draw mode
  64090. */
  64091. static readonly MATERIAL_PointListDrawMode: number;
  64092. /**
  64093. * Returns the line list draw mode
  64094. */
  64095. static readonly MATERIAL_LineListDrawMode: number;
  64096. /**
  64097. * Returns the line loop draw mode
  64098. */
  64099. static readonly MATERIAL_LineLoopDrawMode: number;
  64100. /**
  64101. * Returns the line strip draw mode
  64102. */
  64103. static readonly MATERIAL_LineStripDrawMode: number;
  64104. /**
  64105. * Returns the triangle strip draw mode
  64106. */
  64107. static readonly MATERIAL_TriangleStripDrawMode: number;
  64108. /**
  64109. * Returns the triangle fan draw mode
  64110. */
  64111. static readonly MATERIAL_TriangleFanDrawMode: number;
  64112. /**
  64113. * Stores the clock-wise side orientation
  64114. */
  64115. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64116. /**
  64117. * Stores the counter clock-wise side orientation
  64118. */
  64119. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64120. /**
  64121. * Nothing
  64122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64123. */
  64124. static readonly ACTION_NothingTrigger: number;
  64125. /**
  64126. * On pick
  64127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64128. */
  64129. static readonly ACTION_OnPickTrigger: number;
  64130. /**
  64131. * On left pick
  64132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64133. */
  64134. static readonly ACTION_OnLeftPickTrigger: number;
  64135. /**
  64136. * On right pick
  64137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64138. */
  64139. static readonly ACTION_OnRightPickTrigger: number;
  64140. /**
  64141. * On center pick
  64142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64143. */
  64144. static readonly ACTION_OnCenterPickTrigger: number;
  64145. /**
  64146. * On pick down
  64147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64148. */
  64149. static readonly ACTION_OnPickDownTrigger: number;
  64150. /**
  64151. * On double pick
  64152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64153. */
  64154. static readonly ACTION_OnDoublePickTrigger: number;
  64155. /**
  64156. * On pick up
  64157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64158. */
  64159. static readonly ACTION_OnPickUpTrigger: number;
  64160. /**
  64161. * On pick out.
  64162. * This trigger will only be raised if you also declared a OnPickDown
  64163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64164. */
  64165. static readonly ACTION_OnPickOutTrigger: number;
  64166. /**
  64167. * On long press
  64168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64169. */
  64170. static readonly ACTION_OnLongPressTrigger: number;
  64171. /**
  64172. * On pointer over
  64173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64174. */
  64175. static readonly ACTION_OnPointerOverTrigger: number;
  64176. /**
  64177. * On pointer out
  64178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64179. */
  64180. static readonly ACTION_OnPointerOutTrigger: number;
  64181. /**
  64182. * On every frame
  64183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64184. */
  64185. static readonly ACTION_OnEveryFrameTrigger: number;
  64186. /**
  64187. * On intersection enter
  64188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64189. */
  64190. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64191. /**
  64192. * On intersection exit
  64193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64194. */
  64195. static readonly ACTION_OnIntersectionExitTrigger: number;
  64196. /**
  64197. * On key down
  64198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64199. */
  64200. static readonly ACTION_OnKeyDownTrigger: number;
  64201. /**
  64202. * On key up
  64203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64204. */
  64205. static readonly ACTION_OnKeyUpTrigger: number;
  64206. /**
  64207. * Billboard mode will only apply to Y axis
  64208. */
  64209. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64210. /**
  64211. * Billboard mode will apply to all axes
  64212. */
  64213. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64214. /**
  64215. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64216. */
  64217. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64218. /**
  64219. * Gets or sets base Assets URL
  64220. */
  64221. static readonly PARTICLES_BaseAssetsUrl: string;
  64222. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64223. * Test order :
  64224. * Is the bounding sphere outside the frustum ?
  64225. * If not, are the bounding box vertices outside the frustum ?
  64226. * It not, then the cullable object is in the frustum.
  64227. */
  64228. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64229. /** Culling strategy : Bounding Sphere Only.
  64230. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64231. * It's also less accurate than the standard because some not visible objects can still be selected.
  64232. * Test : is the bounding sphere outside the frustum ?
  64233. * If not, then the cullable object is in the frustum.
  64234. */
  64235. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64236. /** Culling strategy : Optimistic Inclusion.
  64237. * This in an inclusion test first, then the standard exclusion test.
  64238. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64239. * 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.
  64240. * Anyway, it's as accurate as the standard strategy.
  64241. * Test :
  64242. * Is the cullable object bounding sphere center in the frustum ?
  64243. * If not, apply the default culling strategy.
  64244. */
  64245. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64246. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64247. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64248. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64249. * 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.
  64250. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64251. * Test :
  64252. * Is the cullable object bounding sphere center in the frustum ?
  64253. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64254. */
  64255. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64256. /**
  64257. * No logging while loading
  64258. */
  64259. static readonly SCENELOADER_NO_LOGGING: number;
  64260. /**
  64261. * Minimal logging while loading
  64262. */
  64263. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64264. /**
  64265. * Summary logging while loading
  64266. */
  64267. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64268. /**
  64269. * Detailled logging while loading
  64270. */
  64271. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64272. }
  64273. }
  64274. declare module BABYLON {
  64275. /**
  64276. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64277. * Babylon.js
  64278. */
  64279. export class DomManagement {
  64280. /**
  64281. * Checks if the window object exists
  64282. * @returns true if the window object exists
  64283. */
  64284. static IsWindowObjectExist(): boolean;
  64285. /**
  64286. * Extracts text content from a DOM element hierarchy
  64287. * @param element defines the root element
  64288. * @returns a string
  64289. */
  64290. static GetDOMTextContent(element: HTMLElement): string;
  64291. }
  64292. }
  64293. declare module BABYLON {
  64294. /**
  64295. * Logger used througouht the application to allow configuration of
  64296. * the log level required for the messages.
  64297. */
  64298. export class Logger {
  64299. /**
  64300. * No log
  64301. */
  64302. static readonly NoneLogLevel: number;
  64303. /**
  64304. * Only message logs
  64305. */
  64306. static readonly MessageLogLevel: number;
  64307. /**
  64308. * Only warning logs
  64309. */
  64310. static readonly WarningLogLevel: number;
  64311. /**
  64312. * Only error logs
  64313. */
  64314. static readonly ErrorLogLevel: number;
  64315. /**
  64316. * All logs
  64317. */
  64318. static readonly AllLogLevel: number;
  64319. private static _LogCache;
  64320. /**
  64321. * Gets a value indicating the number of loading errors
  64322. * @ignorenaming
  64323. */
  64324. static errorsCount: number;
  64325. /**
  64326. * Callback called when a new log is added
  64327. */
  64328. static OnNewCacheEntry: (entry: string) => void;
  64329. private static _AddLogEntry;
  64330. private static _FormatMessage;
  64331. private static _LogDisabled;
  64332. private static _LogEnabled;
  64333. private static _WarnDisabled;
  64334. private static _WarnEnabled;
  64335. private static _ErrorDisabled;
  64336. private static _ErrorEnabled;
  64337. /**
  64338. * Log a message to the console
  64339. */
  64340. static Log: (message: string) => void;
  64341. /**
  64342. * Write a warning message to the console
  64343. */
  64344. static Warn: (message: string) => void;
  64345. /**
  64346. * Write an error message to the console
  64347. */
  64348. static Error: (message: string) => void;
  64349. /**
  64350. * Gets current log cache (list of logs)
  64351. */
  64352. static readonly LogCache: string;
  64353. /**
  64354. * Clears the log cache
  64355. */
  64356. static ClearLogCache(): void;
  64357. /**
  64358. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64359. */
  64360. static LogLevels: number;
  64361. }
  64362. }
  64363. declare module BABYLON {
  64364. /** @hidden */
  64365. export class _TypeStore {
  64366. /** @hidden */
  64367. static RegisteredTypes: {
  64368. [key: string]: Object;
  64369. };
  64370. /** @hidden */
  64371. static GetClass(fqdn: string): any;
  64372. }
  64373. }
  64374. declare module BABYLON {
  64375. /**
  64376. * Class containing a set of static utilities functions for deep copy.
  64377. */
  64378. export class DeepCopier {
  64379. /**
  64380. * Tries to copy an object by duplicating every property
  64381. * @param source defines the source object
  64382. * @param destination defines the target object
  64383. * @param doNotCopyList defines a list of properties to avoid
  64384. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64385. */
  64386. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64387. }
  64388. }
  64389. declare module BABYLON {
  64390. /**
  64391. * Class containing a set of static utilities functions for precision date
  64392. */
  64393. export class PrecisionDate {
  64394. /**
  64395. * Gets either window.performance.now() if supported or Date.now() else
  64396. */
  64397. static readonly Now: number;
  64398. }
  64399. }
  64400. declare module BABYLON {
  64401. /** @hidden */
  64402. export class _DevTools {
  64403. static WarnImport(name: string): string;
  64404. }
  64405. }
  64406. declare module BABYLON {
  64407. /**
  64408. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64409. */
  64410. export class WebRequest {
  64411. private _xhr;
  64412. /**
  64413. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64414. * i.e. when loading files, where the server/service expects an Authorization header
  64415. */
  64416. static CustomRequestHeaders: {
  64417. [key: string]: string;
  64418. };
  64419. /**
  64420. * Add callback functions in this array to update all the requests before they get sent to the network
  64421. */
  64422. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64423. private _injectCustomRequestHeaders;
  64424. /**
  64425. * Gets or sets a function to be called when loading progress changes
  64426. */
  64427. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64428. /**
  64429. * Returns client's state
  64430. */
  64431. readonly readyState: number;
  64432. /**
  64433. * Returns client's status
  64434. */
  64435. readonly status: number;
  64436. /**
  64437. * Returns client's status as a text
  64438. */
  64439. readonly statusText: string;
  64440. /**
  64441. * Returns client's response
  64442. */
  64443. readonly response: any;
  64444. /**
  64445. * Returns client's response url
  64446. */
  64447. readonly responseURL: string;
  64448. /**
  64449. * Returns client's response as text
  64450. */
  64451. readonly responseText: string;
  64452. /**
  64453. * Gets or sets the expected response type
  64454. */
  64455. responseType: XMLHttpRequestResponseType;
  64456. /** @hidden */
  64457. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64458. /** @hidden */
  64459. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64460. /**
  64461. * Cancels any network activity
  64462. */
  64463. abort(): void;
  64464. /**
  64465. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64466. * @param body defines an optional request body
  64467. */
  64468. send(body?: Document | BodyInit | null): void;
  64469. /**
  64470. * Sets the request method, request URL
  64471. * @param method defines the method to use (GET, POST, etc..)
  64472. * @param url defines the url to connect with
  64473. */
  64474. open(method: string, url: string): void;
  64475. }
  64476. }
  64477. declare module BABYLON {
  64478. /**
  64479. * Class used to evalaute queries containing `and` and `or` operators
  64480. */
  64481. export class AndOrNotEvaluator {
  64482. /**
  64483. * Evaluate a query
  64484. * @param query defines the query to evaluate
  64485. * @param evaluateCallback defines the callback used to filter result
  64486. * @returns true if the query matches
  64487. */
  64488. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64489. private static _HandleParenthesisContent;
  64490. private static _SimplifyNegation;
  64491. }
  64492. }
  64493. declare module BABYLON {
  64494. /**
  64495. * Class used to store custom tags
  64496. */
  64497. export class Tags {
  64498. /**
  64499. * Adds support for tags on the given object
  64500. * @param obj defines the object to use
  64501. */
  64502. static EnableFor(obj: any): void;
  64503. /**
  64504. * Removes tags support
  64505. * @param obj defines the object to use
  64506. */
  64507. static DisableFor(obj: any): void;
  64508. /**
  64509. * Gets a boolean indicating if the given object has tags
  64510. * @param obj defines the object to use
  64511. * @returns a boolean
  64512. */
  64513. static HasTags(obj: any): boolean;
  64514. /**
  64515. * Gets the tags available on a given object
  64516. * @param obj defines the object to use
  64517. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64518. * @returns the tags
  64519. */
  64520. static GetTags(obj: any, asString?: boolean): any;
  64521. /**
  64522. * Adds tags to an object
  64523. * @param obj defines the object to use
  64524. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64525. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64526. */
  64527. static AddTagsTo(obj: any, tagsString: string): void;
  64528. /**
  64529. * @hidden
  64530. */
  64531. static _AddTagTo(obj: any, tag: string): void;
  64532. /**
  64533. * Removes specific tags from a specific object
  64534. * @param obj defines the object to use
  64535. * @param tagsString defines the tags to remove
  64536. */
  64537. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64538. /**
  64539. * @hidden
  64540. */
  64541. static _RemoveTagFrom(obj: any, tag: string): void;
  64542. /**
  64543. * Defines if tags hosted on an object match a given query
  64544. * @param obj defines the object to use
  64545. * @param tagsQuery defines the tag query
  64546. * @returns a boolean
  64547. */
  64548. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64549. }
  64550. }
  64551. declare module BABYLON {
  64552. /**
  64553. * Manages the defines for the Material
  64554. */
  64555. export class MaterialDefines {
  64556. private _keys;
  64557. private _isDirty;
  64558. /** @hidden */
  64559. _renderId: number;
  64560. /** @hidden */
  64561. _areLightsDirty: boolean;
  64562. /** @hidden */
  64563. _areAttributesDirty: boolean;
  64564. /** @hidden */
  64565. _areTexturesDirty: boolean;
  64566. /** @hidden */
  64567. _areFresnelDirty: boolean;
  64568. /** @hidden */
  64569. _areMiscDirty: boolean;
  64570. /** @hidden */
  64571. _areImageProcessingDirty: boolean;
  64572. /** @hidden */
  64573. _normals: boolean;
  64574. /** @hidden */
  64575. _uvs: boolean;
  64576. /** @hidden */
  64577. _needNormals: boolean;
  64578. /** @hidden */
  64579. _needUVs: boolean;
  64580. /**
  64581. * Specifies if the material needs to be re-calculated
  64582. */
  64583. readonly isDirty: boolean;
  64584. /**
  64585. * Marks the material to indicate that it has been re-calculated
  64586. */
  64587. markAsProcessed(): void;
  64588. /**
  64589. * Marks the material to indicate that it needs to be re-calculated
  64590. */
  64591. markAsUnprocessed(): void;
  64592. /**
  64593. * Marks the material to indicate all of its defines need to be re-calculated
  64594. */
  64595. markAllAsDirty(): void;
  64596. /**
  64597. * Marks the material to indicate that image processing needs to be re-calculated
  64598. */
  64599. markAsImageProcessingDirty(): void;
  64600. /**
  64601. * Marks the material to indicate the lights need to be re-calculated
  64602. */
  64603. markAsLightDirty(): void;
  64604. /**
  64605. * Marks the attribute state as changed
  64606. */
  64607. markAsAttributesDirty(): void;
  64608. /**
  64609. * Marks the texture state as changed
  64610. */
  64611. markAsTexturesDirty(): void;
  64612. /**
  64613. * Marks the fresnel state as changed
  64614. */
  64615. markAsFresnelDirty(): void;
  64616. /**
  64617. * Marks the misc state as changed
  64618. */
  64619. markAsMiscDirty(): void;
  64620. /**
  64621. * Rebuilds the material defines
  64622. */
  64623. rebuild(): void;
  64624. /**
  64625. * Specifies if two material defines are equal
  64626. * @param other - A material define instance to compare to
  64627. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64628. */
  64629. isEqual(other: MaterialDefines): boolean;
  64630. /**
  64631. * Clones this instance's defines to another instance
  64632. * @param other - material defines to clone values to
  64633. */
  64634. cloneTo(other: MaterialDefines): void;
  64635. /**
  64636. * Resets the material define values
  64637. */
  64638. reset(): void;
  64639. /**
  64640. * Converts the material define values to a string
  64641. * @returns - String of material define information
  64642. */
  64643. toString(): string;
  64644. }
  64645. }
  64646. declare module BABYLON {
  64647. /**
  64648. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64649. */
  64650. export class PerformanceMonitor {
  64651. private _enabled;
  64652. private _rollingFrameTime;
  64653. private _lastFrameTimeMs;
  64654. /**
  64655. * constructor
  64656. * @param frameSampleSize The number of samples required to saturate the sliding window
  64657. */
  64658. constructor(frameSampleSize?: number);
  64659. /**
  64660. * Samples current frame
  64661. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64662. */
  64663. sampleFrame(timeMs?: number): void;
  64664. /**
  64665. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64666. */
  64667. readonly averageFrameTime: number;
  64668. /**
  64669. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64670. */
  64671. readonly averageFrameTimeVariance: number;
  64672. /**
  64673. * Returns the frame time of the most recent frame
  64674. */
  64675. readonly instantaneousFrameTime: number;
  64676. /**
  64677. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64678. */
  64679. readonly averageFPS: number;
  64680. /**
  64681. * Returns the average framerate in frames per second using the most recent frame time
  64682. */
  64683. readonly instantaneousFPS: number;
  64684. /**
  64685. * Returns true if enough samples have been taken to completely fill the sliding window
  64686. */
  64687. readonly isSaturated: boolean;
  64688. /**
  64689. * Enables contributions to the sliding window sample set
  64690. */
  64691. enable(): void;
  64692. /**
  64693. * Disables contributions to the sliding window sample set
  64694. * Samples will not be interpolated over the disabled period
  64695. */
  64696. disable(): void;
  64697. /**
  64698. * Returns true if sampling is enabled
  64699. */
  64700. readonly isEnabled: boolean;
  64701. /**
  64702. * Resets performance monitor
  64703. */
  64704. reset(): void;
  64705. }
  64706. /**
  64707. * RollingAverage
  64708. *
  64709. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64710. */
  64711. export class RollingAverage {
  64712. /**
  64713. * Current average
  64714. */
  64715. average: number;
  64716. /**
  64717. * Current variance
  64718. */
  64719. variance: number;
  64720. protected _samples: Array<number>;
  64721. protected _sampleCount: number;
  64722. protected _pos: number;
  64723. protected _m2: number;
  64724. /**
  64725. * constructor
  64726. * @param length The number of samples required to saturate the sliding window
  64727. */
  64728. constructor(length: number);
  64729. /**
  64730. * Adds a sample to the sample set
  64731. * @param v The sample value
  64732. */
  64733. add(v: number): void;
  64734. /**
  64735. * Returns previously added values or null if outside of history or outside the sliding window domain
  64736. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64737. * @return Value previously recorded with add() or null if outside of range
  64738. */
  64739. history(i: number): number;
  64740. /**
  64741. * Returns true if enough samples have been taken to completely fill the sliding window
  64742. * @return true if sample-set saturated
  64743. */
  64744. isSaturated(): boolean;
  64745. /**
  64746. * Resets the rolling average (equivalent to 0 samples taken so far)
  64747. */
  64748. reset(): void;
  64749. /**
  64750. * Wraps a value around the sample range boundaries
  64751. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64752. * @return Wrapped position in sample range
  64753. */
  64754. protected _wrapPosition(i: number): number;
  64755. }
  64756. }
  64757. declare module BABYLON {
  64758. /**
  64759. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64760. * The underlying implementation relies on an associative array to ensure the best performances.
  64761. * The value can be anything including 'null' but except 'undefined'
  64762. */
  64763. export class StringDictionary<T> {
  64764. /**
  64765. * This will clear this dictionary and copy the content from the 'source' one.
  64766. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64767. * @param source the dictionary to take the content from and copy to this dictionary
  64768. */
  64769. copyFrom(source: StringDictionary<T>): void;
  64770. /**
  64771. * Get a value based from its key
  64772. * @param key the given key to get the matching value from
  64773. * @return the value if found, otherwise undefined is returned
  64774. */
  64775. get(key: string): T | undefined;
  64776. /**
  64777. * Get a value from its key or add it if it doesn't exist.
  64778. * This method will ensure you that a given key/data will be present in the dictionary.
  64779. * @param key the given key to get the matching value from
  64780. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64781. * The factory will only be invoked if there's no data for the given key.
  64782. * @return the value corresponding to the key.
  64783. */
  64784. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64785. /**
  64786. * Get a value from its key if present in the dictionary otherwise add it
  64787. * @param key the key to get the value from
  64788. * @param val if there's no such key/value pair in the dictionary add it with this value
  64789. * @return the value corresponding to the key
  64790. */
  64791. getOrAdd(key: string, val: T): T;
  64792. /**
  64793. * Check if there's a given key in the dictionary
  64794. * @param key the key to check for
  64795. * @return true if the key is present, false otherwise
  64796. */
  64797. contains(key: string): boolean;
  64798. /**
  64799. * Add a new key and its corresponding value
  64800. * @param key the key to add
  64801. * @param value the value corresponding to the key
  64802. * @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
  64803. */
  64804. add(key: string, value: T): boolean;
  64805. /**
  64806. * Update a specific value associated to a key
  64807. * @param key defines the key to use
  64808. * @param value defines the value to store
  64809. * @returns true if the value was updated (or false if the key was not found)
  64810. */
  64811. set(key: string, value: T): boolean;
  64812. /**
  64813. * Get the element of the given key and remove it from the dictionary
  64814. * @param key defines the key to search
  64815. * @returns the value associated with the key or null if not found
  64816. */
  64817. getAndRemove(key: string): Nullable<T>;
  64818. /**
  64819. * Remove a key/value from the dictionary.
  64820. * @param key the key to remove
  64821. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64822. */
  64823. remove(key: string): boolean;
  64824. /**
  64825. * Clear the whole content of the dictionary
  64826. */
  64827. clear(): void;
  64828. /**
  64829. * Gets the current count
  64830. */
  64831. readonly count: number;
  64832. /**
  64833. * Execute a callback on each key/val of the dictionary.
  64834. * Note that you can remove any element in this dictionary in the callback implementation
  64835. * @param callback the callback to execute on a given key/value pair
  64836. */
  64837. forEach(callback: (key: string, val: T) => void): void;
  64838. /**
  64839. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64840. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64841. * Note that you can remove any element in this dictionary in the callback implementation
  64842. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64843. * @returns the first item
  64844. */
  64845. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64846. private _count;
  64847. private _data;
  64848. }
  64849. }
  64850. declare module BABYLON {
  64851. /**
  64852. * Helper class that provides a small promise polyfill
  64853. */
  64854. export class PromisePolyfill {
  64855. /**
  64856. * Static function used to check if the polyfill is required
  64857. * If this is the case then the function will inject the polyfill to window.Promise
  64858. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  64859. */
  64860. static Apply(force?: boolean): void;
  64861. }
  64862. }
  64863. declare module BABYLON {
  64864. /**
  64865. * Class used to store data that will be store in GPU memory
  64866. */
  64867. export class Buffer {
  64868. private _engine;
  64869. private _buffer;
  64870. /** @hidden */
  64871. _data: Nullable<DataArray>;
  64872. private _updatable;
  64873. private _instanced;
  64874. /**
  64875. * Gets the byte stride.
  64876. */
  64877. readonly byteStride: number;
  64878. /**
  64879. * Constructor
  64880. * @param engine the engine
  64881. * @param data the data to use for this buffer
  64882. * @param updatable whether the data is updatable
  64883. * @param stride the stride (optional)
  64884. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64885. * @param instanced whether the buffer is instanced (optional)
  64886. * @param useBytes set to true if the stride in in bytes (optional)
  64887. */
  64888. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64889. /**
  64890. * Create a new VertexBuffer based on the current buffer
  64891. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64892. * @param offset defines offset in the buffer (0 by default)
  64893. * @param size defines the size in floats of attributes (position is 3 for instance)
  64894. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64895. * @param instanced defines if the vertex buffer contains indexed data
  64896. * @param useBytes defines if the offset and stride are in bytes
  64897. * @returns the new vertex buffer
  64898. */
  64899. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64900. /**
  64901. * Gets a boolean indicating if the Buffer is updatable?
  64902. * @returns true if the buffer is updatable
  64903. */
  64904. isUpdatable(): boolean;
  64905. /**
  64906. * Gets current buffer's data
  64907. * @returns a DataArray or null
  64908. */
  64909. getData(): Nullable<DataArray>;
  64910. /**
  64911. * Gets underlying native buffer
  64912. * @returns underlying native buffer
  64913. */
  64914. getBuffer(): Nullable<WebGLBuffer>;
  64915. /**
  64916. * Gets the stride in float32 units (i.e. byte stride / 4).
  64917. * May not be an integer if the byte stride is not divisible by 4.
  64918. * DEPRECATED. Use byteStride instead.
  64919. * @returns the stride in float32 units
  64920. */
  64921. getStrideSize(): number;
  64922. /**
  64923. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64924. * @param data defines the data to store
  64925. */
  64926. create(data?: Nullable<DataArray>): void;
  64927. /** @hidden */
  64928. _rebuild(): void;
  64929. /**
  64930. * Update current buffer data
  64931. * @param data defines the data to store
  64932. */
  64933. update(data: DataArray): void;
  64934. /**
  64935. * Updates the data directly.
  64936. * @param data the new data
  64937. * @param offset the new offset
  64938. * @param vertexCount the vertex count (optional)
  64939. * @param useBytes set to true if the offset is in bytes
  64940. */
  64941. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64942. /**
  64943. * Release all resources
  64944. */
  64945. dispose(): void;
  64946. }
  64947. /**
  64948. * Specialized buffer used to store vertex data
  64949. */
  64950. export class VertexBuffer {
  64951. /** @hidden */
  64952. _buffer: Buffer;
  64953. private _kind;
  64954. private _size;
  64955. private _ownsBuffer;
  64956. private _instanced;
  64957. private _instanceDivisor;
  64958. /**
  64959. * The byte type.
  64960. */
  64961. static readonly BYTE: number;
  64962. /**
  64963. * The unsigned byte type.
  64964. */
  64965. static readonly UNSIGNED_BYTE: number;
  64966. /**
  64967. * The short type.
  64968. */
  64969. static readonly SHORT: number;
  64970. /**
  64971. * The unsigned short type.
  64972. */
  64973. static readonly UNSIGNED_SHORT: number;
  64974. /**
  64975. * The integer type.
  64976. */
  64977. static readonly INT: number;
  64978. /**
  64979. * The unsigned integer type.
  64980. */
  64981. static readonly UNSIGNED_INT: number;
  64982. /**
  64983. * The float type.
  64984. */
  64985. static readonly FLOAT: number;
  64986. /**
  64987. * Gets or sets the instance divisor when in instanced mode
  64988. */
  64989. instanceDivisor: number;
  64990. /**
  64991. * Gets the byte stride.
  64992. */
  64993. readonly byteStride: number;
  64994. /**
  64995. * Gets the byte offset.
  64996. */
  64997. readonly byteOffset: number;
  64998. /**
  64999. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65000. */
  65001. readonly normalized: boolean;
  65002. /**
  65003. * Gets the data type of each component in the array.
  65004. */
  65005. readonly type: number;
  65006. /**
  65007. * Constructor
  65008. * @param engine the engine
  65009. * @param data the data to use for this vertex buffer
  65010. * @param kind the vertex buffer kind
  65011. * @param updatable whether the data is updatable
  65012. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65013. * @param stride the stride (optional)
  65014. * @param instanced whether the buffer is instanced (optional)
  65015. * @param offset the offset of the data (optional)
  65016. * @param size the number of components (optional)
  65017. * @param type the type of the component (optional)
  65018. * @param normalized whether the data contains normalized data (optional)
  65019. * @param useBytes set to true if stride and offset are in bytes (optional)
  65020. */
  65021. 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);
  65022. /** @hidden */
  65023. _rebuild(): void;
  65024. /**
  65025. * Returns the kind of the VertexBuffer (string)
  65026. * @returns a string
  65027. */
  65028. getKind(): string;
  65029. /**
  65030. * Gets a boolean indicating if the VertexBuffer is updatable?
  65031. * @returns true if the buffer is updatable
  65032. */
  65033. isUpdatable(): boolean;
  65034. /**
  65035. * Gets current buffer's data
  65036. * @returns a DataArray or null
  65037. */
  65038. getData(): Nullable<DataArray>;
  65039. /**
  65040. * Gets underlying native buffer
  65041. * @returns underlying native buffer
  65042. */
  65043. getBuffer(): Nullable<WebGLBuffer>;
  65044. /**
  65045. * Gets the stride in float32 units (i.e. byte stride / 4).
  65046. * May not be an integer if the byte stride is not divisible by 4.
  65047. * DEPRECATED. Use byteStride instead.
  65048. * @returns the stride in float32 units
  65049. */
  65050. getStrideSize(): number;
  65051. /**
  65052. * Returns the offset as a multiple of the type byte length.
  65053. * DEPRECATED. Use byteOffset instead.
  65054. * @returns the offset in bytes
  65055. */
  65056. getOffset(): number;
  65057. /**
  65058. * Returns the number of components per vertex attribute (integer)
  65059. * @returns the size in float
  65060. */
  65061. getSize(): number;
  65062. /**
  65063. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65064. * @returns true if this buffer is instanced
  65065. */
  65066. getIsInstanced(): boolean;
  65067. /**
  65068. * Returns the instancing divisor, zero for non-instanced (integer).
  65069. * @returns a number
  65070. */
  65071. getInstanceDivisor(): number;
  65072. /**
  65073. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65074. * @param data defines the data to store
  65075. */
  65076. create(data?: DataArray): void;
  65077. /**
  65078. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65079. * This function will create a new buffer if the current one is not updatable
  65080. * @param data defines the data to store
  65081. */
  65082. update(data: DataArray): void;
  65083. /**
  65084. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65085. * Returns the directly updated WebGLBuffer.
  65086. * @param data the new data
  65087. * @param offset the new offset
  65088. * @param useBytes set to true if the offset is in bytes
  65089. */
  65090. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65091. /**
  65092. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65093. */
  65094. dispose(): void;
  65095. /**
  65096. * Enumerates each value of this vertex buffer as numbers.
  65097. * @param count the number of values to enumerate
  65098. * @param callback the callback function called for each value
  65099. */
  65100. forEach(count: number, callback: (value: number, index: number) => void): void;
  65101. /**
  65102. * Positions
  65103. */
  65104. static readonly PositionKind: string;
  65105. /**
  65106. * Normals
  65107. */
  65108. static readonly NormalKind: string;
  65109. /**
  65110. * Tangents
  65111. */
  65112. static readonly TangentKind: string;
  65113. /**
  65114. * Texture coordinates
  65115. */
  65116. static readonly UVKind: string;
  65117. /**
  65118. * Texture coordinates 2
  65119. */
  65120. static readonly UV2Kind: string;
  65121. /**
  65122. * Texture coordinates 3
  65123. */
  65124. static readonly UV3Kind: string;
  65125. /**
  65126. * Texture coordinates 4
  65127. */
  65128. static readonly UV4Kind: string;
  65129. /**
  65130. * Texture coordinates 5
  65131. */
  65132. static readonly UV5Kind: string;
  65133. /**
  65134. * Texture coordinates 6
  65135. */
  65136. static readonly UV6Kind: string;
  65137. /**
  65138. * Colors
  65139. */
  65140. static readonly ColorKind: string;
  65141. /**
  65142. * Matrix indices (for bones)
  65143. */
  65144. static readonly MatricesIndicesKind: string;
  65145. /**
  65146. * Matrix weights (for bones)
  65147. */
  65148. static readonly MatricesWeightsKind: string;
  65149. /**
  65150. * Additional matrix indices (for bones)
  65151. */
  65152. static readonly MatricesIndicesExtraKind: string;
  65153. /**
  65154. * Additional matrix weights (for bones)
  65155. */
  65156. static readonly MatricesWeightsExtraKind: string;
  65157. /**
  65158. * Deduces the stride given a kind.
  65159. * @param kind The kind string to deduce
  65160. * @returns The deduced stride
  65161. */
  65162. static DeduceStride(kind: string): number;
  65163. /**
  65164. * Gets the byte length of the given type.
  65165. * @param type the type
  65166. * @returns the number of bytes
  65167. */
  65168. static GetTypeByteLength(type: number): number;
  65169. /**
  65170. * Enumerates each value of the given parameters as numbers.
  65171. * @param data the data to enumerate
  65172. * @param byteOffset the byte offset of the data
  65173. * @param byteStride the byte stride of the data
  65174. * @param componentCount the number of components per element
  65175. * @param componentType the type of the component
  65176. * @param count the total number of components
  65177. * @param normalized whether the data is normalized
  65178. * @param callback the callback function called for each value
  65179. */
  65180. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65181. private static _GetFloatValue;
  65182. }
  65183. }
  65184. declare module BABYLON {
  65185. /**
  65186. * Class representing spherical polynomial coefficients to the 3rd degree
  65187. */
  65188. export class SphericalPolynomial {
  65189. /**
  65190. * The x coefficients of the spherical polynomial
  65191. */
  65192. x: Vector3;
  65193. /**
  65194. * The y coefficients of the spherical polynomial
  65195. */
  65196. y: Vector3;
  65197. /**
  65198. * The z coefficients of the spherical polynomial
  65199. */
  65200. z: Vector3;
  65201. /**
  65202. * The xx coefficients of the spherical polynomial
  65203. */
  65204. xx: Vector3;
  65205. /**
  65206. * The yy coefficients of the spherical polynomial
  65207. */
  65208. yy: Vector3;
  65209. /**
  65210. * The zz coefficients of the spherical polynomial
  65211. */
  65212. zz: Vector3;
  65213. /**
  65214. * The xy coefficients of the spherical polynomial
  65215. */
  65216. xy: Vector3;
  65217. /**
  65218. * The yz coefficients of the spherical polynomial
  65219. */
  65220. yz: Vector3;
  65221. /**
  65222. * The zx coefficients of the spherical polynomial
  65223. */
  65224. zx: Vector3;
  65225. /**
  65226. * Adds an ambient color to the spherical polynomial
  65227. * @param color the color to add
  65228. */
  65229. addAmbient(color: Color3): void;
  65230. /**
  65231. * Scales the spherical polynomial by the given amount
  65232. * @param scale the amount to scale
  65233. */
  65234. scale(scale: number): void;
  65235. /**
  65236. * Gets the spherical polynomial from harmonics
  65237. * @param harmonics the spherical harmonics
  65238. * @returns the spherical polynomial
  65239. */
  65240. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65241. /**
  65242. * Constructs a spherical polynomial from an array.
  65243. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65244. * @returns the spherical polynomial
  65245. */
  65246. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65247. }
  65248. /**
  65249. * Class representing spherical harmonics coefficients to the 3rd degree
  65250. */
  65251. export class SphericalHarmonics {
  65252. /**
  65253. * The l0,0 coefficients of the spherical harmonics
  65254. */
  65255. l00: Vector3;
  65256. /**
  65257. * The l1,-1 coefficients of the spherical harmonics
  65258. */
  65259. l1_1: Vector3;
  65260. /**
  65261. * The l1,0 coefficients of the spherical harmonics
  65262. */
  65263. l10: Vector3;
  65264. /**
  65265. * The l1,1 coefficients of the spherical harmonics
  65266. */
  65267. l11: Vector3;
  65268. /**
  65269. * The l2,-2 coefficients of the spherical harmonics
  65270. */
  65271. l2_2: Vector3;
  65272. /**
  65273. * The l2,-1 coefficients of the spherical harmonics
  65274. */
  65275. l2_1: Vector3;
  65276. /**
  65277. * The l2,0 coefficients of the spherical harmonics
  65278. */
  65279. l20: Vector3;
  65280. /**
  65281. * The l2,1 coefficients of the spherical harmonics
  65282. */
  65283. l21: Vector3;
  65284. /**
  65285. * The l2,2 coefficients of the spherical harmonics
  65286. */
  65287. lL22: Vector3;
  65288. /**
  65289. * Adds a light to the spherical harmonics
  65290. * @param direction the direction of the light
  65291. * @param color the color of the light
  65292. * @param deltaSolidAngle the delta solid angle of the light
  65293. */
  65294. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65295. /**
  65296. * Scales the spherical harmonics by the given amount
  65297. * @param scale the amount to scale
  65298. */
  65299. scale(scale: number): void;
  65300. /**
  65301. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65302. *
  65303. * ```
  65304. * E_lm = A_l * L_lm
  65305. * ```
  65306. *
  65307. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65308. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65309. * the scaling factors are given in equation 9.
  65310. */
  65311. convertIncidentRadianceToIrradiance(): void;
  65312. /**
  65313. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65314. *
  65315. * ```
  65316. * L = (1/pi) * E * rho
  65317. * ```
  65318. *
  65319. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65320. */
  65321. convertIrradianceToLambertianRadiance(): void;
  65322. /**
  65323. * Gets the spherical harmonics from polynomial
  65324. * @param polynomial the spherical polynomial
  65325. * @returns the spherical harmonics
  65326. */
  65327. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65328. /**
  65329. * Constructs a spherical harmonics from an array.
  65330. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65331. * @returns the spherical harmonics
  65332. */
  65333. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65334. }
  65335. }
  65336. declare module BABYLON {
  65337. /**
  65338. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65339. */
  65340. export interface CubeMapInfo {
  65341. /**
  65342. * The pixel array for the front face.
  65343. * This is stored in format, left to right, up to down format.
  65344. */
  65345. front: Nullable<ArrayBufferView>;
  65346. /**
  65347. * The pixel array for the back face.
  65348. * This is stored in format, left to right, up to down format.
  65349. */
  65350. back: Nullable<ArrayBufferView>;
  65351. /**
  65352. * The pixel array for the left face.
  65353. * This is stored in format, left to right, up to down format.
  65354. */
  65355. left: Nullable<ArrayBufferView>;
  65356. /**
  65357. * The pixel array for the right face.
  65358. * This is stored in format, left to right, up to down format.
  65359. */
  65360. right: Nullable<ArrayBufferView>;
  65361. /**
  65362. * The pixel array for the up face.
  65363. * This is stored in format, left to right, up to down format.
  65364. */
  65365. up: Nullable<ArrayBufferView>;
  65366. /**
  65367. * The pixel array for the down face.
  65368. * This is stored in format, left to right, up to down format.
  65369. */
  65370. down: Nullable<ArrayBufferView>;
  65371. /**
  65372. * The size of the cubemap stored.
  65373. *
  65374. * Each faces will be size * size pixels.
  65375. */
  65376. size: number;
  65377. /**
  65378. * The format of the texture.
  65379. *
  65380. * RGBA, RGB.
  65381. */
  65382. format: number;
  65383. /**
  65384. * The type of the texture data.
  65385. *
  65386. * UNSIGNED_INT, FLOAT.
  65387. */
  65388. type: number;
  65389. /**
  65390. * Specifies whether the texture is in gamma space.
  65391. */
  65392. gammaSpace: boolean;
  65393. }
  65394. /**
  65395. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65396. */
  65397. export class PanoramaToCubeMapTools {
  65398. private static FACE_FRONT;
  65399. private static FACE_BACK;
  65400. private static FACE_RIGHT;
  65401. private static FACE_LEFT;
  65402. private static FACE_DOWN;
  65403. private static FACE_UP;
  65404. /**
  65405. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65406. *
  65407. * @param float32Array The source data.
  65408. * @param inputWidth The width of the input panorama.
  65409. * @param inputHeight The height of the input panorama.
  65410. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65411. * @return The cubemap data
  65412. */
  65413. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65414. private static CreateCubemapTexture;
  65415. private static CalcProjectionSpherical;
  65416. }
  65417. }
  65418. declare module BABYLON {
  65419. /**
  65420. * Helper class dealing with the extraction of spherical polynomial dataArray
  65421. * from a cube map.
  65422. */
  65423. export class CubeMapToSphericalPolynomialTools {
  65424. private static FileFaces;
  65425. /**
  65426. * Converts a texture to the according Spherical Polynomial data.
  65427. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65428. *
  65429. * @param texture The texture to extract the information from.
  65430. * @return The Spherical Polynomial data.
  65431. */
  65432. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65433. /**
  65434. * Converts a cubemap to the according Spherical Polynomial data.
  65435. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65436. *
  65437. * @param cubeInfo The Cube map to extract the information from.
  65438. * @return The Spherical Polynomial data.
  65439. */
  65440. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65441. }
  65442. }
  65443. declare module BABYLON {
  65444. /**
  65445. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65446. * during the life time of the application.
  65447. */
  65448. export class EngineStore {
  65449. /** Gets the list of created engines */
  65450. static Instances: Engine[];
  65451. /**
  65452. * Gets the latest created engine
  65453. */
  65454. static readonly LastCreatedEngine: Nullable<Engine>;
  65455. /**
  65456. * Gets the latest created scene
  65457. */
  65458. static readonly LastCreatedScene: Nullable<Scene>;
  65459. }
  65460. }
  65461. declare module BABYLON {
  65462. /**
  65463. * Define options used to create a render target texture
  65464. */
  65465. export class RenderTargetCreationOptions {
  65466. /**
  65467. * Specifies is mipmaps must be generated
  65468. */
  65469. generateMipMaps?: boolean;
  65470. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65471. generateDepthBuffer?: boolean;
  65472. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65473. generateStencilBuffer?: boolean;
  65474. /** Defines texture type (int by default) */
  65475. type?: number;
  65476. /** Defines sampling mode (trilinear by default) */
  65477. samplingMode?: number;
  65478. /** Defines format (RGBA by default) */
  65479. format?: number;
  65480. }
  65481. }
  65482. declare module BABYLON {
  65483. /**
  65484. * @hidden
  65485. **/
  65486. export class _AlphaState {
  65487. private _isAlphaBlendDirty;
  65488. private _isBlendFunctionParametersDirty;
  65489. private _isBlendEquationParametersDirty;
  65490. private _isBlendConstantsDirty;
  65491. private _alphaBlend;
  65492. private _blendFunctionParameters;
  65493. private _blendEquationParameters;
  65494. private _blendConstants;
  65495. /**
  65496. * Initializes the state.
  65497. */
  65498. constructor();
  65499. readonly isDirty: boolean;
  65500. alphaBlend: boolean;
  65501. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65502. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65503. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65504. reset(): void;
  65505. apply(gl: WebGLRenderingContext): void;
  65506. }
  65507. }
  65508. declare module BABYLON {
  65509. /**
  65510. * @hidden
  65511. **/
  65512. export class _DepthCullingState {
  65513. private _isDepthTestDirty;
  65514. private _isDepthMaskDirty;
  65515. private _isDepthFuncDirty;
  65516. private _isCullFaceDirty;
  65517. private _isCullDirty;
  65518. private _isZOffsetDirty;
  65519. private _isFrontFaceDirty;
  65520. private _depthTest;
  65521. private _depthMask;
  65522. private _depthFunc;
  65523. private _cull;
  65524. private _cullFace;
  65525. private _zOffset;
  65526. private _frontFace;
  65527. /**
  65528. * Initializes the state.
  65529. */
  65530. constructor();
  65531. readonly isDirty: boolean;
  65532. zOffset: number;
  65533. cullFace: Nullable<number>;
  65534. cull: Nullable<boolean>;
  65535. depthFunc: Nullable<number>;
  65536. depthMask: boolean;
  65537. depthTest: boolean;
  65538. frontFace: Nullable<number>;
  65539. reset(): void;
  65540. apply(gl: WebGLRenderingContext): void;
  65541. }
  65542. }
  65543. declare module BABYLON {
  65544. /**
  65545. * @hidden
  65546. **/
  65547. export class _StencilState {
  65548. /** 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 */
  65549. static readonly ALWAYS: number;
  65550. /** Passed to stencilOperation to specify that stencil value must be kept */
  65551. static readonly KEEP: number;
  65552. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65553. static readonly REPLACE: number;
  65554. private _isStencilTestDirty;
  65555. private _isStencilMaskDirty;
  65556. private _isStencilFuncDirty;
  65557. private _isStencilOpDirty;
  65558. private _stencilTest;
  65559. private _stencilMask;
  65560. private _stencilFunc;
  65561. private _stencilFuncRef;
  65562. private _stencilFuncMask;
  65563. private _stencilOpStencilFail;
  65564. private _stencilOpDepthFail;
  65565. private _stencilOpStencilDepthPass;
  65566. readonly isDirty: boolean;
  65567. stencilFunc: number;
  65568. stencilFuncRef: number;
  65569. stencilFuncMask: number;
  65570. stencilOpStencilFail: number;
  65571. stencilOpDepthFail: number;
  65572. stencilOpStencilDepthPass: number;
  65573. stencilMask: number;
  65574. stencilTest: boolean;
  65575. constructor();
  65576. reset(): void;
  65577. apply(gl: WebGLRenderingContext): void;
  65578. }
  65579. }
  65580. declare module BABYLON {
  65581. /**
  65582. * @hidden
  65583. **/
  65584. export class _TimeToken {
  65585. _startTimeQuery: Nullable<WebGLQuery>;
  65586. _endTimeQuery: Nullable<WebGLQuery>;
  65587. _timeElapsedQuery: Nullable<WebGLQuery>;
  65588. _timeElapsedQueryEnded: boolean;
  65589. }
  65590. }
  65591. declare module BABYLON {
  65592. /**
  65593. * Class used to store data associated with WebGL texture data for the engine
  65594. * This class should not be used directly
  65595. */
  65596. export class InternalTexture {
  65597. /** hidden */
  65598. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65599. /**
  65600. * The source of the texture data is unknown
  65601. */
  65602. static DATASOURCE_UNKNOWN: number;
  65603. /**
  65604. * Texture data comes from an URL
  65605. */
  65606. static DATASOURCE_URL: number;
  65607. /**
  65608. * Texture data is only used for temporary storage
  65609. */
  65610. static DATASOURCE_TEMP: number;
  65611. /**
  65612. * Texture data comes from raw data (ArrayBuffer)
  65613. */
  65614. static DATASOURCE_RAW: number;
  65615. /**
  65616. * Texture content is dynamic (video or dynamic texture)
  65617. */
  65618. static DATASOURCE_DYNAMIC: number;
  65619. /**
  65620. * Texture content is generated by rendering to it
  65621. */
  65622. static DATASOURCE_RENDERTARGET: number;
  65623. /**
  65624. * Texture content is part of a multi render target process
  65625. */
  65626. static DATASOURCE_MULTIRENDERTARGET: number;
  65627. /**
  65628. * Texture data comes from a cube data file
  65629. */
  65630. static DATASOURCE_CUBE: number;
  65631. /**
  65632. * Texture data comes from a raw cube data
  65633. */
  65634. static DATASOURCE_CUBERAW: number;
  65635. /**
  65636. * Texture data come from a prefiltered cube data file
  65637. */
  65638. static DATASOURCE_CUBEPREFILTERED: number;
  65639. /**
  65640. * Texture content is raw 3D data
  65641. */
  65642. static DATASOURCE_RAW3D: number;
  65643. /**
  65644. * Texture content is a depth texture
  65645. */
  65646. static DATASOURCE_DEPTHTEXTURE: number;
  65647. /**
  65648. * Texture data comes from a raw cube data encoded with RGBD
  65649. */
  65650. static DATASOURCE_CUBERAW_RGBD: number;
  65651. /**
  65652. * Defines if the texture is ready
  65653. */
  65654. isReady: boolean;
  65655. /**
  65656. * Defines if the texture is a cube texture
  65657. */
  65658. isCube: boolean;
  65659. /**
  65660. * Defines if the texture contains 3D data
  65661. */
  65662. is3D: boolean;
  65663. /**
  65664. * Defines if the texture contains multiview data
  65665. */
  65666. isMultiview: boolean;
  65667. /**
  65668. * Gets the URL used to load this texture
  65669. */
  65670. url: string;
  65671. /**
  65672. * Gets the sampling mode of the texture
  65673. */
  65674. samplingMode: number;
  65675. /**
  65676. * Gets a boolean indicating if the texture needs mipmaps generation
  65677. */
  65678. generateMipMaps: boolean;
  65679. /**
  65680. * Gets the number of samples used by the texture (WebGL2+ only)
  65681. */
  65682. samples: number;
  65683. /**
  65684. * Gets the type of the texture (int, float...)
  65685. */
  65686. type: number;
  65687. /**
  65688. * Gets the format of the texture (RGB, RGBA...)
  65689. */
  65690. format: number;
  65691. /**
  65692. * Observable called when the texture is loaded
  65693. */
  65694. onLoadedObservable: Observable<InternalTexture>;
  65695. /**
  65696. * Gets the width of the texture
  65697. */
  65698. width: number;
  65699. /**
  65700. * Gets the height of the texture
  65701. */
  65702. height: number;
  65703. /**
  65704. * Gets the depth of the texture
  65705. */
  65706. depth: number;
  65707. /**
  65708. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  65709. */
  65710. baseWidth: number;
  65711. /**
  65712. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  65713. */
  65714. baseHeight: number;
  65715. /**
  65716. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  65717. */
  65718. baseDepth: number;
  65719. /**
  65720. * Gets a boolean indicating if the texture is inverted on Y axis
  65721. */
  65722. invertY: boolean;
  65723. /** @hidden */
  65724. _invertVScale: boolean;
  65725. /** @hidden */
  65726. _associatedChannel: number;
  65727. /** @hidden */
  65728. _dataSource: number;
  65729. /** @hidden */
  65730. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  65731. /** @hidden */
  65732. _bufferView: Nullable<ArrayBufferView>;
  65733. /** @hidden */
  65734. _bufferViewArray: Nullable<ArrayBufferView[]>;
  65735. /** @hidden */
  65736. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  65737. /** @hidden */
  65738. _size: number;
  65739. /** @hidden */
  65740. _extension: string;
  65741. /** @hidden */
  65742. _files: Nullable<string[]>;
  65743. /** @hidden */
  65744. _workingCanvas: HTMLCanvasElement;
  65745. /** @hidden */
  65746. _workingContext: CanvasRenderingContext2D;
  65747. /** @hidden */
  65748. _framebuffer: Nullable<WebGLFramebuffer>;
  65749. /** @hidden */
  65750. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  65751. /** @hidden */
  65752. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65753. /** @hidden */
  65754. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65755. /** @hidden */
  65756. _attachments: Nullable<number[]>;
  65757. /** @hidden */
  65758. _cachedCoordinatesMode: Nullable<number>;
  65759. /** @hidden */
  65760. _cachedWrapU: Nullable<number>;
  65761. /** @hidden */
  65762. _cachedWrapV: Nullable<number>;
  65763. /** @hidden */
  65764. _cachedWrapR: Nullable<number>;
  65765. /** @hidden */
  65766. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65767. /** @hidden */
  65768. _isDisabled: boolean;
  65769. /** @hidden */
  65770. _compression: Nullable<string>;
  65771. /** @hidden */
  65772. _generateStencilBuffer: boolean;
  65773. /** @hidden */
  65774. _generateDepthBuffer: boolean;
  65775. /** @hidden */
  65776. _comparisonFunction: number;
  65777. /** @hidden */
  65778. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65779. /** @hidden */
  65780. _lodGenerationScale: number;
  65781. /** @hidden */
  65782. _lodGenerationOffset: number;
  65783. /** @hidden */
  65784. _colorTextureArray: Nullable<WebGLTexture>;
  65785. /** @hidden */
  65786. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65787. /** @hidden */
  65788. _lodTextureHigh: BaseTexture;
  65789. /** @hidden */
  65790. _lodTextureMid: BaseTexture;
  65791. /** @hidden */
  65792. _lodTextureLow: BaseTexture;
  65793. /** @hidden */
  65794. _isRGBD: boolean;
  65795. /** @hidden */
  65796. _webGLTexture: Nullable<WebGLTexture>;
  65797. /** @hidden */
  65798. _references: number;
  65799. private _engine;
  65800. /**
  65801. * Gets the Engine the texture belongs to.
  65802. * @returns The babylon engine
  65803. */
  65804. getEngine(): Engine;
  65805. /**
  65806. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65807. */
  65808. readonly dataSource: number;
  65809. /**
  65810. * Creates a new InternalTexture
  65811. * @param engine defines the engine to use
  65812. * @param dataSource defines the type of data that will be used
  65813. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65814. */
  65815. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65816. /**
  65817. * Increments the number of references (ie. the number of Texture that point to it)
  65818. */
  65819. incrementReferences(): void;
  65820. /**
  65821. * Change the size of the texture (not the size of the content)
  65822. * @param width defines the new width
  65823. * @param height defines the new height
  65824. * @param depth defines the new depth (1 by default)
  65825. */
  65826. updateSize(width: int, height: int, depth?: int): void;
  65827. /** @hidden */
  65828. _rebuild(): void;
  65829. /** @hidden */
  65830. _swapAndDie(target: InternalTexture): void;
  65831. /**
  65832. * Dispose the current allocated resources
  65833. */
  65834. dispose(): void;
  65835. }
  65836. }
  65837. declare module BABYLON {
  65838. /**
  65839. * This represents the main contract an easing function should follow.
  65840. * Easing functions are used throughout the animation system.
  65841. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65842. */
  65843. export interface IEasingFunction {
  65844. /**
  65845. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65846. * of the easing function.
  65847. * The link below provides some of the most common examples of easing functions.
  65848. * @see https://easings.net/
  65849. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65850. * @returns the corresponding value on the curve defined by the easing function
  65851. */
  65852. ease(gradient: number): number;
  65853. }
  65854. /**
  65855. * Base class used for every default easing function.
  65856. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65857. */
  65858. export class EasingFunction implements IEasingFunction {
  65859. /**
  65860. * Interpolation follows the mathematical formula associated with the easing function.
  65861. */
  65862. static readonly EASINGMODE_EASEIN: number;
  65863. /**
  65864. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  65865. */
  65866. static readonly EASINGMODE_EASEOUT: number;
  65867. /**
  65868. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  65869. */
  65870. static readonly EASINGMODE_EASEINOUT: number;
  65871. private _easingMode;
  65872. /**
  65873. * Sets the easing mode of the current function.
  65874. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  65875. */
  65876. setEasingMode(easingMode: number): void;
  65877. /**
  65878. * Gets the current easing mode.
  65879. * @returns the easing mode
  65880. */
  65881. getEasingMode(): number;
  65882. /**
  65883. * @hidden
  65884. */
  65885. easeInCore(gradient: number): number;
  65886. /**
  65887. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65888. * of the easing function.
  65889. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65890. * @returns the corresponding value on the curve defined by the easing function
  65891. */
  65892. ease(gradient: number): number;
  65893. }
  65894. /**
  65895. * Easing function with a circle shape (see link below).
  65896. * @see https://easings.net/#easeInCirc
  65897. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65898. */
  65899. export class CircleEase extends EasingFunction implements IEasingFunction {
  65900. /** @hidden */
  65901. easeInCore(gradient: number): number;
  65902. }
  65903. /**
  65904. * Easing function with a ease back shape (see link below).
  65905. * @see https://easings.net/#easeInBack
  65906. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65907. */
  65908. export class BackEase extends EasingFunction implements IEasingFunction {
  65909. /** Defines the amplitude of the function */
  65910. amplitude: number;
  65911. /**
  65912. * Instantiates a back ease easing
  65913. * @see https://easings.net/#easeInBack
  65914. * @param amplitude Defines the amplitude of the function
  65915. */
  65916. constructor(
  65917. /** Defines the amplitude of the function */
  65918. amplitude?: number);
  65919. /** @hidden */
  65920. easeInCore(gradient: number): number;
  65921. }
  65922. /**
  65923. * Easing function with a bouncing shape (see link below).
  65924. * @see https://easings.net/#easeInBounce
  65925. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65926. */
  65927. export class BounceEase extends EasingFunction implements IEasingFunction {
  65928. /** Defines the number of bounces */
  65929. bounces: number;
  65930. /** Defines the amplitude of the bounce */
  65931. bounciness: number;
  65932. /**
  65933. * Instantiates a bounce easing
  65934. * @see https://easings.net/#easeInBounce
  65935. * @param bounces Defines the number of bounces
  65936. * @param bounciness Defines the amplitude of the bounce
  65937. */
  65938. constructor(
  65939. /** Defines the number of bounces */
  65940. bounces?: number,
  65941. /** Defines the amplitude of the bounce */
  65942. bounciness?: number);
  65943. /** @hidden */
  65944. easeInCore(gradient: number): number;
  65945. }
  65946. /**
  65947. * Easing function with a power of 3 shape (see link below).
  65948. * @see https://easings.net/#easeInCubic
  65949. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65950. */
  65951. export class CubicEase extends EasingFunction implements IEasingFunction {
  65952. /** @hidden */
  65953. easeInCore(gradient: number): number;
  65954. }
  65955. /**
  65956. * Easing function with an elastic shape (see link below).
  65957. * @see https://easings.net/#easeInElastic
  65958. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65959. */
  65960. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65961. /** Defines the number of oscillations*/
  65962. oscillations: number;
  65963. /** Defines the amplitude of the oscillations*/
  65964. springiness: number;
  65965. /**
  65966. * Instantiates an elastic easing function
  65967. * @see https://easings.net/#easeInElastic
  65968. * @param oscillations Defines the number of oscillations
  65969. * @param springiness Defines the amplitude of the oscillations
  65970. */
  65971. constructor(
  65972. /** Defines the number of oscillations*/
  65973. oscillations?: number,
  65974. /** Defines the amplitude of the oscillations*/
  65975. springiness?: number);
  65976. /** @hidden */
  65977. easeInCore(gradient: number): number;
  65978. }
  65979. /**
  65980. * Easing function with an exponential shape (see link below).
  65981. * @see https://easings.net/#easeInExpo
  65982. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65983. */
  65984. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65985. /** Defines the exponent of the function */
  65986. exponent: number;
  65987. /**
  65988. * Instantiates an exponential easing function
  65989. * @see https://easings.net/#easeInExpo
  65990. * @param exponent Defines the exponent of the function
  65991. */
  65992. constructor(
  65993. /** Defines the exponent of the function */
  65994. exponent?: number);
  65995. /** @hidden */
  65996. easeInCore(gradient: number): number;
  65997. }
  65998. /**
  65999. * Easing function with a power shape (see link below).
  66000. * @see https://easings.net/#easeInQuad
  66001. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66002. */
  66003. export class PowerEase extends EasingFunction implements IEasingFunction {
  66004. /** Defines the power of the function */
  66005. power: number;
  66006. /**
  66007. * Instantiates an power base easing function
  66008. * @see https://easings.net/#easeInQuad
  66009. * @param power Defines the power of the function
  66010. */
  66011. constructor(
  66012. /** Defines the power of the function */
  66013. power?: number);
  66014. /** @hidden */
  66015. easeInCore(gradient: number): number;
  66016. }
  66017. /**
  66018. * Easing function with a power of 2 shape (see link below).
  66019. * @see https://easings.net/#easeInQuad
  66020. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66021. */
  66022. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66023. /** @hidden */
  66024. easeInCore(gradient: number): number;
  66025. }
  66026. /**
  66027. * Easing function with a power of 4 shape (see link below).
  66028. * @see https://easings.net/#easeInQuart
  66029. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66030. */
  66031. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66032. /** @hidden */
  66033. easeInCore(gradient: number): number;
  66034. }
  66035. /**
  66036. * Easing function with a power of 5 shape (see link below).
  66037. * @see https://easings.net/#easeInQuint
  66038. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66039. */
  66040. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66041. /** @hidden */
  66042. easeInCore(gradient: number): number;
  66043. }
  66044. /**
  66045. * Easing function with a sin shape (see link below).
  66046. * @see https://easings.net/#easeInSine
  66047. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66048. */
  66049. export class SineEase extends EasingFunction implements IEasingFunction {
  66050. /** @hidden */
  66051. easeInCore(gradient: number): number;
  66052. }
  66053. /**
  66054. * Easing function with a bezier shape (see link below).
  66055. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66056. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66057. */
  66058. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66059. /** Defines the x component of the start tangent in the bezier curve */
  66060. x1: number;
  66061. /** Defines the y component of the start tangent in the bezier curve */
  66062. y1: number;
  66063. /** Defines the x component of the end tangent in the bezier curve */
  66064. x2: number;
  66065. /** Defines the y component of the end tangent in the bezier curve */
  66066. y2: number;
  66067. /**
  66068. * Instantiates a bezier function
  66069. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66070. * @param x1 Defines the x component of the start tangent in the bezier curve
  66071. * @param y1 Defines the y component of the start tangent in the bezier curve
  66072. * @param x2 Defines the x component of the end tangent in the bezier curve
  66073. * @param y2 Defines the y component of the end tangent in the bezier curve
  66074. */
  66075. constructor(
  66076. /** Defines the x component of the start tangent in the bezier curve */
  66077. x1?: number,
  66078. /** Defines the y component of the start tangent in the bezier curve */
  66079. y1?: number,
  66080. /** Defines the x component of the end tangent in the bezier curve */
  66081. x2?: number,
  66082. /** Defines the y component of the end tangent in the bezier curve */
  66083. y2?: number);
  66084. /** @hidden */
  66085. easeInCore(gradient: number): number;
  66086. }
  66087. }
  66088. declare module BABYLON {
  66089. /**
  66090. * Defines an interface which represents an animation key frame
  66091. */
  66092. export interface IAnimationKey {
  66093. /**
  66094. * Frame of the key frame
  66095. */
  66096. frame: number;
  66097. /**
  66098. * Value at the specifies key frame
  66099. */
  66100. value: any;
  66101. /**
  66102. * The input tangent for the cubic hermite spline
  66103. */
  66104. inTangent?: any;
  66105. /**
  66106. * The output tangent for the cubic hermite spline
  66107. */
  66108. outTangent?: any;
  66109. /**
  66110. * The animation interpolation type
  66111. */
  66112. interpolation?: AnimationKeyInterpolation;
  66113. }
  66114. /**
  66115. * Enum for the animation key frame interpolation type
  66116. */
  66117. export enum AnimationKeyInterpolation {
  66118. /**
  66119. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66120. */
  66121. STEP = 1
  66122. }
  66123. }
  66124. declare module BABYLON {
  66125. /**
  66126. * Represents the range of an animation
  66127. */
  66128. export class AnimationRange {
  66129. /**The name of the animation range**/
  66130. name: string;
  66131. /**The starting frame of the animation */
  66132. from: number;
  66133. /**The ending frame of the animation*/
  66134. to: number;
  66135. /**
  66136. * Initializes the range of an animation
  66137. * @param name The name of the animation range
  66138. * @param from The starting frame of the animation
  66139. * @param to The ending frame of the animation
  66140. */
  66141. constructor(
  66142. /**The name of the animation range**/
  66143. name: string,
  66144. /**The starting frame of the animation */
  66145. from: number,
  66146. /**The ending frame of the animation*/
  66147. to: number);
  66148. /**
  66149. * Makes a copy of the animation range
  66150. * @returns A copy of the animation range
  66151. */
  66152. clone(): AnimationRange;
  66153. }
  66154. }
  66155. declare module BABYLON {
  66156. /**
  66157. * Composed of a frame, and an action function
  66158. */
  66159. export class AnimationEvent {
  66160. /** The frame for which the event is triggered **/
  66161. frame: number;
  66162. /** The event to perform when triggered **/
  66163. action: (currentFrame: number) => void;
  66164. /** Specifies if the event should be triggered only once**/
  66165. onlyOnce?: boolean | undefined;
  66166. /**
  66167. * Specifies if the animation event is done
  66168. */
  66169. isDone: boolean;
  66170. /**
  66171. * Initializes the animation event
  66172. * @param frame The frame for which the event is triggered
  66173. * @param action The event to perform when triggered
  66174. * @param onlyOnce Specifies if the event should be triggered only once
  66175. */
  66176. constructor(
  66177. /** The frame for which the event is triggered **/
  66178. frame: number,
  66179. /** The event to perform when triggered **/
  66180. action: (currentFrame: number) => void,
  66181. /** Specifies if the event should be triggered only once**/
  66182. onlyOnce?: boolean | undefined);
  66183. /** @hidden */
  66184. _clone(): AnimationEvent;
  66185. }
  66186. }
  66187. declare module BABYLON {
  66188. /**
  66189. * Interface used to define a behavior
  66190. */
  66191. export interface Behavior<T> {
  66192. /** gets or sets behavior's name */
  66193. name: string;
  66194. /**
  66195. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66196. */
  66197. init(): void;
  66198. /**
  66199. * Called when the behavior is attached to a target
  66200. * @param target defines the target where the behavior is attached to
  66201. */
  66202. attach(target: T): void;
  66203. /**
  66204. * Called when the behavior is detached from its target
  66205. */
  66206. detach(): void;
  66207. }
  66208. /**
  66209. * Interface implemented by classes supporting behaviors
  66210. */
  66211. export interface IBehaviorAware<T> {
  66212. /**
  66213. * Attach a behavior
  66214. * @param behavior defines the behavior to attach
  66215. * @returns the current host
  66216. */
  66217. addBehavior(behavior: Behavior<T>): T;
  66218. /**
  66219. * Remove a behavior from the current object
  66220. * @param behavior defines the behavior to detach
  66221. * @returns the current host
  66222. */
  66223. removeBehavior(behavior: Behavior<T>): T;
  66224. /**
  66225. * Gets a behavior using its name to search
  66226. * @param name defines the name to search
  66227. * @returns the behavior or null if not found
  66228. */
  66229. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66230. }
  66231. }
  66232. declare module BABYLON {
  66233. /**
  66234. * @hidden
  66235. */
  66236. export class IntersectionInfo {
  66237. bu: Nullable<number>;
  66238. bv: Nullable<number>;
  66239. distance: number;
  66240. faceId: number;
  66241. subMeshId: number;
  66242. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66243. }
  66244. }
  66245. declare module BABYLON {
  66246. /**
  66247. * Class used to store bounding sphere information
  66248. */
  66249. export class BoundingSphere {
  66250. /**
  66251. * Gets the center of the bounding sphere in local space
  66252. */
  66253. readonly center: Vector3;
  66254. /**
  66255. * Radius of the bounding sphere in local space
  66256. */
  66257. radius: number;
  66258. /**
  66259. * Gets the center of the bounding sphere in world space
  66260. */
  66261. readonly centerWorld: Vector3;
  66262. /**
  66263. * Radius of the bounding sphere in world space
  66264. */
  66265. radiusWorld: number;
  66266. /**
  66267. * Gets the minimum vector in local space
  66268. */
  66269. readonly minimum: Vector3;
  66270. /**
  66271. * Gets the maximum vector in local space
  66272. */
  66273. readonly maximum: Vector3;
  66274. private _worldMatrix;
  66275. private static readonly TmpVector3;
  66276. /**
  66277. * Creates a new bounding sphere
  66278. * @param min defines the minimum vector (in local space)
  66279. * @param max defines the maximum vector (in local space)
  66280. * @param worldMatrix defines the new world matrix
  66281. */
  66282. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66283. /**
  66284. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66285. * @param min defines the new minimum vector (in local space)
  66286. * @param max defines the new maximum vector (in local space)
  66287. * @param worldMatrix defines the new world matrix
  66288. */
  66289. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66290. /**
  66291. * Scale the current bounding sphere by applying a scale factor
  66292. * @param factor defines the scale factor to apply
  66293. * @returns the current bounding box
  66294. */
  66295. scale(factor: number): BoundingSphere;
  66296. /**
  66297. * Gets the world matrix of the bounding box
  66298. * @returns a matrix
  66299. */
  66300. getWorldMatrix(): DeepImmutable<Matrix>;
  66301. /** @hidden */
  66302. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66303. /**
  66304. * Tests if the bounding sphere is intersecting the frustum planes
  66305. * @param frustumPlanes defines the frustum planes to test
  66306. * @returns true if there is an intersection
  66307. */
  66308. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66309. /**
  66310. * Tests if the bounding sphere center is in between the frustum planes.
  66311. * Used for optimistic fast inclusion.
  66312. * @param frustumPlanes defines the frustum planes to test
  66313. * @returns true if the sphere center is in between the frustum planes
  66314. */
  66315. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66316. /**
  66317. * Tests if a point is inside the bounding sphere
  66318. * @param point defines the point to test
  66319. * @returns true if the point is inside the bounding sphere
  66320. */
  66321. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66322. /**
  66323. * Checks if two sphere intersct
  66324. * @param sphere0 sphere 0
  66325. * @param sphere1 sphere 1
  66326. * @returns true if the speres intersect
  66327. */
  66328. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66329. }
  66330. }
  66331. declare module BABYLON {
  66332. /**
  66333. * Class used to store bounding box information
  66334. */
  66335. export class BoundingBox implements ICullable {
  66336. /**
  66337. * Gets the 8 vectors representing the bounding box in local space
  66338. */
  66339. readonly vectors: Vector3[];
  66340. /**
  66341. * Gets the center of the bounding box in local space
  66342. */
  66343. readonly center: Vector3;
  66344. /**
  66345. * Gets the center of the bounding box in world space
  66346. */
  66347. readonly centerWorld: Vector3;
  66348. /**
  66349. * Gets the extend size in local space
  66350. */
  66351. readonly extendSize: Vector3;
  66352. /**
  66353. * Gets the extend size in world space
  66354. */
  66355. readonly extendSizeWorld: Vector3;
  66356. /**
  66357. * Gets the OBB (object bounding box) directions
  66358. */
  66359. readonly directions: Vector3[];
  66360. /**
  66361. * Gets the 8 vectors representing the bounding box in world space
  66362. */
  66363. readonly vectorsWorld: Vector3[];
  66364. /**
  66365. * Gets the minimum vector in world space
  66366. */
  66367. readonly minimumWorld: Vector3;
  66368. /**
  66369. * Gets the maximum vector in world space
  66370. */
  66371. readonly maximumWorld: Vector3;
  66372. /**
  66373. * Gets the minimum vector in local space
  66374. */
  66375. readonly minimum: Vector3;
  66376. /**
  66377. * Gets the maximum vector in local space
  66378. */
  66379. readonly maximum: Vector3;
  66380. private _worldMatrix;
  66381. private static readonly TmpVector3;
  66382. /**
  66383. * @hidden
  66384. */
  66385. _tag: number;
  66386. /**
  66387. * Creates a new bounding box
  66388. * @param min defines the minimum vector (in local space)
  66389. * @param max defines the maximum vector (in local space)
  66390. * @param worldMatrix defines the new world matrix
  66391. */
  66392. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66393. /**
  66394. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66395. * @param min defines the new minimum vector (in local space)
  66396. * @param max defines the new maximum vector (in local space)
  66397. * @param worldMatrix defines the new world matrix
  66398. */
  66399. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66400. /**
  66401. * Scale the current bounding box by applying a scale factor
  66402. * @param factor defines the scale factor to apply
  66403. * @returns the current bounding box
  66404. */
  66405. scale(factor: number): BoundingBox;
  66406. /**
  66407. * Gets the world matrix of the bounding box
  66408. * @returns a matrix
  66409. */
  66410. getWorldMatrix(): DeepImmutable<Matrix>;
  66411. /** @hidden */
  66412. _update(world: DeepImmutable<Matrix>): void;
  66413. /**
  66414. * Tests if the bounding box is intersecting the frustum planes
  66415. * @param frustumPlanes defines the frustum planes to test
  66416. * @returns true if there is an intersection
  66417. */
  66418. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66419. /**
  66420. * Tests if the bounding box is entirely inside the frustum planes
  66421. * @param frustumPlanes defines the frustum planes to test
  66422. * @returns true if there is an inclusion
  66423. */
  66424. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66425. /**
  66426. * Tests if a point is inside the bounding box
  66427. * @param point defines the point to test
  66428. * @returns true if the point is inside the bounding box
  66429. */
  66430. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66431. /**
  66432. * Tests if the bounding box intersects with a bounding sphere
  66433. * @param sphere defines the sphere to test
  66434. * @returns true if there is an intersection
  66435. */
  66436. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66437. /**
  66438. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66439. * @param min defines the min vector to use
  66440. * @param max defines the max vector to use
  66441. * @returns true if there is an intersection
  66442. */
  66443. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66444. /**
  66445. * Tests if two bounding boxes are intersections
  66446. * @param box0 defines the first box to test
  66447. * @param box1 defines the second box to test
  66448. * @returns true if there is an intersection
  66449. */
  66450. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66451. /**
  66452. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66453. * @param minPoint defines the minimum vector of the bounding box
  66454. * @param maxPoint defines the maximum vector of the bounding box
  66455. * @param sphereCenter defines the sphere center
  66456. * @param sphereRadius defines the sphere radius
  66457. * @returns true if there is an intersection
  66458. */
  66459. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66460. /**
  66461. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66462. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66463. * @param frustumPlanes defines the frustum planes to test
  66464. * @return true if there is an inclusion
  66465. */
  66466. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66467. /**
  66468. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66469. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66470. * @param frustumPlanes defines the frustum planes to test
  66471. * @return true if there is an intersection
  66472. */
  66473. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66474. }
  66475. }
  66476. declare module BABYLON {
  66477. /** @hidden */
  66478. export class Collider {
  66479. /** Define if a collision was found */
  66480. collisionFound: boolean;
  66481. /**
  66482. * Define last intersection point in local space
  66483. */
  66484. intersectionPoint: Vector3;
  66485. /**
  66486. * Define last collided mesh
  66487. */
  66488. collidedMesh: Nullable<AbstractMesh>;
  66489. private _collisionPoint;
  66490. private _planeIntersectionPoint;
  66491. private _tempVector;
  66492. private _tempVector2;
  66493. private _tempVector3;
  66494. private _tempVector4;
  66495. private _edge;
  66496. private _baseToVertex;
  66497. private _destinationPoint;
  66498. private _slidePlaneNormal;
  66499. private _displacementVector;
  66500. /** @hidden */
  66501. _radius: Vector3;
  66502. /** @hidden */
  66503. _retry: number;
  66504. private _velocity;
  66505. private _basePoint;
  66506. private _epsilon;
  66507. /** @hidden */
  66508. _velocityWorldLength: number;
  66509. /** @hidden */
  66510. _basePointWorld: Vector3;
  66511. private _velocityWorld;
  66512. private _normalizedVelocity;
  66513. /** @hidden */
  66514. _initialVelocity: Vector3;
  66515. /** @hidden */
  66516. _initialPosition: Vector3;
  66517. private _nearestDistance;
  66518. private _collisionMask;
  66519. collisionMask: number;
  66520. /**
  66521. * Gets the plane normal used to compute the sliding response (in local space)
  66522. */
  66523. readonly slidePlaneNormal: Vector3;
  66524. /** @hidden */
  66525. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66526. /** @hidden */
  66527. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66528. /** @hidden */
  66529. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66530. /** @hidden */
  66531. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66532. /** @hidden */
  66533. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66534. /** @hidden */
  66535. _getResponse(pos: Vector3, vel: Vector3): void;
  66536. }
  66537. }
  66538. declare module BABYLON {
  66539. /**
  66540. * Interface for cullable objects
  66541. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66542. */
  66543. export interface ICullable {
  66544. /**
  66545. * Checks if the object or part of the object is in the frustum
  66546. * @param frustumPlanes Camera near/planes
  66547. * @returns true if the object is in frustum otherwise false
  66548. */
  66549. isInFrustum(frustumPlanes: Plane[]): boolean;
  66550. /**
  66551. * Checks if a cullable object (mesh...) is in the camera frustum
  66552. * Unlike isInFrustum this cheks the full bounding box
  66553. * @param frustumPlanes Camera near/planes
  66554. * @returns true if the object is in frustum otherwise false
  66555. */
  66556. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66557. }
  66558. /**
  66559. * Info for a bounding data of a mesh
  66560. */
  66561. export class BoundingInfo implements ICullable {
  66562. /**
  66563. * Bounding box for the mesh
  66564. */
  66565. readonly boundingBox: BoundingBox;
  66566. /**
  66567. * Bounding sphere for the mesh
  66568. */
  66569. readonly boundingSphere: BoundingSphere;
  66570. private _isLocked;
  66571. private static readonly TmpVector3;
  66572. /**
  66573. * Constructs bounding info
  66574. * @param minimum min vector of the bounding box/sphere
  66575. * @param maximum max vector of the bounding box/sphere
  66576. * @param worldMatrix defines the new world matrix
  66577. */
  66578. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66579. /**
  66580. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66581. * @param min defines the new minimum vector (in local space)
  66582. * @param max defines the new maximum vector (in local space)
  66583. * @param worldMatrix defines the new world matrix
  66584. */
  66585. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66586. /**
  66587. * min vector of the bounding box/sphere
  66588. */
  66589. readonly minimum: Vector3;
  66590. /**
  66591. * max vector of the bounding box/sphere
  66592. */
  66593. readonly maximum: Vector3;
  66594. /**
  66595. * If the info is locked and won't be updated to avoid perf overhead
  66596. */
  66597. isLocked: boolean;
  66598. /**
  66599. * Updates the bounding sphere and box
  66600. * @param world world matrix to be used to update
  66601. */
  66602. update(world: DeepImmutable<Matrix>): void;
  66603. /**
  66604. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66605. * @param center New center of the bounding info
  66606. * @param extend New extend of the bounding info
  66607. * @returns the current bounding info
  66608. */
  66609. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66610. /**
  66611. * Scale the current bounding info by applying a scale factor
  66612. * @param factor defines the scale factor to apply
  66613. * @returns the current bounding info
  66614. */
  66615. scale(factor: number): BoundingInfo;
  66616. /**
  66617. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66618. * @param frustumPlanes defines the frustum to test
  66619. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66620. * @returns true if the bounding info is in the frustum planes
  66621. */
  66622. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66623. /**
  66624. * Gets the world distance between the min and max points of the bounding box
  66625. */
  66626. readonly diagonalLength: number;
  66627. /**
  66628. * Checks if a cullable object (mesh...) is in the camera frustum
  66629. * Unlike isInFrustum this cheks the full bounding box
  66630. * @param frustumPlanes Camera near/planes
  66631. * @returns true if the object is in frustum otherwise false
  66632. */
  66633. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66634. /** @hidden */
  66635. _checkCollision(collider: Collider): boolean;
  66636. /**
  66637. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66638. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66639. * @param point the point to check intersection with
  66640. * @returns if the point intersects
  66641. */
  66642. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66643. /**
  66644. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66645. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66646. * @param boundingInfo the bounding info to check intersection with
  66647. * @param precise if the intersection should be done using OBB
  66648. * @returns if the bounding info intersects
  66649. */
  66650. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66651. }
  66652. }
  66653. declare module BABYLON {
  66654. /**
  66655. * Defines an array and its length.
  66656. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66657. */
  66658. export interface ISmartArrayLike<T> {
  66659. /**
  66660. * The data of the array.
  66661. */
  66662. data: Array<T>;
  66663. /**
  66664. * The active length of the array.
  66665. */
  66666. length: number;
  66667. }
  66668. /**
  66669. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66670. */
  66671. export class SmartArray<T> implements ISmartArrayLike<T> {
  66672. /**
  66673. * The full set of data from the array.
  66674. */
  66675. data: Array<T>;
  66676. /**
  66677. * The active length of the array.
  66678. */
  66679. length: number;
  66680. protected _id: number;
  66681. /**
  66682. * Instantiates a Smart Array.
  66683. * @param capacity defines the default capacity of the array.
  66684. */
  66685. constructor(capacity: number);
  66686. /**
  66687. * Pushes a value at the end of the active data.
  66688. * @param value defines the object to push in the array.
  66689. */
  66690. push(value: T): void;
  66691. /**
  66692. * Iterates over the active data and apply the lambda to them.
  66693. * @param func defines the action to apply on each value.
  66694. */
  66695. forEach(func: (content: T) => void): void;
  66696. /**
  66697. * Sorts the full sets of data.
  66698. * @param compareFn defines the comparison function to apply.
  66699. */
  66700. sort(compareFn: (a: T, b: T) => number): void;
  66701. /**
  66702. * Resets the active data to an empty array.
  66703. */
  66704. reset(): void;
  66705. /**
  66706. * Releases all the data from the array as well as the array.
  66707. */
  66708. dispose(): void;
  66709. /**
  66710. * Concats the active data with a given array.
  66711. * @param array defines the data to concatenate with.
  66712. */
  66713. concat(array: any): void;
  66714. /**
  66715. * Returns the position of a value in the active data.
  66716. * @param value defines the value to find the index for
  66717. * @returns the index if found in the active data otherwise -1
  66718. */
  66719. indexOf(value: T): number;
  66720. /**
  66721. * Returns whether an element is part of the active data.
  66722. * @param value defines the value to look for
  66723. * @returns true if found in the active data otherwise false
  66724. */
  66725. contains(value: T): boolean;
  66726. private static _GlobalId;
  66727. }
  66728. /**
  66729. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66730. * The data in this array can only be present once
  66731. */
  66732. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  66733. private _duplicateId;
  66734. /**
  66735. * Pushes a value at the end of the active data.
  66736. * THIS DOES NOT PREVENT DUPPLICATE DATA
  66737. * @param value defines the object to push in the array.
  66738. */
  66739. push(value: T): void;
  66740. /**
  66741. * Pushes a value at the end of the active data.
  66742. * If the data is already present, it won t be added again
  66743. * @param value defines the object to push in the array.
  66744. * @returns true if added false if it was already present
  66745. */
  66746. pushNoDuplicate(value: T): boolean;
  66747. /**
  66748. * Resets the active data to an empty array.
  66749. */
  66750. reset(): void;
  66751. /**
  66752. * Concats the active data with a given array.
  66753. * This ensures no dupplicate will be present in the result.
  66754. * @param array defines the data to concatenate with.
  66755. */
  66756. concatWithNoDuplicate(array: any): void;
  66757. }
  66758. }
  66759. declare module BABYLON {
  66760. /**
  66761. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66762. * separate meshes. This can be use to improve performances.
  66763. * @see http://doc.babylonjs.com/how_to/multi_materials
  66764. */
  66765. export class MultiMaterial extends Material {
  66766. private _subMaterials;
  66767. /**
  66768. * Gets or Sets the list of Materials used within the multi material.
  66769. * They need to be ordered according to the submeshes order in the associated mesh
  66770. */
  66771. subMaterials: Nullable<Material>[];
  66772. /**
  66773. * Function used to align with Node.getChildren()
  66774. * @returns the list of Materials used within the multi material
  66775. */
  66776. getChildren(): Nullable<Material>[];
  66777. /**
  66778. * Instantiates a new Multi Material
  66779. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66780. * separate meshes. This can be use to improve performances.
  66781. * @see http://doc.babylonjs.com/how_to/multi_materials
  66782. * @param name Define the name in the scene
  66783. * @param scene Define the scene the material belongs to
  66784. */
  66785. constructor(name: string, scene: Scene);
  66786. private _hookArray;
  66787. /**
  66788. * Get one of the submaterial by its index in the submaterials array
  66789. * @param index The index to look the sub material at
  66790. * @returns The Material if the index has been defined
  66791. */
  66792. getSubMaterial(index: number): Nullable<Material>;
  66793. /**
  66794. * Get the list of active textures for the whole sub materials list.
  66795. * @returns All the textures that will be used during the rendering
  66796. */
  66797. getActiveTextures(): BaseTexture[];
  66798. /**
  66799. * Gets the current class name of the material e.g. "MultiMaterial"
  66800. * Mainly use in serialization.
  66801. * @returns the class name
  66802. */
  66803. getClassName(): string;
  66804. /**
  66805. * Checks if the material is ready to render the requested sub mesh
  66806. * @param mesh Define the mesh the submesh belongs to
  66807. * @param subMesh Define the sub mesh to look readyness for
  66808. * @param useInstances Define whether or not the material is used with instances
  66809. * @returns true if ready, otherwise false
  66810. */
  66811. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66812. /**
  66813. * Clones the current material and its related sub materials
  66814. * @param name Define the name of the newly cloned material
  66815. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66816. * @returns the cloned material
  66817. */
  66818. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66819. /**
  66820. * Serializes the materials into a JSON representation.
  66821. * @returns the JSON representation
  66822. */
  66823. serialize(): any;
  66824. /**
  66825. * Dispose the material and release its associated resources
  66826. * @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)
  66827. * @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)
  66828. * @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)
  66829. */
  66830. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66831. /**
  66832. * Creates a MultiMaterial from parsed MultiMaterial data.
  66833. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66834. * @param scene defines the hosting scene
  66835. * @returns a new MultiMaterial
  66836. */
  66837. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66838. }
  66839. }
  66840. declare module BABYLON {
  66841. /**
  66842. * Class used to represent data loading progression
  66843. */
  66844. export class SceneLoaderFlags {
  66845. private static _ForceFullSceneLoadingForIncremental;
  66846. private static _ShowLoadingScreen;
  66847. private static _CleanBoneMatrixWeights;
  66848. private static _loggingLevel;
  66849. /**
  66850. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66851. */
  66852. static ForceFullSceneLoadingForIncremental: boolean;
  66853. /**
  66854. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66855. */
  66856. static ShowLoadingScreen: boolean;
  66857. /**
  66858. * Defines the current logging level (while loading the scene)
  66859. * @ignorenaming
  66860. */
  66861. static loggingLevel: number;
  66862. /**
  66863. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  66864. */
  66865. static CleanBoneMatrixWeights: boolean;
  66866. }
  66867. }
  66868. declare module BABYLON {
  66869. /**
  66870. * 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.
  66871. * @see https://doc.babylonjs.com/how_to/transformnode
  66872. */
  66873. export class TransformNode extends Node {
  66874. /**
  66875. * Object will not rotate to face the camera
  66876. */
  66877. static BILLBOARDMODE_NONE: number;
  66878. /**
  66879. * Object will rotate to face the camera but only on the x axis
  66880. */
  66881. static BILLBOARDMODE_X: number;
  66882. /**
  66883. * Object will rotate to face the camera but only on the y axis
  66884. */
  66885. static BILLBOARDMODE_Y: number;
  66886. /**
  66887. * Object will rotate to face the camera but only on the z axis
  66888. */
  66889. static BILLBOARDMODE_Z: number;
  66890. /**
  66891. * Object will rotate to face the camera
  66892. */
  66893. static BILLBOARDMODE_ALL: number;
  66894. private _forward;
  66895. private _forwardInverted;
  66896. private _up;
  66897. private _right;
  66898. private _rightInverted;
  66899. private _position;
  66900. private _rotation;
  66901. private _rotationQuaternion;
  66902. protected _scaling: Vector3;
  66903. protected _isDirty: boolean;
  66904. private _transformToBoneReferal;
  66905. private _billboardMode;
  66906. /**
  66907. * Gets or sets the billboard mode. Default is 0.
  66908. *
  66909. * | Value | Type | Description |
  66910. * | --- | --- | --- |
  66911. * | 0 | BILLBOARDMODE_NONE | |
  66912. * | 1 | BILLBOARDMODE_X | |
  66913. * | 2 | BILLBOARDMODE_Y | |
  66914. * | 4 | BILLBOARDMODE_Z | |
  66915. * | 7 | BILLBOARDMODE_ALL | |
  66916. *
  66917. */
  66918. billboardMode: number;
  66919. private _preserveParentRotationForBillboard;
  66920. /**
  66921. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  66922. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  66923. */
  66924. preserveParentRotationForBillboard: boolean;
  66925. /**
  66926. * 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
  66927. */
  66928. scalingDeterminant: number;
  66929. private _infiniteDistance;
  66930. /**
  66931. * Gets or sets the distance of the object to max, often used by skybox
  66932. */
  66933. infiniteDistance: boolean;
  66934. /**
  66935. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66936. * By default the system will update normals to compensate
  66937. */
  66938. ignoreNonUniformScaling: boolean;
  66939. /**
  66940. * 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
  66941. */
  66942. reIntegrateRotationIntoRotationQuaternion: boolean;
  66943. /** @hidden */
  66944. _poseMatrix: Matrix;
  66945. /** @hidden */
  66946. _localMatrix: Matrix;
  66947. private _usePivotMatrix;
  66948. private _absolutePosition;
  66949. private _pivotMatrix;
  66950. private _pivotMatrixInverse;
  66951. protected _postMultiplyPivotMatrix: boolean;
  66952. protected _isWorldMatrixFrozen: boolean;
  66953. /** @hidden */
  66954. _indexInSceneTransformNodesArray: number;
  66955. /**
  66956. * An event triggered after the world matrix is updated
  66957. */
  66958. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66959. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66960. /**
  66961. * Gets a string identifying the name of the class
  66962. * @returns "TransformNode" string
  66963. */
  66964. getClassName(): string;
  66965. /**
  66966. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66967. */
  66968. position: Vector3;
  66969. /**
  66970. * 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)).
  66971. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66972. */
  66973. rotation: Vector3;
  66974. /**
  66975. * 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)).
  66976. */
  66977. scaling: Vector3;
  66978. /**
  66979. * 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).
  66980. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66981. */
  66982. rotationQuaternion: Nullable<Quaternion>;
  66983. /**
  66984. * The forward direction of that transform in world space.
  66985. */
  66986. readonly forward: Vector3;
  66987. /**
  66988. * The up direction of that transform in world space.
  66989. */
  66990. readonly up: Vector3;
  66991. /**
  66992. * The right direction of that transform in world space.
  66993. */
  66994. readonly right: Vector3;
  66995. /**
  66996. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66997. * @param matrix the matrix to copy the pose from
  66998. * @returns this TransformNode.
  66999. */
  67000. updatePoseMatrix(matrix: Matrix): TransformNode;
  67001. /**
  67002. * Returns the mesh Pose matrix.
  67003. * @returns the pose matrix
  67004. */
  67005. getPoseMatrix(): Matrix;
  67006. /** @hidden */
  67007. _isSynchronized(): boolean;
  67008. /** @hidden */
  67009. _initCache(): void;
  67010. /**
  67011. * Flag the transform node as dirty (Forcing it to update everything)
  67012. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67013. * @returns this transform node
  67014. */
  67015. markAsDirty(property: string): TransformNode;
  67016. /**
  67017. * Returns the current mesh absolute position.
  67018. * Returns a Vector3.
  67019. */
  67020. readonly absolutePosition: Vector3;
  67021. /**
  67022. * Sets a new matrix to apply before all other transformation
  67023. * @param matrix defines the transform matrix
  67024. * @returns the current TransformNode
  67025. */
  67026. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67027. /**
  67028. * Sets a new pivot matrix to the current node
  67029. * @param matrix defines the new pivot matrix to use
  67030. * @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
  67031. * @returns the current TransformNode
  67032. */
  67033. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67034. /**
  67035. * Returns the mesh pivot matrix.
  67036. * Default : Identity.
  67037. * @returns the matrix
  67038. */
  67039. getPivotMatrix(): Matrix;
  67040. /**
  67041. * Prevents the World matrix to be computed any longer.
  67042. * @returns the TransformNode.
  67043. */
  67044. freezeWorldMatrix(): TransformNode;
  67045. /**
  67046. * Allows back the World matrix computation.
  67047. * @returns the TransformNode.
  67048. */
  67049. unfreezeWorldMatrix(): this;
  67050. /**
  67051. * True if the World matrix has been frozen.
  67052. */
  67053. readonly isWorldMatrixFrozen: boolean;
  67054. /**
  67055. * Retuns the mesh absolute position in the World.
  67056. * @returns a Vector3.
  67057. */
  67058. getAbsolutePosition(): Vector3;
  67059. /**
  67060. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67061. * @param absolutePosition the absolute position to set
  67062. * @returns the TransformNode.
  67063. */
  67064. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67065. /**
  67066. * Sets the mesh position in its local space.
  67067. * @param vector3 the position to set in localspace
  67068. * @returns the TransformNode.
  67069. */
  67070. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67071. /**
  67072. * Returns the mesh position in the local space from the current World matrix values.
  67073. * @returns a new Vector3.
  67074. */
  67075. getPositionExpressedInLocalSpace(): Vector3;
  67076. /**
  67077. * Translates the mesh along the passed Vector3 in its local space.
  67078. * @param vector3 the distance to translate in localspace
  67079. * @returns the TransformNode.
  67080. */
  67081. locallyTranslate(vector3: Vector3): TransformNode;
  67082. private static _lookAtVectorCache;
  67083. /**
  67084. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67085. * @param targetPoint the position (must be in same space as current mesh) to look at
  67086. * @param yawCor optional yaw (y-axis) correction in radians
  67087. * @param pitchCor optional pitch (x-axis) correction in radians
  67088. * @param rollCor optional roll (z-axis) correction in radians
  67089. * @param space the choosen space of the target
  67090. * @returns the TransformNode.
  67091. */
  67092. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67093. /**
  67094. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67095. * This Vector3 is expressed in the World space.
  67096. * @param localAxis axis to rotate
  67097. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67098. */
  67099. getDirection(localAxis: Vector3): Vector3;
  67100. /**
  67101. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67102. * localAxis is expressed in the mesh local space.
  67103. * result is computed in the Wordl space from the mesh World matrix.
  67104. * @param localAxis axis to rotate
  67105. * @param result the resulting transformnode
  67106. * @returns this TransformNode.
  67107. */
  67108. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67109. /**
  67110. * Sets this transform node rotation to the given local axis.
  67111. * @param localAxis the axis in local space
  67112. * @param yawCor optional yaw (y-axis) correction in radians
  67113. * @param pitchCor optional pitch (x-axis) correction in radians
  67114. * @param rollCor optional roll (z-axis) correction in radians
  67115. * @returns this TransformNode
  67116. */
  67117. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67118. /**
  67119. * Sets a new pivot point to the current node
  67120. * @param point defines the new pivot point to use
  67121. * @param space defines if the point is in world or local space (local by default)
  67122. * @returns the current TransformNode
  67123. */
  67124. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67125. /**
  67126. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67127. * @returns the pivot point
  67128. */
  67129. getPivotPoint(): Vector3;
  67130. /**
  67131. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67132. * @param result the vector3 to store the result
  67133. * @returns this TransformNode.
  67134. */
  67135. getPivotPointToRef(result: Vector3): TransformNode;
  67136. /**
  67137. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67138. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67139. */
  67140. getAbsolutePivotPoint(): Vector3;
  67141. /**
  67142. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67143. * @param result vector3 to store the result
  67144. * @returns this TransformNode.
  67145. */
  67146. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67147. /**
  67148. * Defines the passed node as the parent of the current node.
  67149. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67150. * @see https://doc.babylonjs.com/how_to/parenting
  67151. * @param node the node ot set as the parent
  67152. * @returns this TransformNode.
  67153. */
  67154. setParent(node: Nullable<Node>): TransformNode;
  67155. private _nonUniformScaling;
  67156. /**
  67157. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67158. */
  67159. readonly nonUniformScaling: boolean;
  67160. /** @hidden */
  67161. _updateNonUniformScalingState(value: boolean): boolean;
  67162. /**
  67163. * Attach the current TransformNode to another TransformNode associated with a bone
  67164. * @param bone Bone affecting the TransformNode
  67165. * @param affectedTransformNode TransformNode associated with the bone
  67166. * @returns this object
  67167. */
  67168. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67169. /**
  67170. * Detach the transform node if its associated with a bone
  67171. * @returns this object
  67172. */
  67173. detachFromBone(): TransformNode;
  67174. private static _rotationAxisCache;
  67175. /**
  67176. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67177. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67178. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67179. * The passed axis is also normalized.
  67180. * @param axis the axis to rotate around
  67181. * @param amount the amount to rotate in radians
  67182. * @param space Space to rotate in (Default: local)
  67183. * @returns the TransformNode.
  67184. */
  67185. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67186. /**
  67187. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67188. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67189. * The passed axis is also normalized. .
  67190. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67191. * @param point the point to rotate around
  67192. * @param axis the axis to rotate around
  67193. * @param amount the amount to rotate in radians
  67194. * @returns the TransformNode
  67195. */
  67196. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67197. /**
  67198. * Translates the mesh along the axis vector for the passed distance in the given space.
  67199. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67200. * @param axis the axis to translate in
  67201. * @param distance the distance to translate
  67202. * @param space Space to rotate in (Default: local)
  67203. * @returns the TransformNode.
  67204. */
  67205. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67206. /**
  67207. * Adds a rotation step to the mesh current rotation.
  67208. * x, y, z are Euler angles expressed in radians.
  67209. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67210. * This means this rotation is made in the mesh local space only.
  67211. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67212. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67213. * ```javascript
  67214. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67215. * ```
  67216. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67217. * 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.
  67218. * @param x Rotation to add
  67219. * @param y Rotation to add
  67220. * @param z Rotation to add
  67221. * @returns the TransformNode.
  67222. */
  67223. addRotation(x: number, y: number, z: number): TransformNode;
  67224. /**
  67225. * @hidden
  67226. */
  67227. protected _getEffectiveParent(): Nullable<Node>;
  67228. /**
  67229. * Computes the world matrix of the node
  67230. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67231. * @returns the world matrix
  67232. */
  67233. computeWorldMatrix(force?: boolean): Matrix;
  67234. protected _afterComputeWorldMatrix(): void;
  67235. /**
  67236. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67237. * @param func callback function to add
  67238. *
  67239. * @returns the TransformNode.
  67240. */
  67241. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67242. /**
  67243. * Removes a registered callback function.
  67244. * @param func callback function to remove
  67245. * @returns the TransformNode.
  67246. */
  67247. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67248. /**
  67249. * Gets the position of the current mesh in camera space
  67250. * @param camera defines the camera to use
  67251. * @returns a position
  67252. */
  67253. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67254. /**
  67255. * Returns the distance from the mesh to the active camera
  67256. * @param camera defines the camera to use
  67257. * @returns the distance
  67258. */
  67259. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67260. /**
  67261. * Clone the current transform node
  67262. * @param name Name of the new clone
  67263. * @param newParent New parent for the clone
  67264. * @param doNotCloneChildren Do not clone children hierarchy
  67265. * @returns the new transform node
  67266. */
  67267. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67268. /**
  67269. * Serializes the objects information.
  67270. * @param currentSerializationObject defines the object to serialize in
  67271. * @returns the serialized object
  67272. */
  67273. serialize(currentSerializationObject?: any): any;
  67274. /**
  67275. * Returns a new TransformNode object parsed from the source provided.
  67276. * @param parsedTransformNode is the source.
  67277. * @param scene the scne the object belongs to
  67278. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67279. * @returns a new TransformNode object parsed from the source provided.
  67280. */
  67281. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67282. /**
  67283. * Get all child-transformNodes of this node
  67284. * @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
  67285. * @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
  67286. * @returns an array of TransformNode
  67287. */
  67288. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67289. /**
  67290. * Releases resources associated with this transform node.
  67291. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67292. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67293. */
  67294. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67295. }
  67296. }
  67297. declare module BABYLON {
  67298. /**
  67299. * Class used to override all child animations of a given target
  67300. */
  67301. export class AnimationPropertiesOverride {
  67302. /**
  67303. * Gets or sets a value indicating if animation blending must be used
  67304. */
  67305. enableBlending: boolean;
  67306. /**
  67307. * Gets or sets the blending speed to use when enableBlending is true
  67308. */
  67309. blendingSpeed: number;
  67310. /**
  67311. * Gets or sets the default loop mode to use
  67312. */
  67313. loopMode: number;
  67314. }
  67315. }
  67316. declare module BABYLON {
  67317. /**
  67318. * Class used to store bone information
  67319. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67320. */
  67321. export class Bone extends Node {
  67322. /**
  67323. * defines the bone name
  67324. */
  67325. name: string;
  67326. private static _tmpVecs;
  67327. private static _tmpQuat;
  67328. private static _tmpMats;
  67329. /**
  67330. * Gets the list of child bones
  67331. */
  67332. children: Bone[];
  67333. /** Gets the animations associated with this bone */
  67334. animations: Animation[];
  67335. /**
  67336. * Gets or sets bone length
  67337. */
  67338. length: number;
  67339. /**
  67340. * @hidden Internal only
  67341. * Set this value to map this bone to a different index in the transform matrices
  67342. * Set this value to -1 to exclude the bone from the transform matrices
  67343. */
  67344. _index: Nullable<number>;
  67345. private _skeleton;
  67346. private _localMatrix;
  67347. private _restPose;
  67348. private _baseMatrix;
  67349. private _absoluteTransform;
  67350. private _invertedAbsoluteTransform;
  67351. private _parent;
  67352. private _scalingDeterminant;
  67353. private _worldTransform;
  67354. private _localScaling;
  67355. private _localRotation;
  67356. private _localPosition;
  67357. private _needToDecompose;
  67358. private _needToCompose;
  67359. /** @hidden */
  67360. _linkedTransformNode: Nullable<TransformNode>;
  67361. /** @hidden */
  67362. /** @hidden */
  67363. _matrix: Matrix;
  67364. /**
  67365. * Create a new bone
  67366. * @param name defines the bone name
  67367. * @param skeleton defines the parent skeleton
  67368. * @param parentBone defines the parent (can be null if the bone is the root)
  67369. * @param localMatrix defines the local matrix
  67370. * @param restPose defines the rest pose matrix
  67371. * @param baseMatrix defines the base matrix
  67372. * @param index defines index of the bone in the hiearchy
  67373. */
  67374. constructor(
  67375. /**
  67376. * defines the bone name
  67377. */
  67378. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67379. /**
  67380. * Gets the current object class name.
  67381. * @return the class name
  67382. */
  67383. getClassName(): string;
  67384. /**
  67385. * Gets the parent skeleton
  67386. * @returns a skeleton
  67387. */
  67388. getSkeleton(): Skeleton;
  67389. /**
  67390. * Gets parent bone
  67391. * @returns a bone or null if the bone is the root of the bone hierarchy
  67392. */
  67393. getParent(): Nullable<Bone>;
  67394. /**
  67395. * Returns an array containing the root bones
  67396. * @returns an array containing the root bones
  67397. */
  67398. getChildren(): Array<Bone>;
  67399. /**
  67400. * Sets the parent bone
  67401. * @param parent defines the parent (can be null if the bone is the root)
  67402. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67403. */
  67404. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67405. /**
  67406. * Gets the local matrix
  67407. * @returns a matrix
  67408. */
  67409. getLocalMatrix(): Matrix;
  67410. /**
  67411. * Gets the base matrix (initial matrix which remains unchanged)
  67412. * @returns a matrix
  67413. */
  67414. getBaseMatrix(): Matrix;
  67415. /**
  67416. * Gets the rest pose matrix
  67417. * @returns a matrix
  67418. */
  67419. getRestPose(): Matrix;
  67420. /**
  67421. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67422. */
  67423. getWorldMatrix(): Matrix;
  67424. /**
  67425. * Sets the local matrix to rest pose matrix
  67426. */
  67427. returnToRest(): void;
  67428. /**
  67429. * Gets the inverse of the absolute transform matrix.
  67430. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67431. * @returns a matrix
  67432. */
  67433. getInvertedAbsoluteTransform(): Matrix;
  67434. /**
  67435. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67436. * @returns a matrix
  67437. */
  67438. getAbsoluteTransform(): Matrix;
  67439. /**
  67440. * Links with the given transform node.
  67441. * The local matrix of this bone is copied from the transform node every frame.
  67442. * @param transformNode defines the transform node to link to
  67443. */
  67444. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67445. /** Gets or sets current position (in local space) */
  67446. position: Vector3;
  67447. /** Gets or sets current rotation (in local space) */
  67448. rotation: Vector3;
  67449. /** Gets or sets current rotation quaternion (in local space) */
  67450. rotationQuaternion: Quaternion;
  67451. /** Gets or sets current scaling (in local space) */
  67452. scaling: Vector3;
  67453. /**
  67454. * Gets the animation properties override
  67455. */
  67456. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67457. private _decompose;
  67458. private _compose;
  67459. /**
  67460. * Update the base and local matrices
  67461. * @param matrix defines the new base or local matrix
  67462. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67463. * @param updateLocalMatrix defines if the local matrix should be updated
  67464. */
  67465. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67466. /** @hidden */
  67467. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67468. /**
  67469. * Flag the bone as dirty (Forcing it to update everything)
  67470. */
  67471. markAsDirty(): void;
  67472. private _markAsDirtyAndCompose;
  67473. private _markAsDirtyAndDecompose;
  67474. /**
  67475. * Translate the bone in local or world space
  67476. * @param vec The amount to translate the bone
  67477. * @param space The space that the translation is in
  67478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67479. */
  67480. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67481. /**
  67482. * Set the postion of the bone in local or world space
  67483. * @param position The position to set the bone
  67484. * @param space The space that the position is in
  67485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67486. */
  67487. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67488. /**
  67489. * Set the absolute position of the bone (world space)
  67490. * @param position The position to set the bone
  67491. * @param mesh The mesh that this bone is attached to
  67492. */
  67493. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67494. /**
  67495. * Scale the bone on the x, y and z axes (in local space)
  67496. * @param x The amount to scale the bone on the x axis
  67497. * @param y The amount to scale the bone on the y axis
  67498. * @param z The amount to scale the bone on the z axis
  67499. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67500. */
  67501. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67502. /**
  67503. * Set the bone scaling in local space
  67504. * @param scale defines the scaling vector
  67505. */
  67506. setScale(scale: Vector3): void;
  67507. /**
  67508. * Gets the current scaling in local space
  67509. * @returns the current scaling vector
  67510. */
  67511. getScale(): Vector3;
  67512. /**
  67513. * Gets the current scaling in local space and stores it in a target vector
  67514. * @param result defines the target vector
  67515. */
  67516. getScaleToRef(result: Vector3): void;
  67517. /**
  67518. * Set the yaw, pitch, and roll of the bone in local or world space
  67519. * @param yaw The rotation of the bone on the y axis
  67520. * @param pitch The rotation of the bone on the x axis
  67521. * @param roll The rotation of the bone on the z axis
  67522. * @param space The space that the axes of rotation are in
  67523. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67524. */
  67525. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67526. /**
  67527. * Add a rotation to the bone on an axis in local or world space
  67528. * @param axis The axis to rotate the bone on
  67529. * @param amount The amount to rotate the bone
  67530. * @param space The space that the axis is in
  67531. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67532. */
  67533. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67534. /**
  67535. * Set the rotation of the bone to a particular axis angle in local or world space
  67536. * @param axis The axis to rotate the bone on
  67537. * @param angle The angle that the bone should be rotated to
  67538. * @param space The space that the axis is in
  67539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67540. */
  67541. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67542. /**
  67543. * Set the euler rotation of the bone in local of world space
  67544. * @param rotation The euler rotation that the bone should be set to
  67545. * @param space The space that the rotation is in
  67546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67547. */
  67548. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67549. /**
  67550. * Set the quaternion rotation of the bone in local of world space
  67551. * @param quat The quaternion rotation that the bone should be set to
  67552. * @param space The space that the rotation is in
  67553. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67554. */
  67555. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67556. /**
  67557. * Set the rotation matrix of the bone in local of world space
  67558. * @param rotMat The rotation matrix that the bone should be set to
  67559. * @param space The space that the rotation is in
  67560. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67561. */
  67562. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67563. private _rotateWithMatrix;
  67564. private _getNegativeRotationToRef;
  67565. /**
  67566. * Get the position of the bone in local or world space
  67567. * @param space The space that the returned position is in
  67568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67569. * @returns The position of the bone
  67570. */
  67571. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67572. /**
  67573. * Copy the position of the bone to a vector3 in local or world space
  67574. * @param space The space that the returned position is in
  67575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67576. * @param result The vector3 to copy the position to
  67577. */
  67578. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67579. /**
  67580. * Get the absolute position of the bone (world space)
  67581. * @param mesh The mesh that this bone is attached to
  67582. * @returns The absolute position of the bone
  67583. */
  67584. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67585. /**
  67586. * Copy the absolute position of the bone (world space) to the result param
  67587. * @param mesh The mesh that this bone is attached to
  67588. * @param result The vector3 to copy the absolute position to
  67589. */
  67590. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67591. /**
  67592. * Compute the absolute transforms of this bone and its children
  67593. */
  67594. computeAbsoluteTransforms(): void;
  67595. /**
  67596. * Get the world direction from an axis that is in the local space of the bone
  67597. * @param localAxis The local direction that is used to compute the world direction
  67598. * @param mesh The mesh that this bone is attached to
  67599. * @returns The world direction
  67600. */
  67601. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67602. /**
  67603. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67604. * @param localAxis The local direction that is used to compute the world direction
  67605. * @param mesh The mesh that this bone is attached to
  67606. * @param result The vector3 that the world direction will be copied to
  67607. */
  67608. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67609. /**
  67610. * Get the euler rotation of the bone in local or world space
  67611. * @param space The space that the rotation should be in
  67612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67613. * @returns The euler rotation
  67614. */
  67615. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67616. /**
  67617. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67618. * @param space The space that the rotation should be in
  67619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67620. * @param result The vector3 that the rotation should be copied to
  67621. */
  67622. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67623. /**
  67624. * Get the quaternion rotation of the bone in either local or world space
  67625. * @param space The space that the rotation should be in
  67626. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67627. * @returns The quaternion rotation
  67628. */
  67629. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67630. /**
  67631. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67632. * @param space The space that the rotation should be in
  67633. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67634. * @param result The quaternion that the rotation should be copied to
  67635. */
  67636. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67637. /**
  67638. * Get the rotation matrix of the bone in local or world space
  67639. * @param space The space that the rotation should be in
  67640. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67641. * @returns The rotation matrix
  67642. */
  67643. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67644. /**
  67645. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67646. * @param space The space that the rotation should be in
  67647. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67648. * @param result The quaternion that the rotation should be copied to
  67649. */
  67650. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67651. /**
  67652. * Get the world position of a point that is in the local space of the bone
  67653. * @param position The local position
  67654. * @param mesh The mesh that this bone is attached to
  67655. * @returns The world position
  67656. */
  67657. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67658. /**
  67659. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  67660. * @param position The local position
  67661. * @param mesh The mesh that this bone is attached to
  67662. * @param result The vector3 that the world position should be copied to
  67663. */
  67664. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67665. /**
  67666. * Get the local position of a point that is in world space
  67667. * @param position The world position
  67668. * @param mesh The mesh that this bone is attached to
  67669. * @returns The local position
  67670. */
  67671. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67672. /**
  67673. * Get the local position of a point that is in world space and copy it to the result param
  67674. * @param position The world position
  67675. * @param mesh The mesh that this bone is attached to
  67676. * @param result The vector3 that the local position should be copied to
  67677. */
  67678. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67679. }
  67680. }
  67681. declare module BABYLON {
  67682. /**
  67683. * Enum that determines the text-wrapping mode to use.
  67684. */
  67685. export enum InspectableType {
  67686. /**
  67687. * Checkbox for booleans
  67688. */
  67689. Checkbox = 0,
  67690. /**
  67691. * Sliders for numbers
  67692. */
  67693. Slider = 1,
  67694. /**
  67695. * Vector3
  67696. */
  67697. Vector3 = 2,
  67698. /**
  67699. * Quaternions
  67700. */
  67701. Quaternion = 3,
  67702. /**
  67703. * Color3
  67704. */
  67705. Color3 = 4
  67706. }
  67707. /**
  67708. * Interface used to define custom inspectable properties.
  67709. * This interface is used by the inspector to display custom property grids
  67710. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67711. */
  67712. export interface IInspectable {
  67713. /**
  67714. * Gets the label to display
  67715. */
  67716. label: string;
  67717. /**
  67718. * Gets the name of the property to edit
  67719. */
  67720. propertyName: string;
  67721. /**
  67722. * Gets the type of the editor to use
  67723. */
  67724. type: InspectableType;
  67725. /**
  67726. * Gets the minimum value of the property when using in "slider" mode
  67727. */
  67728. min?: number;
  67729. /**
  67730. * Gets the maximum value of the property when using in "slider" mode
  67731. */
  67732. max?: number;
  67733. /**
  67734. * Gets the setp to use when using in "slider" mode
  67735. */
  67736. step?: number;
  67737. }
  67738. }
  67739. declare module BABYLON {
  67740. /**
  67741. * Class for creating a cube texture
  67742. */
  67743. export class CubeTexture extends BaseTexture {
  67744. private _delayedOnLoad;
  67745. /**
  67746. * The url of the texture
  67747. */
  67748. url: string;
  67749. /**
  67750. * Gets or sets the center of the bounding box associated with the cube texture.
  67751. * It must define where the camera used to render the texture was set
  67752. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67753. */
  67754. boundingBoxPosition: Vector3;
  67755. private _boundingBoxSize;
  67756. /**
  67757. * Gets or sets the size of the bounding box associated with the cube texture
  67758. * When defined, the cubemap will switch to local mode
  67759. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67760. * @example https://www.babylonjs-playground.com/#RNASML
  67761. */
  67762. /**
  67763. * Returns the bounding box size
  67764. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67765. */
  67766. boundingBoxSize: Vector3;
  67767. protected _rotationY: number;
  67768. /**
  67769. * Sets texture matrix rotation angle around Y axis in radians.
  67770. */
  67771. /**
  67772. * Gets texture matrix rotation angle around Y axis radians.
  67773. */
  67774. rotationY: number;
  67775. /**
  67776. * Are mip maps generated for this texture or not.
  67777. */
  67778. readonly noMipmap: boolean;
  67779. private _noMipmap;
  67780. private _files;
  67781. private _extensions;
  67782. private _textureMatrix;
  67783. private _format;
  67784. private _createPolynomials;
  67785. /** @hidden */
  67786. _prefiltered: boolean;
  67787. /**
  67788. * Creates a cube texture from an array of image urls
  67789. * @param files defines an array of image urls
  67790. * @param scene defines the hosting scene
  67791. * @param noMipmap specifies if mip maps are not used
  67792. * @returns a cube texture
  67793. */
  67794. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67795. /**
  67796. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67797. * @param url defines the url of the prefiltered texture
  67798. * @param scene defines the scene the texture is attached to
  67799. * @param forcedExtension defines the extension of the file if different from the url
  67800. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67801. * @return the prefiltered texture
  67802. */
  67803. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67804. /**
  67805. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67806. * as prefiltered data.
  67807. * @param rootUrl defines the url of the texture or the root name of the six images
  67808. * @param scene defines the scene the texture is attached to
  67809. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67810. * @param noMipmap defines if mipmaps should be created or not
  67811. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67812. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67813. * @param onError defines a callback triggered in case of error during load
  67814. * @param format defines the internal format to use for the texture once loaded
  67815. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67816. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67817. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67818. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67819. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67820. * @return the cube texture
  67821. */
  67822. 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);
  67823. /**
  67824. * Get the current class name of the texture useful for serialization or dynamic coding.
  67825. * @returns "CubeTexture"
  67826. */
  67827. getClassName(): string;
  67828. /**
  67829. * Update the url (and optional buffer) of this texture if url was null during construction.
  67830. * @param url the url of the texture
  67831. * @param forcedExtension defines the extension to use
  67832. * @param onLoad callback called when the texture is loaded (defaults to null)
  67833. */
  67834. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67835. /**
  67836. * Delays loading of the cube texture
  67837. * @param forcedExtension defines the extension to use
  67838. */
  67839. delayLoad(forcedExtension?: string): void;
  67840. /**
  67841. * Returns the reflection texture matrix
  67842. * @returns the reflection texture matrix
  67843. */
  67844. getReflectionTextureMatrix(): Matrix;
  67845. /**
  67846. * Sets the reflection texture matrix
  67847. * @param value Reflection texture matrix
  67848. */
  67849. setReflectionTextureMatrix(value: Matrix): void;
  67850. /**
  67851. * Parses text to create a cube texture
  67852. * @param parsedTexture define the serialized text to read from
  67853. * @param scene defines the hosting scene
  67854. * @param rootUrl defines the root url of the cube texture
  67855. * @returns a cube texture
  67856. */
  67857. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  67858. /**
  67859. * Makes a clone, or deep copy, of the cube texture
  67860. * @returns a new cube texture
  67861. */
  67862. clone(): CubeTexture;
  67863. }
  67864. }
  67865. declare module BABYLON {
  67866. /** @hidden */
  67867. export var postprocessVertexShader: {
  67868. name: string;
  67869. shader: string;
  67870. };
  67871. }
  67872. declare module BABYLON {
  67873. /**
  67874. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  67875. * This is the base of the follow, arc rotate cameras and Free camera
  67876. * @see http://doc.babylonjs.com/features/cameras
  67877. */
  67878. export class TargetCamera extends Camera {
  67879. private static _RigCamTransformMatrix;
  67880. private static _TargetTransformMatrix;
  67881. private static _TargetFocalPoint;
  67882. /**
  67883. * Define the current direction the camera is moving to
  67884. */
  67885. cameraDirection: Vector3;
  67886. /**
  67887. * Define the current rotation the camera is rotating to
  67888. */
  67889. cameraRotation: Vector2;
  67890. /**
  67891. * When set, the up vector of the camera will be updated by the rotation of the camera
  67892. */
  67893. updateUpVectorFromRotation: boolean;
  67894. private _tmpQuaternion;
  67895. /**
  67896. * Define the current rotation of the camera
  67897. */
  67898. rotation: Vector3;
  67899. /**
  67900. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  67901. */
  67902. rotationQuaternion: Quaternion;
  67903. /**
  67904. * Define the current speed of the camera
  67905. */
  67906. speed: number;
  67907. /**
  67908. * Add cconstraint to the camera to prevent it to move freely in all directions and
  67909. * around all axis.
  67910. */
  67911. noRotationConstraint: boolean;
  67912. /**
  67913. * Define the current target of the camera as an object or a position.
  67914. */
  67915. lockedTarget: any;
  67916. /** @hidden */
  67917. _currentTarget: Vector3;
  67918. /** @hidden */
  67919. _initialFocalDistance: number;
  67920. /** @hidden */
  67921. _viewMatrix: Matrix;
  67922. /** @hidden */
  67923. _camMatrix: Matrix;
  67924. /** @hidden */
  67925. _cameraTransformMatrix: Matrix;
  67926. /** @hidden */
  67927. _cameraRotationMatrix: Matrix;
  67928. /** @hidden */
  67929. _referencePoint: Vector3;
  67930. /** @hidden */
  67931. _transformedReferencePoint: Vector3;
  67932. protected _globalCurrentTarget: Vector3;
  67933. protected _globalCurrentUpVector: Vector3;
  67934. /** @hidden */
  67935. _reset: () => void;
  67936. private _defaultUp;
  67937. /**
  67938. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67939. * This is the base of the follow, arc rotate cameras and Free camera
  67940. * @see http://doc.babylonjs.com/features/cameras
  67941. * @param name Defines the name of the camera in the scene
  67942. * @param position Defines the start position of the camera in the scene
  67943. * @param scene Defines the scene the camera belongs to
  67944. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67945. */
  67946. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67947. /**
  67948. * Gets the position in front of the camera at a given distance.
  67949. * @param distance The distance from the camera we want the position to be
  67950. * @returns the position
  67951. */
  67952. getFrontPosition(distance: number): Vector3;
  67953. /** @hidden */
  67954. _getLockedTargetPosition(): Nullable<Vector3>;
  67955. private _storedPosition;
  67956. private _storedRotation;
  67957. private _storedRotationQuaternion;
  67958. /**
  67959. * Store current camera state of the camera (fov, position, rotation, etc..)
  67960. * @returns the camera
  67961. */
  67962. storeState(): Camera;
  67963. /**
  67964. * Restored camera state. You must call storeState() first
  67965. * @returns whether it was successful or not
  67966. * @hidden
  67967. */
  67968. _restoreStateValues(): boolean;
  67969. /** @hidden */
  67970. _initCache(): void;
  67971. /** @hidden */
  67972. _updateCache(ignoreParentClass?: boolean): void;
  67973. /** @hidden */
  67974. _isSynchronizedViewMatrix(): boolean;
  67975. /** @hidden */
  67976. _computeLocalCameraSpeed(): number;
  67977. /**
  67978. * Defines the target the camera should look at.
  67979. * This will automatically adapt alpha beta and radius to fit within the new target.
  67980. * @param target Defines the new target as a Vector or a mesh
  67981. */
  67982. setTarget(target: Vector3): void;
  67983. /**
  67984. * Return the current target position of the camera. This value is expressed in local space.
  67985. * @returns the target position
  67986. */
  67987. getTarget(): Vector3;
  67988. /** @hidden */
  67989. _decideIfNeedsToMove(): boolean;
  67990. /** @hidden */
  67991. _updatePosition(): void;
  67992. /** @hidden */
  67993. _checkInputs(): void;
  67994. protected _updateCameraRotationMatrix(): void;
  67995. /**
  67996. * 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)
  67997. * @returns the current camera
  67998. */
  67999. private _rotateUpVectorWithCameraRotationMatrix;
  68000. private _cachedRotationZ;
  68001. private _cachedQuaternionRotationZ;
  68002. /** @hidden */
  68003. _getViewMatrix(): Matrix;
  68004. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68005. /**
  68006. * @hidden
  68007. */
  68008. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68009. /**
  68010. * @hidden
  68011. */
  68012. _updateRigCameras(): void;
  68013. private _getRigCamPositionAndTarget;
  68014. /**
  68015. * Gets the current object class name.
  68016. * @return the class name
  68017. */
  68018. getClassName(): string;
  68019. }
  68020. }
  68021. declare module BABYLON {
  68022. /**
  68023. * @ignore
  68024. * This is a list of all the different input types that are available in the application.
  68025. * Fo instance: ArcRotateCameraGamepadInput...
  68026. */
  68027. export var CameraInputTypes: {};
  68028. /**
  68029. * This is the contract to implement in order to create a new input class.
  68030. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68031. */
  68032. export interface ICameraInput<TCamera extends Camera> {
  68033. /**
  68034. * Defines the camera the input is attached to.
  68035. */
  68036. camera: Nullable<TCamera>;
  68037. /**
  68038. * Gets the class name of the current intput.
  68039. * @returns the class name
  68040. */
  68041. getClassName(): string;
  68042. /**
  68043. * Get the friendly name associated with the input class.
  68044. * @returns the input friendly name
  68045. */
  68046. getSimpleName(): string;
  68047. /**
  68048. * Attach the input controls to a specific dom element to get the input from.
  68049. * @param element Defines the element the controls should be listened from
  68050. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68051. */
  68052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68053. /**
  68054. * Detach the current controls from the specified dom element.
  68055. * @param element Defines the element to stop listening the inputs from
  68056. */
  68057. detachControl(element: Nullable<HTMLElement>): void;
  68058. /**
  68059. * Update the current camera state depending on the inputs that have been used this frame.
  68060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68061. */
  68062. checkInputs?: () => void;
  68063. }
  68064. /**
  68065. * Represents a map of input types to input instance or input index to input instance.
  68066. */
  68067. export interface CameraInputsMap<TCamera extends Camera> {
  68068. /**
  68069. * Accessor to the input by input type.
  68070. */
  68071. [name: string]: ICameraInput<TCamera>;
  68072. /**
  68073. * Accessor to the input by input index.
  68074. */
  68075. [idx: number]: ICameraInput<TCamera>;
  68076. }
  68077. /**
  68078. * This represents the input manager used within a camera.
  68079. * It helps dealing with all the different kind of input attached to a camera.
  68080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68081. */
  68082. export class CameraInputsManager<TCamera extends Camera> {
  68083. /**
  68084. * Defines the list of inputs attahed to the camera.
  68085. */
  68086. attached: CameraInputsMap<TCamera>;
  68087. /**
  68088. * Defines the dom element the camera is collecting inputs from.
  68089. * This is null if the controls have not been attached.
  68090. */
  68091. attachedElement: Nullable<HTMLElement>;
  68092. /**
  68093. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68094. */
  68095. noPreventDefault: boolean;
  68096. /**
  68097. * Defined the camera the input manager belongs to.
  68098. */
  68099. camera: TCamera;
  68100. /**
  68101. * Update the current camera state depending on the inputs that have been used this frame.
  68102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68103. */
  68104. checkInputs: () => void;
  68105. /**
  68106. * Instantiate a new Camera Input Manager.
  68107. * @param camera Defines the camera the input manager blongs to
  68108. */
  68109. constructor(camera: TCamera);
  68110. /**
  68111. * Add an input method to a camera
  68112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68113. * @param input camera input method
  68114. */
  68115. add(input: ICameraInput<TCamera>): void;
  68116. /**
  68117. * Remove a specific input method from a camera
  68118. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68119. * @param inputToRemove camera input method
  68120. */
  68121. remove(inputToRemove: ICameraInput<TCamera>): void;
  68122. /**
  68123. * Remove a specific input type from a camera
  68124. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68125. * @param inputType the type of the input to remove
  68126. */
  68127. removeByType(inputType: string): void;
  68128. private _addCheckInputs;
  68129. /**
  68130. * Attach the input controls to the currently attached dom element to listen the events from.
  68131. * @param input Defines the input to attach
  68132. */
  68133. attachInput(input: ICameraInput<TCamera>): void;
  68134. /**
  68135. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68136. * @param element Defines the dom element to collect the events from
  68137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68138. */
  68139. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68140. /**
  68141. * Detach the current manager inputs controls from a specific dom element.
  68142. * @param element Defines the dom element to collect the events from
  68143. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68144. */
  68145. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68146. /**
  68147. * Rebuild the dynamic inputCheck function from the current list of
  68148. * defined inputs in the manager.
  68149. */
  68150. rebuildInputCheck(): void;
  68151. /**
  68152. * Remove all attached input methods from a camera
  68153. */
  68154. clear(): void;
  68155. /**
  68156. * Serialize the current input manager attached to a camera.
  68157. * This ensures than once parsed,
  68158. * the input associated to the camera will be identical to the current ones
  68159. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68160. */
  68161. serialize(serializedCamera: any): void;
  68162. /**
  68163. * Parses an input manager serialized JSON to restore the previous list of inputs
  68164. * and states associated to a camera.
  68165. * @param parsedCamera Defines the JSON to parse
  68166. */
  68167. parse(parsedCamera: any): void;
  68168. }
  68169. }
  68170. declare module BABYLON {
  68171. /**
  68172. * Gather the list of keyboard event types as constants.
  68173. */
  68174. export class KeyboardEventTypes {
  68175. /**
  68176. * The keydown event is fired when a key becomes active (pressed).
  68177. */
  68178. static readonly KEYDOWN: number;
  68179. /**
  68180. * The keyup event is fired when a key has been released.
  68181. */
  68182. static readonly KEYUP: number;
  68183. }
  68184. /**
  68185. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68186. */
  68187. export class KeyboardInfo {
  68188. /**
  68189. * Defines the type of event (KeyboardEventTypes)
  68190. */
  68191. type: number;
  68192. /**
  68193. * Defines the related dom event
  68194. */
  68195. event: KeyboardEvent;
  68196. /**
  68197. * Instantiates a new keyboard info.
  68198. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68199. * @param type Defines the type of event (KeyboardEventTypes)
  68200. * @param event Defines the related dom event
  68201. */
  68202. constructor(
  68203. /**
  68204. * Defines the type of event (KeyboardEventTypes)
  68205. */
  68206. type: number,
  68207. /**
  68208. * Defines the related dom event
  68209. */
  68210. event: KeyboardEvent);
  68211. }
  68212. /**
  68213. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68214. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68215. */
  68216. export class KeyboardInfoPre extends KeyboardInfo {
  68217. /**
  68218. * Defines the type of event (KeyboardEventTypes)
  68219. */
  68220. type: number;
  68221. /**
  68222. * Defines the related dom event
  68223. */
  68224. event: KeyboardEvent;
  68225. /**
  68226. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68227. */
  68228. skipOnPointerObservable: boolean;
  68229. /**
  68230. * Instantiates a new keyboard pre info.
  68231. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68232. * @param type Defines the type of event (KeyboardEventTypes)
  68233. * @param event Defines the related dom event
  68234. */
  68235. constructor(
  68236. /**
  68237. * Defines the type of event (KeyboardEventTypes)
  68238. */
  68239. type: number,
  68240. /**
  68241. * Defines the related dom event
  68242. */
  68243. event: KeyboardEvent);
  68244. }
  68245. }
  68246. declare module BABYLON {
  68247. /**
  68248. * Manage the keyboard inputs to control the movement of a free camera.
  68249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68250. */
  68251. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68252. /**
  68253. * Defines the camera the input is attached to.
  68254. */
  68255. camera: FreeCamera;
  68256. /**
  68257. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68258. */
  68259. keysUp: number[];
  68260. /**
  68261. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68262. */
  68263. keysDown: number[];
  68264. /**
  68265. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68266. */
  68267. keysLeft: number[];
  68268. /**
  68269. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68270. */
  68271. keysRight: number[];
  68272. private _keys;
  68273. private _onCanvasBlurObserver;
  68274. private _onKeyboardObserver;
  68275. private _engine;
  68276. private _scene;
  68277. /**
  68278. * Attach the input controls to a specific dom element to get the input from.
  68279. * @param element Defines the element the controls should be listened from
  68280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68281. */
  68282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68283. /**
  68284. * Detach the current controls from the specified dom element.
  68285. * @param element Defines the element to stop listening the inputs from
  68286. */
  68287. detachControl(element: Nullable<HTMLElement>): void;
  68288. /**
  68289. * Update the current camera state depending on the inputs that have been used this frame.
  68290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68291. */
  68292. checkInputs(): void;
  68293. /**
  68294. * Gets the class name of the current intput.
  68295. * @returns the class name
  68296. */
  68297. getClassName(): string;
  68298. /** @hidden */
  68299. _onLostFocus(): void;
  68300. /**
  68301. * Get the friendly name associated with the input class.
  68302. * @returns the input friendly name
  68303. */
  68304. getSimpleName(): string;
  68305. }
  68306. }
  68307. declare module BABYLON {
  68308. /**
  68309. * Interface describing all the common properties and methods a shadow light needs to implement.
  68310. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68311. * as well as binding the different shadow properties to the effects.
  68312. */
  68313. export interface IShadowLight extends Light {
  68314. /**
  68315. * The light id in the scene (used in scene.findLighById for instance)
  68316. */
  68317. id: string;
  68318. /**
  68319. * The position the shdow will be casted from.
  68320. */
  68321. position: Vector3;
  68322. /**
  68323. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68324. */
  68325. direction: Vector3;
  68326. /**
  68327. * The transformed position. Position of the light in world space taking parenting in account.
  68328. */
  68329. transformedPosition: Vector3;
  68330. /**
  68331. * The transformed direction. Direction of the light in world space taking parenting in account.
  68332. */
  68333. transformedDirection: Vector3;
  68334. /**
  68335. * The friendly name of the light in the scene.
  68336. */
  68337. name: string;
  68338. /**
  68339. * Defines the shadow projection clipping minimum z value.
  68340. */
  68341. shadowMinZ: number;
  68342. /**
  68343. * Defines the shadow projection clipping maximum z value.
  68344. */
  68345. shadowMaxZ: number;
  68346. /**
  68347. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68348. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68349. */
  68350. computeTransformedInformation(): boolean;
  68351. /**
  68352. * Gets the scene the light belongs to.
  68353. * @returns The scene
  68354. */
  68355. getScene(): Scene;
  68356. /**
  68357. * Callback defining a custom Projection Matrix Builder.
  68358. * This can be used to override the default projection matrix computation.
  68359. */
  68360. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68361. /**
  68362. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68363. * @param matrix The materix to updated with the projection information
  68364. * @param viewMatrix The transform matrix of the light
  68365. * @param renderList The list of mesh to render in the map
  68366. * @returns The current light
  68367. */
  68368. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68369. /**
  68370. * Gets the current depth scale used in ESM.
  68371. * @returns The scale
  68372. */
  68373. getDepthScale(): number;
  68374. /**
  68375. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68376. * @returns true if a cube texture needs to be use
  68377. */
  68378. needCube(): boolean;
  68379. /**
  68380. * Detects if the projection matrix requires to be recomputed this frame.
  68381. * @returns true if it requires to be recomputed otherwise, false.
  68382. */
  68383. needProjectionMatrixCompute(): boolean;
  68384. /**
  68385. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68386. */
  68387. forceProjectionMatrixCompute(): void;
  68388. /**
  68389. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68390. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68391. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68392. */
  68393. getShadowDirection(faceIndex?: number): Vector3;
  68394. /**
  68395. * Gets the minZ used for shadow according to both the scene and the light.
  68396. * @param activeCamera The camera we are returning the min for
  68397. * @returns the depth min z
  68398. */
  68399. getDepthMinZ(activeCamera: Camera): number;
  68400. /**
  68401. * Gets the maxZ used for shadow according to both the scene and the light.
  68402. * @param activeCamera The camera we are returning the max for
  68403. * @returns the depth max z
  68404. */
  68405. getDepthMaxZ(activeCamera: Camera): number;
  68406. }
  68407. /**
  68408. * Base implementation IShadowLight
  68409. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68410. */
  68411. export abstract class ShadowLight extends Light implements IShadowLight {
  68412. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68413. protected _position: Vector3;
  68414. protected _setPosition(value: Vector3): void;
  68415. /**
  68416. * Sets the position the shadow will be casted from. Also use as the light position for both
  68417. * point and spot lights.
  68418. */
  68419. /**
  68420. * Sets the position the shadow will be casted from. Also use as the light position for both
  68421. * point and spot lights.
  68422. */
  68423. position: Vector3;
  68424. protected _direction: Vector3;
  68425. protected _setDirection(value: Vector3): void;
  68426. /**
  68427. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68428. * Also use as the light direction on spot and directional lights.
  68429. */
  68430. /**
  68431. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68432. * Also use as the light direction on spot and directional lights.
  68433. */
  68434. direction: Vector3;
  68435. private _shadowMinZ;
  68436. /**
  68437. * Gets the shadow projection clipping minimum z value.
  68438. */
  68439. /**
  68440. * Sets the shadow projection clipping minimum z value.
  68441. */
  68442. shadowMinZ: number;
  68443. private _shadowMaxZ;
  68444. /**
  68445. * Sets the shadow projection clipping maximum z value.
  68446. */
  68447. /**
  68448. * Gets the shadow projection clipping maximum z value.
  68449. */
  68450. shadowMaxZ: number;
  68451. /**
  68452. * Callback defining a custom Projection Matrix Builder.
  68453. * This can be used to override the default projection matrix computation.
  68454. */
  68455. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68456. /**
  68457. * The transformed position. Position of the light in world space taking parenting in account.
  68458. */
  68459. transformedPosition: Vector3;
  68460. /**
  68461. * The transformed direction. Direction of the light in world space taking parenting in account.
  68462. */
  68463. transformedDirection: Vector3;
  68464. private _needProjectionMatrixCompute;
  68465. /**
  68466. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68467. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68468. */
  68469. computeTransformedInformation(): boolean;
  68470. /**
  68471. * Return the depth scale used for the shadow map.
  68472. * @returns the depth scale.
  68473. */
  68474. getDepthScale(): number;
  68475. /**
  68476. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68477. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68478. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68479. */
  68480. getShadowDirection(faceIndex?: number): Vector3;
  68481. /**
  68482. * Returns the ShadowLight absolute position in the World.
  68483. * @returns the position vector in world space
  68484. */
  68485. getAbsolutePosition(): Vector3;
  68486. /**
  68487. * Sets the ShadowLight direction toward the passed target.
  68488. * @param target The point to target in local space
  68489. * @returns the updated ShadowLight direction
  68490. */
  68491. setDirectionToTarget(target: Vector3): Vector3;
  68492. /**
  68493. * Returns the light rotation in euler definition.
  68494. * @returns the x y z rotation in local space.
  68495. */
  68496. getRotation(): Vector3;
  68497. /**
  68498. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68499. * @returns true if a cube texture needs to be use
  68500. */
  68501. needCube(): boolean;
  68502. /**
  68503. * Detects if the projection matrix requires to be recomputed this frame.
  68504. * @returns true if it requires to be recomputed otherwise, false.
  68505. */
  68506. needProjectionMatrixCompute(): boolean;
  68507. /**
  68508. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68509. */
  68510. forceProjectionMatrixCompute(): void;
  68511. /** @hidden */
  68512. _initCache(): void;
  68513. /** @hidden */
  68514. _isSynchronized(): boolean;
  68515. /**
  68516. * Computes the world matrix of the node
  68517. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68518. * @returns the world matrix
  68519. */
  68520. computeWorldMatrix(force?: boolean): Matrix;
  68521. /**
  68522. * Gets the minZ used for shadow according to both the scene and the light.
  68523. * @param activeCamera The camera we are returning the min for
  68524. * @returns the depth min z
  68525. */
  68526. getDepthMinZ(activeCamera: Camera): number;
  68527. /**
  68528. * Gets the maxZ used for shadow according to both the scene and the light.
  68529. * @param activeCamera The camera we are returning the max for
  68530. * @returns the depth max z
  68531. */
  68532. getDepthMaxZ(activeCamera: Camera): number;
  68533. /**
  68534. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68535. * @param matrix The materix to updated with the projection information
  68536. * @param viewMatrix The transform matrix of the light
  68537. * @param renderList The list of mesh to render in the map
  68538. * @returns The current light
  68539. */
  68540. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68541. }
  68542. }
  68543. declare module BABYLON {
  68544. /**
  68545. * "Static Class" containing the most commonly used helper while dealing with material for
  68546. * rendering purpose.
  68547. *
  68548. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68549. *
  68550. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68551. */
  68552. export class MaterialHelper {
  68553. /**
  68554. * Bind the current view position to an effect.
  68555. * @param effect The effect to be bound
  68556. * @param scene The scene the eyes position is used from
  68557. */
  68558. static BindEyePosition(effect: Effect, scene: Scene): void;
  68559. /**
  68560. * Helps preparing the defines values about the UVs in used in the effect.
  68561. * UVs are shared as much as we can accross channels in the shaders.
  68562. * @param texture The texture we are preparing the UVs for
  68563. * @param defines The defines to update
  68564. * @param key The channel key "diffuse", "specular"... used in the shader
  68565. */
  68566. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68567. /**
  68568. * Binds a texture matrix value to its corrsponding uniform
  68569. * @param texture The texture to bind the matrix for
  68570. * @param uniformBuffer The uniform buffer receivin the data
  68571. * @param key The channel key "diffuse", "specular"... used in the shader
  68572. */
  68573. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  68574. /**
  68575. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68576. * @param mesh defines the current mesh
  68577. * @param scene defines the current scene
  68578. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68579. * @param pointsCloud defines if point cloud rendering has to be turned on
  68580. * @param fogEnabled defines if fog has to be turned on
  68581. * @param alphaTest defines if alpha testing has to be turned on
  68582. * @param defines defines the current list of defines
  68583. */
  68584. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  68585. /**
  68586. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68587. * @param scene defines the current scene
  68588. * @param engine defines the current engine
  68589. * @param defines specifies the list of active defines
  68590. * @param useInstances defines if instances have to be turned on
  68591. * @param useClipPlane defines if clip plane have to be turned on
  68592. */
  68593. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  68594. /**
  68595. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68596. * @param mesh The mesh containing the geometry data we will draw
  68597. * @param defines The defines to update
  68598. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68599. * @param useBones Precise whether bones should be used or not (override mesh info)
  68600. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68601. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68602. * @returns false if defines are considered not dirty and have not been checked
  68603. */
  68604. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  68605. /**
  68606. * Prepares the defines related to multiview
  68607. * @param scene The scene we are intending to draw
  68608. * @param defines The defines to update
  68609. */
  68610. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  68611. /**
  68612. * Prepares the defines related to the light information passed in parameter
  68613. * @param scene The scene we are intending to draw
  68614. * @param mesh The mesh the effect is compiling for
  68615. * @param defines The defines to update
  68616. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68617. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68618. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68619. * @returns true if normals will be required for the rest of the effect
  68620. */
  68621. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  68622. /**
  68623. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68624. * that won t be acctive due to defines being turned off.
  68625. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68626. * @param samplersList The samplers list
  68627. * @param defines The defines helping in the list generation
  68628. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68629. */
  68630. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  68631. /**
  68632. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68633. * @param defines The defines to update while falling back
  68634. * @param fallbacks The authorized effect fallbacks
  68635. * @param maxSimultaneousLights The maximum number of lights allowed
  68636. * @param rank the current rank of the Effect
  68637. * @returns The newly affected rank
  68638. */
  68639. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  68640. /**
  68641. * Prepares the list of attributes required for morph targets according to the effect defines.
  68642. * @param attribs The current list of supported attribs
  68643. * @param mesh The mesh to prepare the morph targets attributes for
  68644. * @param defines The current Defines of the effect
  68645. */
  68646. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  68647. /**
  68648. * Prepares the list of attributes required for bones according to the effect defines.
  68649. * @param attribs The current list of supported attribs
  68650. * @param mesh The mesh to prepare the bones attributes for
  68651. * @param defines The current Defines of the effect
  68652. * @param fallbacks The current efffect fallback strategy
  68653. */
  68654. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  68655. /**
  68656. * Prepares the list of attributes required for instances according to the effect defines.
  68657. * @param attribs The current list of supported attribs
  68658. * @param defines The current Defines of the effect
  68659. */
  68660. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  68661. /**
  68662. * Binds the light shadow information to the effect for the given mesh.
  68663. * @param light The light containing the generator
  68664. * @param scene The scene the lights belongs to
  68665. * @param mesh The mesh we are binding the information to render
  68666. * @param lightIndex The light index in the effect used to render the mesh
  68667. * @param effect The effect we are binding the data to
  68668. */
  68669. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  68670. /**
  68671. * Binds the light information to the effect.
  68672. * @param light The light containing the generator
  68673. * @param effect The effect we are binding the data to
  68674. * @param lightIndex The light index in the effect used to render
  68675. */
  68676. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  68677. /**
  68678. * Binds the lights information from the scene to the effect for the given mesh.
  68679. * @param scene The scene the lights belongs to
  68680. * @param mesh The mesh we are binding the information to render
  68681. * @param effect The effect we are binding the data to
  68682. * @param defines The generated defines for the effect
  68683. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  68684. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  68685. */
  68686. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  68687. private static _tempFogColor;
  68688. /**
  68689. * Binds the fog information from the scene to the effect for the given mesh.
  68690. * @param scene The scene the lights belongs to
  68691. * @param mesh The mesh we are binding the information to render
  68692. * @param effect The effect we are binding the data to
  68693. * @param linearSpace Defines if the fog effect is applied in linear space
  68694. */
  68695. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  68696. /**
  68697. * Binds the bones information from the mesh to the effect.
  68698. * @param mesh The mesh we are binding the information to render
  68699. * @param effect The effect we are binding the data to
  68700. */
  68701. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  68702. /**
  68703. * Binds the morph targets information from the mesh to the effect.
  68704. * @param abstractMesh The mesh we are binding the information to render
  68705. * @param effect The effect we are binding the data to
  68706. */
  68707. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  68708. /**
  68709. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  68710. * @param defines The generated defines used in the effect
  68711. * @param effect The effect we are binding the data to
  68712. * @param scene The scene we are willing to render with logarithmic scale for
  68713. */
  68714. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  68715. /**
  68716. * Binds the clip plane information from the scene to the effect.
  68717. * @param scene The scene the clip plane information are extracted from
  68718. * @param effect The effect we are binding the data to
  68719. */
  68720. static BindClipPlane(effect: Effect, scene: Scene): void;
  68721. }
  68722. }
  68723. declare module BABYLON {
  68724. /** @hidden */
  68725. export var kernelBlurVaryingDeclaration: {
  68726. name: string;
  68727. shader: string;
  68728. };
  68729. }
  68730. declare module BABYLON {
  68731. /** @hidden */
  68732. export var kernelBlurFragment: {
  68733. name: string;
  68734. shader: string;
  68735. };
  68736. }
  68737. declare module BABYLON {
  68738. /** @hidden */
  68739. export var kernelBlurFragment2: {
  68740. name: string;
  68741. shader: string;
  68742. };
  68743. }
  68744. declare module BABYLON {
  68745. /** @hidden */
  68746. export var kernelBlurPixelShader: {
  68747. name: string;
  68748. shader: string;
  68749. };
  68750. }
  68751. declare module BABYLON {
  68752. /** @hidden */
  68753. export var kernelBlurVertex: {
  68754. name: string;
  68755. shader: string;
  68756. };
  68757. }
  68758. declare module BABYLON {
  68759. /** @hidden */
  68760. export var kernelBlurVertexShader: {
  68761. name: string;
  68762. shader: string;
  68763. };
  68764. }
  68765. declare module BABYLON {
  68766. /**
  68767. * The Blur Post Process which blurs an image based on a kernel and direction.
  68768. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68769. */
  68770. export class BlurPostProcess extends PostProcess {
  68771. /** The direction in which to blur the image. */
  68772. direction: Vector2;
  68773. private blockCompilation;
  68774. protected _kernel: number;
  68775. protected _idealKernel: number;
  68776. protected _packedFloat: boolean;
  68777. private _staticDefines;
  68778. /**
  68779. * Sets the length in pixels of the blur sample region
  68780. */
  68781. /**
  68782. * Gets the length in pixels of the blur sample region
  68783. */
  68784. kernel: number;
  68785. /**
  68786. * Sets wether or not the blur needs to unpack/repack floats
  68787. */
  68788. /**
  68789. * Gets wether or not the blur is unpacking/repacking floats
  68790. */
  68791. packedFloat: boolean;
  68792. /**
  68793. * Creates a new instance BlurPostProcess
  68794. * @param name The name of the effect.
  68795. * @param direction The direction in which to blur the image.
  68796. * @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.
  68797. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68798. * @param camera The camera to apply the render pass to.
  68799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68800. * @param engine The engine which the post process will be applied. (default: current engine)
  68801. * @param reusable If the post process can be reused on the same frame. (default: false)
  68802. * @param textureType Type of textures used when performing the post process. (default: 0)
  68803. * @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)
  68804. */
  68805. constructor(name: string,
  68806. /** The direction in which to blur the image. */
  68807. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68808. /**
  68809. * Updates the effect with the current post process compile time values and recompiles the shader.
  68810. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68811. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68812. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68813. * @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
  68814. * @param onCompiled Called when the shader has been compiled.
  68815. * @param onError Called if there is an error when compiling a shader.
  68816. */
  68817. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68818. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68819. /**
  68820. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68821. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68822. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68823. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68824. * The gaps between physical kernels are compensated for in the weighting of the samples
  68825. * @param idealKernel Ideal blur kernel.
  68826. * @return Nearest best kernel.
  68827. */
  68828. protected _nearestBestKernel(idealKernel: number): number;
  68829. /**
  68830. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68831. * @param x The point on the Gaussian distribution to sample.
  68832. * @return the value of the Gaussian function at x.
  68833. */
  68834. protected _gaussianWeight(x: number): number;
  68835. /**
  68836. * Generates a string that can be used as a floating point number in GLSL.
  68837. * @param x Value to print.
  68838. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68839. * @return GLSL float string.
  68840. */
  68841. protected _glslFloat(x: number, decimalFigures?: number): string;
  68842. }
  68843. }
  68844. declare module BABYLON {
  68845. /** @hidden */
  68846. export var shadowMapPixelShader: {
  68847. name: string;
  68848. shader: string;
  68849. };
  68850. }
  68851. declare module BABYLON {
  68852. /** @hidden */
  68853. export var bonesDeclaration: {
  68854. name: string;
  68855. shader: string;
  68856. };
  68857. }
  68858. declare module BABYLON {
  68859. /** @hidden */
  68860. export var morphTargetsVertexGlobalDeclaration: {
  68861. name: string;
  68862. shader: string;
  68863. };
  68864. }
  68865. declare module BABYLON {
  68866. /** @hidden */
  68867. export var morphTargetsVertexDeclaration: {
  68868. name: string;
  68869. shader: string;
  68870. };
  68871. }
  68872. declare module BABYLON {
  68873. /** @hidden */
  68874. export var instancesDeclaration: {
  68875. name: string;
  68876. shader: string;
  68877. };
  68878. }
  68879. declare module BABYLON {
  68880. /** @hidden */
  68881. export var helperFunctions: {
  68882. name: string;
  68883. shader: string;
  68884. };
  68885. }
  68886. declare module BABYLON {
  68887. /** @hidden */
  68888. export var morphTargetsVertex: {
  68889. name: string;
  68890. shader: string;
  68891. };
  68892. }
  68893. declare module BABYLON {
  68894. /** @hidden */
  68895. export var instancesVertex: {
  68896. name: string;
  68897. shader: string;
  68898. };
  68899. }
  68900. declare module BABYLON {
  68901. /** @hidden */
  68902. export var bonesVertex: {
  68903. name: string;
  68904. shader: string;
  68905. };
  68906. }
  68907. declare module BABYLON {
  68908. /** @hidden */
  68909. export var shadowMapVertexShader: {
  68910. name: string;
  68911. shader: string;
  68912. };
  68913. }
  68914. declare module BABYLON {
  68915. /** @hidden */
  68916. export var depthBoxBlurPixelShader: {
  68917. name: string;
  68918. shader: string;
  68919. };
  68920. }
  68921. declare module BABYLON {
  68922. /**
  68923. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68924. */
  68925. export interface ICustomShaderOptions {
  68926. /**
  68927. * Gets or sets the custom shader name to use
  68928. */
  68929. shaderName: string;
  68930. /**
  68931. * The list of attribute names used in the shader
  68932. */
  68933. attributes?: string[];
  68934. /**
  68935. * The list of unifrom names used in the shader
  68936. */
  68937. uniforms?: string[];
  68938. /**
  68939. * The list of sampler names used in the shader
  68940. */
  68941. samplers?: string[];
  68942. /**
  68943. * The list of defines used in the shader
  68944. */
  68945. defines?: string[];
  68946. }
  68947. /**
  68948. * Interface to implement to create a shadow generator compatible with BJS.
  68949. */
  68950. export interface IShadowGenerator {
  68951. /**
  68952. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68953. * @returns The render target texture if present otherwise, null
  68954. */
  68955. getShadowMap(): Nullable<RenderTargetTexture>;
  68956. /**
  68957. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68958. * @returns The render target texture if the shadow map is present otherwise, null
  68959. */
  68960. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68961. /**
  68962. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68963. * @param subMesh The submesh we want to render in the shadow map
  68964. * @param useInstances Defines wether will draw in the map using instances
  68965. * @returns true if ready otherwise, false
  68966. */
  68967. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68968. /**
  68969. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68970. * @param defines Defines of the material we want to update
  68971. * @param lightIndex Index of the light in the enabled light list of the material
  68972. */
  68973. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68974. /**
  68975. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68976. * defined in the generator but impacting the effect).
  68977. * It implies the unifroms available on the materials are the standard BJS ones.
  68978. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68979. * @param effect The effect we are binfing the information for
  68980. */
  68981. bindShadowLight(lightIndex: string, effect: Effect): void;
  68982. /**
  68983. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68984. * (eq to shadow prjection matrix * light transform matrix)
  68985. * @returns The transform matrix used to create the shadow map
  68986. */
  68987. getTransformMatrix(): Matrix;
  68988. /**
  68989. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68990. * Cube and 2D textures for instance.
  68991. */
  68992. recreateShadowMap(): void;
  68993. /**
  68994. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68995. * @param onCompiled Callback triggered at the and of the effects compilation
  68996. * @param options Sets of optional options forcing the compilation with different modes
  68997. */
  68998. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68999. useInstances: boolean;
  69000. }>): void;
  69001. /**
  69002. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69003. * @param options Sets of optional options forcing the compilation with different modes
  69004. * @returns A promise that resolves when the compilation completes
  69005. */
  69006. forceCompilationAsync(options?: Partial<{
  69007. useInstances: boolean;
  69008. }>): Promise<void>;
  69009. /**
  69010. * Serializes the shadow generator setup to a json object.
  69011. * @returns The serialized JSON object
  69012. */
  69013. serialize(): any;
  69014. /**
  69015. * Disposes the Shadow map and related Textures and effects.
  69016. */
  69017. dispose(): void;
  69018. }
  69019. /**
  69020. * Default implementation IShadowGenerator.
  69021. * This is the main object responsible of generating shadows in the framework.
  69022. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69023. */
  69024. export class ShadowGenerator implements IShadowGenerator {
  69025. /**
  69026. * Shadow generator mode None: no filtering applied.
  69027. */
  69028. static readonly FILTER_NONE: number;
  69029. /**
  69030. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69031. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69032. */
  69033. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69034. /**
  69035. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69036. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69037. */
  69038. static readonly FILTER_POISSONSAMPLING: number;
  69039. /**
  69040. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69041. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69042. */
  69043. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69044. /**
  69045. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69046. * edge artifacts on steep falloff.
  69047. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69048. */
  69049. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69050. /**
  69051. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69052. * edge artifacts on steep falloff.
  69053. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69054. */
  69055. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69056. /**
  69057. * Shadow generator mode PCF: Percentage Closer Filtering
  69058. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69059. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69060. */
  69061. static readonly FILTER_PCF: number;
  69062. /**
  69063. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69064. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69065. * Contact Hardening
  69066. */
  69067. static readonly FILTER_PCSS: number;
  69068. /**
  69069. * Reserved for PCF and PCSS
  69070. * Highest Quality.
  69071. *
  69072. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69073. *
  69074. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69075. */
  69076. static readonly QUALITY_HIGH: number;
  69077. /**
  69078. * Reserved for PCF and PCSS
  69079. * Good tradeoff for quality/perf cross devices
  69080. *
  69081. * Execute PCF on a 3*3 kernel.
  69082. *
  69083. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69084. */
  69085. static readonly QUALITY_MEDIUM: number;
  69086. /**
  69087. * Reserved for PCF and PCSS
  69088. * The lowest quality but the fastest.
  69089. *
  69090. * Execute PCF on a 1*1 kernel.
  69091. *
  69092. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69093. */
  69094. static readonly QUALITY_LOW: number;
  69095. /** Gets or sets the custom shader name to use */
  69096. customShaderOptions: ICustomShaderOptions;
  69097. /**
  69098. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69099. */
  69100. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69101. /**
  69102. * Observable triggered before a mesh is rendered in the shadow map.
  69103. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69104. */
  69105. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69106. private _bias;
  69107. /**
  69108. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69109. */
  69110. /**
  69111. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69112. */
  69113. bias: number;
  69114. private _normalBias;
  69115. /**
  69116. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69117. */
  69118. /**
  69119. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69120. */
  69121. normalBias: number;
  69122. private _blurBoxOffset;
  69123. /**
  69124. * Gets the blur box offset: offset applied during the blur pass.
  69125. * Only useful if useKernelBlur = false
  69126. */
  69127. /**
  69128. * Sets the blur box offset: offset applied during the blur pass.
  69129. * Only useful if useKernelBlur = false
  69130. */
  69131. blurBoxOffset: number;
  69132. private _blurScale;
  69133. /**
  69134. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69135. * 2 means half of the size.
  69136. */
  69137. /**
  69138. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69139. * 2 means half of the size.
  69140. */
  69141. blurScale: number;
  69142. private _blurKernel;
  69143. /**
  69144. * Gets the blur kernel: kernel size of the blur pass.
  69145. * Only useful if useKernelBlur = true
  69146. */
  69147. /**
  69148. * Sets the blur kernel: kernel size of the blur pass.
  69149. * Only useful if useKernelBlur = true
  69150. */
  69151. blurKernel: number;
  69152. private _useKernelBlur;
  69153. /**
  69154. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69155. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69156. */
  69157. /**
  69158. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69159. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69160. */
  69161. useKernelBlur: boolean;
  69162. private _depthScale;
  69163. /**
  69164. * Gets the depth scale used in ESM mode.
  69165. */
  69166. /**
  69167. * Sets the depth scale used in ESM mode.
  69168. * This can override the scale stored on the light.
  69169. */
  69170. depthScale: number;
  69171. private _filter;
  69172. /**
  69173. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69174. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69175. */
  69176. /**
  69177. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69178. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69179. */
  69180. filter: number;
  69181. /**
  69182. * Gets if the current filter is set to Poisson Sampling.
  69183. */
  69184. /**
  69185. * Sets the current filter to Poisson Sampling.
  69186. */
  69187. usePoissonSampling: boolean;
  69188. /**
  69189. * Gets if the current filter is set to ESM.
  69190. */
  69191. /**
  69192. * Sets the current filter is to ESM.
  69193. */
  69194. useExponentialShadowMap: boolean;
  69195. /**
  69196. * Gets if the current filter is set to filtered ESM.
  69197. */
  69198. /**
  69199. * Gets if the current filter is set to filtered ESM.
  69200. */
  69201. useBlurExponentialShadowMap: boolean;
  69202. /**
  69203. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69204. * exponential to prevent steep falloff artifacts).
  69205. */
  69206. /**
  69207. * Sets the current filter to "close ESM" (using the inverse of the
  69208. * exponential to prevent steep falloff artifacts).
  69209. */
  69210. useCloseExponentialShadowMap: boolean;
  69211. /**
  69212. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69213. * exponential to prevent steep falloff artifacts).
  69214. */
  69215. /**
  69216. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69217. * exponential to prevent steep falloff artifacts).
  69218. */
  69219. useBlurCloseExponentialShadowMap: boolean;
  69220. /**
  69221. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69222. */
  69223. /**
  69224. * Sets the current filter to "PCF" (percentage closer filtering).
  69225. */
  69226. usePercentageCloserFiltering: boolean;
  69227. private _filteringQuality;
  69228. /**
  69229. * Gets the PCF or PCSS Quality.
  69230. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69231. */
  69232. /**
  69233. * Sets the PCF or PCSS Quality.
  69234. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69235. */
  69236. filteringQuality: number;
  69237. /**
  69238. * Gets if the current filter is set to "PCSS" (contact hardening).
  69239. */
  69240. /**
  69241. * Sets the current filter to "PCSS" (contact hardening).
  69242. */
  69243. useContactHardeningShadow: boolean;
  69244. private _contactHardeningLightSizeUVRatio;
  69245. /**
  69246. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69247. * Using a ratio helps keeping shape stability independently of the map size.
  69248. *
  69249. * It does not account for the light projection as it was having too much
  69250. * instability during the light setup or during light position changes.
  69251. *
  69252. * Only valid if useContactHardeningShadow is true.
  69253. */
  69254. /**
  69255. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69256. * Using a ratio helps keeping shape stability independently of the map size.
  69257. *
  69258. * It does not account for the light projection as it was having too much
  69259. * instability during the light setup or during light position changes.
  69260. *
  69261. * Only valid if useContactHardeningShadow is true.
  69262. */
  69263. contactHardeningLightSizeUVRatio: number;
  69264. private _darkness;
  69265. /**
  69266. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69267. * 0 means strongest and 1 would means no shadow.
  69268. * @returns the darkness.
  69269. */
  69270. getDarkness(): number;
  69271. /**
  69272. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69273. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69274. * @returns the shadow generator allowing fluent coding.
  69275. */
  69276. setDarkness(darkness: number): ShadowGenerator;
  69277. private _transparencyShadow;
  69278. /**
  69279. * Sets the ability to have transparent shadow (boolean).
  69280. * @param transparent True if transparent else False
  69281. * @returns the shadow generator allowing fluent coding
  69282. */
  69283. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69284. private _shadowMap;
  69285. private _shadowMap2;
  69286. /**
  69287. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69288. * @returns The render target texture if present otherwise, null
  69289. */
  69290. getShadowMap(): Nullable<RenderTargetTexture>;
  69291. /**
  69292. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69293. * @returns The render target texture if the shadow map is present otherwise, null
  69294. */
  69295. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69296. /**
  69297. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69298. * @param mesh Mesh to add
  69299. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69300. * @returns the Shadow Generator itself
  69301. */
  69302. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69303. /**
  69304. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69305. * @param mesh Mesh to remove
  69306. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69307. * @returns the Shadow Generator itself
  69308. */
  69309. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69310. /**
  69311. * Controls the extent to which the shadows fade out at the edge of the frustum
  69312. * Used only by directionals and spots
  69313. */
  69314. frustumEdgeFalloff: number;
  69315. private _light;
  69316. /**
  69317. * Returns the associated light object.
  69318. * @returns the light generating the shadow
  69319. */
  69320. getLight(): IShadowLight;
  69321. /**
  69322. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69323. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69324. * It might on the other hand introduce peter panning.
  69325. */
  69326. forceBackFacesOnly: boolean;
  69327. private _scene;
  69328. private _lightDirection;
  69329. private _effect;
  69330. private _viewMatrix;
  69331. private _projectionMatrix;
  69332. private _transformMatrix;
  69333. private _cachedPosition;
  69334. private _cachedDirection;
  69335. private _cachedDefines;
  69336. private _currentRenderID;
  69337. private _boxBlurPostprocess;
  69338. private _kernelBlurXPostprocess;
  69339. private _kernelBlurYPostprocess;
  69340. private _blurPostProcesses;
  69341. private _mapSize;
  69342. private _currentFaceIndex;
  69343. private _currentFaceIndexCache;
  69344. private _textureType;
  69345. private _defaultTextureMatrix;
  69346. /** @hidden */
  69347. static _SceneComponentInitialization: (scene: Scene) => void;
  69348. /**
  69349. * Creates a ShadowGenerator object.
  69350. * A ShadowGenerator is the required tool to use the shadows.
  69351. * Each light casting shadows needs to use its own ShadowGenerator.
  69352. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69353. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69354. * @param light The light object generating the shadows.
  69355. * @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.
  69356. */
  69357. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69358. private _initializeGenerator;
  69359. private _initializeShadowMap;
  69360. private _initializeBlurRTTAndPostProcesses;
  69361. private _renderForShadowMap;
  69362. private _renderSubMeshForShadowMap;
  69363. private _applyFilterValues;
  69364. /**
  69365. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69366. * @param onCompiled Callback triggered at the and of the effects compilation
  69367. * @param options Sets of optional options forcing the compilation with different modes
  69368. */
  69369. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69370. useInstances: boolean;
  69371. }>): void;
  69372. /**
  69373. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69374. * @param options Sets of optional options forcing the compilation with different modes
  69375. * @returns A promise that resolves when the compilation completes
  69376. */
  69377. forceCompilationAsync(options?: Partial<{
  69378. useInstances: boolean;
  69379. }>): Promise<void>;
  69380. /**
  69381. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69382. * @param subMesh The submesh we want to render in the shadow map
  69383. * @param useInstances Defines wether will draw in the map using instances
  69384. * @returns true if ready otherwise, false
  69385. */
  69386. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69387. /**
  69388. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69389. * @param defines Defines of the material we want to update
  69390. * @param lightIndex Index of the light in the enabled light list of the material
  69391. */
  69392. prepareDefines(defines: any, lightIndex: number): void;
  69393. /**
  69394. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69395. * defined in the generator but impacting the effect).
  69396. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69397. * @param effect The effect we are binfing the information for
  69398. */
  69399. bindShadowLight(lightIndex: string, effect: Effect): void;
  69400. /**
  69401. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69402. * (eq to shadow prjection matrix * light transform matrix)
  69403. * @returns The transform matrix used to create the shadow map
  69404. */
  69405. getTransformMatrix(): Matrix;
  69406. /**
  69407. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69408. * Cube and 2D textures for instance.
  69409. */
  69410. recreateShadowMap(): void;
  69411. private _disposeBlurPostProcesses;
  69412. private _disposeRTTandPostProcesses;
  69413. /**
  69414. * Disposes the ShadowGenerator.
  69415. * Returns nothing.
  69416. */
  69417. dispose(): void;
  69418. /**
  69419. * Serializes the shadow generator setup to a json object.
  69420. * @returns The serialized JSON object
  69421. */
  69422. serialize(): any;
  69423. /**
  69424. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69425. * @param parsedShadowGenerator The JSON object to parse
  69426. * @param scene The scene to create the shadow map for
  69427. * @returns The parsed shadow generator
  69428. */
  69429. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69430. }
  69431. }
  69432. declare module BABYLON {
  69433. /**
  69434. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69435. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69436. * 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.
  69437. */
  69438. export abstract class Light extends Node {
  69439. /**
  69440. * Falloff Default: light is falling off following the material specification:
  69441. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69442. */
  69443. static readonly FALLOFF_DEFAULT: number;
  69444. /**
  69445. * Falloff Physical: light is falling off following the inverse squared distance law.
  69446. */
  69447. static readonly FALLOFF_PHYSICAL: number;
  69448. /**
  69449. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69450. * to enhance interoperability with other engines.
  69451. */
  69452. static readonly FALLOFF_GLTF: number;
  69453. /**
  69454. * Falloff Standard: light is falling off like in the standard material
  69455. * to enhance interoperability with other materials.
  69456. */
  69457. static readonly FALLOFF_STANDARD: number;
  69458. /**
  69459. * If every light affecting the material is in this lightmapMode,
  69460. * material.lightmapTexture adds or multiplies
  69461. * (depends on material.useLightmapAsShadowmap)
  69462. * after every other light calculations.
  69463. */
  69464. static readonly LIGHTMAP_DEFAULT: number;
  69465. /**
  69466. * material.lightmapTexture as only diffuse lighting from this light
  69467. * adds only specular lighting from this light
  69468. * adds dynamic shadows
  69469. */
  69470. static readonly LIGHTMAP_SPECULAR: number;
  69471. /**
  69472. * material.lightmapTexture as only lighting
  69473. * no light calculation from this light
  69474. * only adds dynamic shadows from this light
  69475. */
  69476. static readonly LIGHTMAP_SHADOWSONLY: number;
  69477. /**
  69478. * Each light type uses the default quantity according to its type:
  69479. * point/spot lights use luminous intensity
  69480. * directional lights use illuminance
  69481. */
  69482. static readonly INTENSITYMODE_AUTOMATIC: number;
  69483. /**
  69484. * lumen (lm)
  69485. */
  69486. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69487. /**
  69488. * candela (lm/sr)
  69489. */
  69490. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69491. /**
  69492. * lux (lm/m^2)
  69493. */
  69494. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69495. /**
  69496. * nit (cd/m^2)
  69497. */
  69498. static readonly INTENSITYMODE_LUMINANCE: number;
  69499. /**
  69500. * Light type const id of the point light.
  69501. */
  69502. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69503. /**
  69504. * Light type const id of the directional light.
  69505. */
  69506. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69507. /**
  69508. * Light type const id of the spot light.
  69509. */
  69510. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69511. /**
  69512. * Light type const id of the hemispheric light.
  69513. */
  69514. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69515. /**
  69516. * Diffuse gives the basic color to an object.
  69517. */
  69518. diffuse: Color3;
  69519. /**
  69520. * Specular produces a highlight color on an object.
  69521. * Note: This is note affecting PBR materials.
  69522. */
  69523. specular: Color3;
  69524. /**
  69525. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69526. * falling off base on range or angle.
  69527. * This can be set to any values in Light.FALLOFF_x.
  69528. *
  69529. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69530. * other types of materials.
  69531. */
  69532. falloffType: number;
  69533. /**
  69534. * Strength of the light.
  69535. * Note: By default it is define in the framework own unit.
  69536. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69537. */
  69538. intensity: number;
  69539. private _range;
  69540. protected _inverseSquaredRange: number;
  69541. /**
  69542. * Defines how far from the source the light is impacting in scene units.
  69543. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69544. */
  69545. /**
  69546. * Defines how far from the source the light is impacting in scene units.
  69547. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69548. */
  69549. range: number;
  69550. /**
  69551. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  69552. * of light.
  69553. */
  69554. private _photometricScale;
  69555. private _intensityMode;
  69556. /**
  69557. * Gets the photometric scale used to interpret the intensity.
  69558. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69559. */
  69560. /**
  69561. * Sets the photometric scale used to interpret the intensity.
  69562. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69563. */
  69564. intensityMode: number;
  69565. private _radius;
  69566. /**
  69567. * Gets the light radius used by PBR Materials to simulate soft area lights.
  69568. */
  69569. /**
  69570. * sets the light radius used by PBR Materials to simulate soft area lights.
  69571. */
  69572. radius: number;
  69573. private _renderPriority;
  69574. /**
  69575. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  69576. * exceeding the number allowed of the materials.
  69577. */
  69578. renderPriority: number;
  69579. private _shadowEnabled;
  69580. /**
  69581. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69582. * the current shadow generator.
  69583. */
  69584. /**
  69585. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69586. * the current shadow generator.
  69587. */
  69588. shadowEnabled: boolean;
  69589. private _includedOnlyMeshes;
  69590. /**
  69591. * Gets the only meshes impacted by this light.
  69592. */
  69593. /**
  69594. * Sets the only meshes impacted by this light.
  69595. */
  69596. includedOnlyMeshes: AbstractMesh[];
  69597. private _excludedMeshes;
  69598. /**
  69599. * Gets the meshes not impacted by this light.
  69600. */
  69601. /**
  69602. * Sets the meshes not impacted by this light.
  69603. */
  69604. excludedMeshes: AbstractMesh[];
  69605. private _excludeWithLayerMask;
  69606. /**
  69607. * Gets the layer id use to find what meshes are not impacted by the light.
  69608. * Inactive if 0
  69609. */
  69610. /**
  69611. * Sets the layer id use to find what meshes are not impacted by the light.
  69612. * Inactive if 0
  69613. */
  69614. excludeWithLayerMask: number;
  69615. private _includeOnlyWithLayerMask;
  69616. /**
  69617. * Gets the layer id use to find what meshes are impacted by the light.
  69618. * Inactive if 0
  69619. */
  69620. /**
  69621. * Sets the layer id use to find what meshes are impacted by the light.
  69622. * Inactive if 0
  69623. */
  69624. includeOnlyWithLayerMask: number;
  69625. private _lightmapMode;
  69626. /**
  69627. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69628. */
  69629. /**
  69630. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69631. */
  69632. lightmapMode: number;
  69633. /**
  69634. * Shadow generator associted to the light.
  69635. * @hidden Internal use only.
  69636. */
  69637. _shadowGenerator: Nullable<IShadowGenerator>;
  69638. /**
  69639. * @hidden Internal use only.
  69640. */
  69641. _excludedMeshesIds: string[];
  69642. /**
  69643. * @hidden Internal use only.
  69644. */
  69645. _includedOnlyMeshesIds: string[];
  69646. /**
  69647. * The current light unifom buffer.
  69648. * @hidden Internal use only.
  69649. */
  69650. _uniformBuffer: UniformBuffer;
  69651. /**
  69652. * Creates a Light object in the scene.
  69653. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69654. * @param name The firendly name of the light
  69655. * @param scene The scene the light belongs too
  69656. */
  69657. constructor(name: string, scene: Scene);
  69658. protected abstract _buildUniformLayout(): void;
  69659. /**
  69660. * Sets the passed Effect "effect" with the Light information.
  69661. * @param effect The effect to update
  69662. * @param lightIndex The index of the light in the effect to update
  69663. * @returns The light
  69664. */
  69665. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  69666. /**
  69667. * Returns the string "Light".
  69668. * @returns the class name
  69669. */
  69670. getClassName(): string;
  69671. /** @hidden */
  69672. readonly _isLight: boolean;
  69673. /**
  69674. * Converts the light information to a readable string for debug purpose.
  69675. * @param fullDetails Supports for multiple levels of logging within scene loading
  69676. * @returns the human readable light info
  69677. */
  69678. toString(fullDetails?: boolean): string;
  69679. /** @hidden */
  69680. protected _syncParentEnabledState(): void;
  69681. /**
  69682. * Set the enabled state of this node.
  69683. * @param value - the new enabled state
  69684. */
  69685. setEnabled(value: boolean): void;
  69686. /**
  69687. * Returns the Light associated shadow generator if any.
  69688. * @return the associated shadow generator.
  69689. */
  69690. getShadowGenerator(): Nullable<IShadowGenerator>;
  69691. /**
  69692. * Returns a Vector3, the absolute light position in the World.
  69693. * @returns the world space position of the light
  69694. */
  69695. getAbsolutePosition(): Vector3;
  69696. /**
  69697. * Specifies if the light will affect the passed mesh.
  69698. * @param mesh The mesh to test against the light
  69699. * @return true the mesh is affected otherwise, false.
  69700. */
  69701. canAffectMesh(mesh: AbstractMesh): boolean;
  69702. /**
  69703. * Sort function to order lights for rendering.
  69704. * @param a First Light object to compare to second.
  69705. * @param b Second Light object to compare first.
  69706. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  69707. */
  69708. static CompareLightsPriority(a: Light, b: Light): number;
  69709. /**
  69710. * Releases resources associated with this node.
  69711. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69712. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69713. */
  69714. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69715. /**
  69716. * Returns the light type ID (integer).
  69717. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69718. */
  69719. getTypeID(): number;
  69720. /**
  69721. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  69722. * @returns the scaled intensity in intensity mode unit
  69723. */
  69724. getScaledIntensity(): number;
  69725. /**
  69726. * Returns a new Light object, named "name", from the current one.
  69727. * @param name The name of the cloned light
  69728. * @returns the new created light
  69729. */
  69730. clone(name: string): Nullable<Light>;
  69731. /**
  69732. * Serializes the current light into a Serialization object.
  69733. * @returns the serialized object.
  69734. */
  69735. serialize(): any;
  69736. /**
  69737. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  69738. * This new light is named "name" and added to the passed scene.
  69739. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  69740. * @param name The friendly name of the light
  69741. * @param scene The scene the new light will belong to
  69742. * @returns the constructor function
  69743. */
  69744. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  69745. /**
  69746. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  69747. * @param parsedLight The JSON representation of the light
  69748. * @param scene The scene to create the parsed light in
  69749. * @returns the created light after parsing
  69750. */
  69751. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  69752. private _hookArrayForExcluded;
  69753. private _hookArrayForIncludedOnly;
  69754. private _resyncMeshes;
  69755. /**
  69756. * Forces the meshes to update their light related information in their rendering used effects
  69757. * @hidden Internal Use Only
  69758. */
  69759. _markMeshesAsLightDirty(): void;
  69760. /**
  69761. * Recomputes the cached photometric scale if needed.
  69762. */
  69763. private _computePhotometricScale;
  69764. /**
  69765. * Returns the Photometric Scale according to the light type and intensity mode.
  69766. */
  69767. private _getPhotometricScale;
  69768. /**
  69769. * Reorder the light in the scene according to their defined priority.
  69770. * @hidden Internal Use Only
  69771. */
  69772. _reorderLightsInScene(): void;
  69773. /**
  69774. * Prepares the list of defines specific to the light type.
  69775. * @param defines the list of defines
  69776. * @param lightIndex defines the index of the light for the effect
  69777. */
  69778. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69779. }
  69780. }
  69781. declare module BABYLON {
  69782. /**
  69783. * Interface used to define Action
  69784. */
  69785. export interface IAction {
  69786. /**
  69787. * Trigger for the action
  69788. */
  69789. trigger: number;
  69790. /** Options of the trigger */
  69791. triggerOptions: any;
  69792. /**
  69793. * Gets the trigger parameters
  69794. * @returns the trigger parameters
  69795. */
  69796. getTriggerParameter(): any;
  69797. /**
  69798. * Internal only - executes current action event
  69799. * @hidden
  69800. */
  69801. _executeCurrent(evt?: ActionEvent): void;
  69802. /**
  69803. * Serialize placeholder for child classes
  69804. * @param parent of child
  69805. * @returns the serialized object
  69806. */
  69807. serialize(parent: any): any;
  69808. /**
  69809. * Internal only
  69810. * @hidden
  69811. */
  69812. _prepare(): void;
  69813. /**
  69814. * Internal only - manager for action
  69815. * @hidden
  69816. */
  69817. _actionManager: AbstractActionManager;
  69818. }
  69819. /**
  69820. * The action to be carried out following a trigger
  69821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69822. */
  69823. export class Action implements IAction {
  69824. /** the trigger, with or without parameters, for the action */
  69825. triggerOptions: any;
  69826. /**
  69827. * Trigger for the action
  69828. */
  69829. trigger: number;
  69830. /**
  69831. * Internal only - manager for action
  69832. * @hidden
  69833. */
  69834. _actionManager: ActionManager;
  69835. private _nextActiveAction;
  69836. private _child;
  69837. private _condition?;
  69838. private _triggerParameter;
  69839. /**
  69840. * An event triggered prior to action being executed.
  69841. */
  69842. onBeforeExecuteObservable: Observable<Action>;
  69843. /**
  69844. * Creates a new Action
  69845. * @param triggerOptions the trigger, with or without parameters, for the action
  69846. * @param condition an optional determinant of action
  69847. */
  69848. constructor(
  69849. /** the trigger, with or without parameters, for the action */
  69850. triggerOptions: any, condition?: Condition);
  69851. /**
  69852. * Internal only
  69853. * @hidden
  69854. */
  69855. _prepare(): void;
  69856. /**
  69857. * Gets the trigger parameters
  69858. * @returns the trigger parameters
  69859. */
  69860. getTriggerParameter(): any;
  69861. /**
  69862. * Internal only - executes current action event
  69863. * @hidden
  69864. */
  69865. _executeCurrent(evt?: ActionEvent): void;
  69866. /**
  69867. * Execute placeholder for child classes
  69868. * @param evt optional action event
  69869. */
  69870. execute(evt?: ActionEvent): void;
  69871. /**
  69872. * Skips to next active action
  69873. */
  69874. skipToNextActiveAction(): void;
  69875. /**
  69876. * Adds action to chain of actions, may be a DoNothingAction
  69877. * @param action defines the next action to execute
  69878. * @returns The action passed in
  69879. * @see https://www.babylonjs-playground.com/#1T30HR#0
  69880. */
  69881. then(action: Action): Action;
  69882. /**
  69883. * Internal only
  69884. * @hidden
  69885. */
  69886. _getProperty(propertyPath: string): string;
  69887. /**
  69888. * Internal only
  69889. * @hidden
  69890. */
  69891. _getEffectiveTarget(target: any, propertyPath: string): any;
  69892. /**
  69893. * Serialize placeholder for child classes
  69894. * @param parent of child
  69895. * @returns the serialized object
  69896. */
  69897. serialize(parent: any): any;
  69898. /**
  69899. * Internal only called by serialize
  69900. * @hidden
  69901. */
  69902. protected _serialize(serializedAction: any, parent?: any): any;
  69903. /**
  69904. * Internal only
  69905. * @hidden
  69906. */
  69907. static _SerializeValueAsString: (value: any) => string;
  69908. /**
  69909. * Internal only
  69910. * @hidden
  69911. */
  69912. static _GetTargetProperty: (target: Scene | Node) => {
  69913. name: string;
  69914. targetType: string;
  69915. value: string;
  69916. };
  69917. }
  69918. }
  69919. declare module BABYLON {
  69920. /**
  69921. * A Condition applied to an Action
  69922. */
  69923. export class Condition {
  69924. /**
  69925. * Internal only - manager for action
  69926. * @hidden
  69927. */
  69928. _actionManager: ActionManager;
  69929. /**
  69930. * Internal only
  69931. * @hidden
  69932. */
  69933. _evaluationId: number;
  69934. /**
  69935. * Internal only
  69936. * @hidden
  69937. */
  69938. _currentResult: boolean;
  69939. /**
  69940. * Creates a new Condition
  69941. * @param actionManager the manager of the action the condition is applied to
  69942. */
  69943. constructor(actionManager: ActionManager);
  69944. /**
  69945. * Check if the current condition is valid
  69946. * @returns a boolean
  69947. */
  69948. isValid(): boolean;
  69949. /**
  69950. * Internal only
  69951. * @hidden
  69952. */
  69953. _getProperty(propertyPath: string): string;
  69954. /**
  69955. * Internal only
  69956. * @hidden
  69957. */
  69958. _getEffectiveTarget(target: any, propertyPath: string): any;
  69959. /**
  69960. * Serialize placeholder for child classes
  69961. * @returns the serialized object
  69962. */
  69963. serialize(): any;
  69964. /**
  69965. * Internal only
  69966. * @hidden
  69967. */
  69968. protected _serialize(serializedCondition: any): any;
  69969. }
  69970. /**
  69971. * Defines specific conditional operators as extensions of Condition
  69972. */
  69973. export class ValueCondition extends Condition {
  69974. /** path to specify the property of the target the conditional operator uses */
  69975. propertyPath: string;
  69976. /** the value compared by the conditional operator against the current value of the property */
  69977. value: any;
  69978. /** the conditional operator, default ValueCondition.IsEqual */
  69979. operator: number;
  69980. /**
  69981. * Internal only
  69982. * @hidden
  69983. */
  69984. private static _IsEqual;
  69985. /**
  69986. * Internal only
  69987. * @hidden
  69988. */
  69989. private static _IsDifferent;
  69990. /**
  69991. * Internal only
  69992. * @hidden
  69993. */
  69994. private static _IsGreater;
  69995. /**
  69996. * Internal only
  69997. * @hidden
  69998. */
  69999. private static _IsLesser;
  70000. /**
  70001. * returns the number for IsEqual
  70002. */
  70003. static readonly IsEqual: number;
  70004. /**
  70005. * Returns the number for IsDifferent
  70006. */
  70007. static readonly IsDifferent: number;
  70008. /**
  70009. * Returns the number for IsGreater
  70010. */
  70011. static readonly IsGreater: number;
  70012. /**
  70013. * Returns the number for IsLesser
  70014. */
  70015. static readonly IsLesser: number;
  70016. /**
  70017. * Internal only The action manager for the condition
  70018. * @hidden
  70019. */
  70020. _actionManager: ActionManager;
  70021. /**
  70022. * Internal only
  70023. * @hidden
  70024. */
  70025. private _target;
  70026. /**
  70027. * Internal only
  70028. * @hidden
  70029. */
  70030. private _effectiveTarget;
  70031. /**
  70032. * Internal only
  70033. * @hidden
  70034. */
  70035. private _property;
  70036. /**
  70037. * Creates a new ValueCondition
  70038. * @param actionManager manager for the action the condition applies to
  70039. * @param target for the action
  70040. * @param propertyPath path to specify the property of the target the conditional operator uses
  70041. * @param value the value compared by the conditional operator against the current value of the property
  70042. * @param operator the conditional operator, default ValueCondition.IsEqual
  70043. */
  70044. constructor(actionManager: ActionManager, target: any,
  70045. /** path to specify the property of the target the conditional operator uses */
  70046. propertyPath: string,
  70047. /** the value compared by the conditional operator against the current value of the property */
  70048. value: any,
  70049. /** the conditional operator, default ValueCondition.IsEqual */
  70050. operator?: number);
  70051. /**
  70052. * Compares the given value with the property value for the specified conditional operator
  70053. * @returns the result of the comparison
  70054. */
  70055. isValid(): boolean;
  70056. /**
  70057. * Serialize the ValueCondition into a JSON compatible object
  70058. * @returns serialization object
  70059. */
  70060. serialize(): any;
  70061. /**
  70062. * Gets the name of the conditional operator for the ValueCondition
  70063. * @param operator the conditional operator
  70064. * @returns the name
  70065. */
  70066. static GetOperatorName(operator: number): string;
  70067. }
  70068. /**
  70069. * Defines a predicate condition as an extension of Condition
  70070. */
  70071. export class PredicateCondition extends Condition {
  70072. /** defines the predicate function used to validate the condition */
  70073. predicate: () => boolean;
  70074. /**
  70075. * Internal only - manager for action
  70076. * @hidden
  70077. */
  70078. _actionManager: ActionManager;
  70079. /**
  70080. * Creates a new PredicateCondition
  70081. * @param actionManager manager for the action the condition applies to
  70082. * @param predicate defines the predicate function used to validate the condition
  70083. */
  70084. constructor(actionManager: ActionManager,
  70085. /** defines the predicate function used to validate the condition */
  70086. predicate: () => boolean);
  70087. /**
  70088. * @returns the validity of the predicate condition
  70089. */
  70090. isValid(): boolean;
  70091. }
  70092. /**
  70093. * Defines a state condition as an extension of Condition
  70094. */
  70095. export class StateCondition extends Condition {
  70096. /** Value to compare with target state */
  70097. value: string;
  70098. /**
  70099. * Internal only - manager for action
  70100. * @hidden
  70101. */
  70102. _actionManager: ActionManager;
  70103. /**
  70104. * Internal only
  70105. * @hidden
  70106. */
  70107. private _target;
  70108. /**
  70109. * Creates a new StateCondition
  70110. * @param actionManager manager for the action the condition applies to
  70111. * @param target of the condition
  70112. * @param value to compare with target state
  70113. */
  70114. constructor(actionManager: ActionManager, target: any,
  70115. /** Value to compare with target state */
  70116. value: string);
  70117. /**
  70118. * Gets a boolean indicating if the current condition is met
  70119. * @returns the validity of the state
  70120. */
  70121. isValid(): boolean;
  70122. /**
  70123. * Serialize the StateCondition into a JSON compatible object
  70124. * @returns serialization object
  70125. */
  70126. serialize(): any;
  70127. }
  70128. }
  70129. declare module BABYLON {
  70130. /**
  70131. * This defines an action responsible to toggle a boolean once triggered.
  70132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70133. */
  70134. export class SwitchBooleanAction extends Action {
  70135. /**
  70136. * The path to the boolean property in the target object
  70137. */
  70138. propertyPath: string;
  70139. private _target;
  70140. private _effectiveTarget;
  70141. private _property;
  70142. /**
  70143. * Instantiate the action
  70144. * @param triggerOptions defines the trigger options
  70145. * @param target defines the object containing the boolean
  70146. * @param propertyPath defines the path to the boolean property in the target object
  70147. * @param condition defines the trigger related conditions
  70148. */
  70149. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70150. /** @hidden */
  70151. _prepare(): void;
  70152. /**
  70153. * Execute the action toggle the boolean value.
  70154. */
  70155. execute(): void;
  70156. /**
  70157. * Serializes the actions and its related information.
  70158. * @param parent defines the object to serialize in
  70159. * @returns the serialized object
  70160. */
  70161. serialize(parent: any): any;
  70162. }
  70163. /**
  70164. * This defines an action responsible to set a the state field of the target
  70165. * to a desired value once triggered.
  70166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70167. */
  70168. export class SetStateAction extends Action {
  70169. /**
  70170. * The value to store in the state field.
  70171. */
  70172. value: string;
  70173. private _target;
  70174. /**
  70175. * Instantiate the action
  70176. * @param triggerOptions defines the trigger options
  70177. * @param target defines the object containing the state property
  70178. * @param value defines the value to store in the state field
  70179. * @param condition defines the trigger related conditions
  70180. */
  70181. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70182. /**
  70183. * Execute the action and store the value on the target state property.
  70184. */
  70185. execute(): void;
  70186. /**
  70187. * Serializes the actions and its related information.
  70188. * @param parent defines the object to serialize in
  70189. * @returns the serialized object
  70190. */
  70191. serialize(parent: any): any;
  70192. }
  70193. /**
  70194. * This defines an action responsible to set a property of the target
  70195. * to a desired value once triggered.
  70196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70197. */
  70198. export class SetValueAction extends Action {
  70199. /**
  70200. * The path of the property to set in the target.
  70201. */
  70202. propertyPath: string;
  70203. /**
  70204. * The value to set in the property
  70205. */
  70206. value: any;
  70207. private _target;
  70208. private _effectiveTarget;
  70209. private _property;
  70210. /**
  70211. * Instantiate the action
  70212. * @param triggerOptions defines the trigger options
  70213. * @param target defines the object containing the property
  70214. * @param propertyPath defines the path of the property to set in the target
  70215. * @param value defines the value to set in the property
  70216. * @param condition defines the trigger related conditions
  70217. */
  70218. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70219. /** @hidden */
  70220. _prepare(): void;
  70221. /**
  70222. * Execute the action and set the targetted property to the desired value.
  70223. */
  70224. execute(): void;
  70225. /**
  70226. * Serializes the actions and its related information.
  70227. * @param parent defines the object to serialize in
  70228. * @returns the serialized object
  70229. */
  70230. serialize(parent: any): any;
  70231. }
  70232. /**
  70233. * This defines an action responsible to increment the target value
  70234. * to a desired value once triggered.
  70235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70236. */
  70237. export class IncrementValueAction extends Action {
  70238. /**
  70239. * The path of the property to increment in the target.
  70240. */
  70241. propertyPath: string;
  70242. /**
  70243. * The value we should increment the property by.
  70244. */
  70245. value: any;
  70246. private _target;
  70247. private _effectiveTarget;
  70248. private _property;
  70249. /**
  70250. * Instantiate the action
  70251. * @param triggerOptions defines the trigger options
  70252. * @param target defines the object containing the property
  70253. * @param propertyPath defines the path of the property to increment in the target
  70254. * @param value defines the value value we should increment the property by
  70255. * @param condition defines the trigger related conditions
  70256. */
  70257. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70258. /** @hidden */
  70259. _prepare(): void;
  70260. /**
  70261. * Execute the action and increment the target of the value amount.
  70262. */
  70263. execute(): void;
  70264. /**
  70265. * Serializes the actions and its related information.
  70266. * @param parent defines the object to serialize in
  70267. * @returns the serialized object
  70268. */
  70269. serialize(parent: any): any;
  70270. }
  70271. /**
  70272. * This defines an action responsible to start an animation once triggered.
  70273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70274. */
  70275. export class PlayAnimationAction extends Action {
  70276. /**
  70277. * Where the animation should start (animation frame)
  70278. */
  70279. from: number;
  70280. /**
  70281. * Where the animation should stop (animation frame)
  70282. */
  70283. to: number;
  70284. /**
  70285. * Define if the animation should loop or stop after the first play.
  70286. */
  70287. loop?: boolean;
  70288. private _target;
  70289. /**
  70290. * Instantiate the action
  70291. * @param triggerOptions defines the trigger options
  70292. * @param target defines the target animation or animation name
  70293. * @param from defines from where the animation should start (animation frame)
  70294. * @param end defines where the animation should stop (animation frame)
  70295. * @param loop defines if the animation should loop or stop after the first play
  70296. * @param condition defines the trigger related conditions
  70297. */
  70298. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70299. /** @hidden */
  70300. _prepare(): void;
  70301. /**
  70302. * Execute the action and play the animation.
  70303. */
  70304. execute(): void;
  70305. /**
  70306. * Serializes the actions and its related information.
  70307. * @param parent defines the object to serialize in
  70308. * @returns the serialized object
  70309. */
  70310. serialize(parent: any): any;
  70311. }
  70312. /**
  70313. * This defines an action responsible to stop an animation once triggered.
  70314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70315. */
  70316. export class StopAnimationAction extends Action {
  70317. private _target;
  70318. /**
  70319. * Instantiate the action
  70320. * @param triggerOptions defines the trigger options
  70321. * @param target defines the target animation or animation name
  70322. * @param condition defines the trigger related conditions
  70323. */
  70324. constructor(triggerOptions: any, target: any, condition?: Condition);
  70325. /** @hidden */
  70326. _prepare(): void;
  70327. /**
  70328. * Execute the action and stop the animation.
  70329. */
  70330. execute(): void;
  70331. /**
  70332. * Serializes the actions and its related information.
  70333. * @param parent defines the object to serialize in
  70334. * @returns the serialized object
  70335. */
  70336. serialize(parent: any): any;
  70337. }
  70338. /**
  70339. * This defines an action responsible that does nothing once triggered.
  70340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70341. */
  70342. export class DoNothingAction extends Action {
  70343. /**
  70344. * Instantiate the action
  70345. * @param triggerOptions defines the trigger options
  70346. * @param condition defines the trigger related conditions
  70347. */
  70348. constructor(triggerOptions?: any, condition?: Condition);
  70349. /**
  70350. * Execute the action and do nothing.
  70351. */
  70352. execute(): void;
  70353. /**
  70354. * Serializes the actions and its related information.
  70355. * @param parent defines the object to serialize in
  70356. * @returns the serialized object
  70357. */
  70358. serialize(parent: any): any;
  70359. }
  70360. /**
  70361. * This defines an action responsible to trigger several actions once triggered.
  70362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70363. */
  70364. export class CombineAction extends Action {
  70365. /**
  70366. * The list of aggregated animations to run.
  70367. */
  70368. children: Action[];
  70369. /**
  70370. * Instantiate the action
  70371. * @param triggerOptions defines the trigger options
  70372. * @param children defines the list of aggregated animations to run
  70373. * @param condition defines the trigger related conditions
  70374. */
  70375. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70376. /** @hidden */
  70377. _prepare(): void;
  70378. /**
  70379. * Execute the action and executes all the aggregated actions.
  70380. */
  70381. execute(evt: ActionEvent): void;
  70382. /**
  70383. * Serializes the actions and its related information.
  70384. * @param parent defines the object to serialize in
  70385. * @returns the serialized object
  70386. */
  70387. serialize(parent: any): any;
  70388. }
  70389. /**
  70390. * This defines an action responsible to run code (external event) once triggered.
  70391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70392. */
  70393. export class ExecuteCodeAction extends Action {
  70394. /**
  70395. * The callback function to run.
  70396. */
  70397. func: (evt: ActionEvent) => void;
  70398. /**
  70399. * Instantiate the action
  70400. * @param triggerOptions defines the trigger options
  70401. * @param func defines the callback function to run
  70402. * @param condition defines the trigger related conditions
  70403. */
  70404. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70405. /**
  70406. * Execute the action and run the attached code.
  70407. */
  70408. execute(evt: ActionEvent): void;
  70409. }
  70410. /**
  70411. * This defines an action responsible to set the parent property of the target once triggered.
  70412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70413. */
  70414. export class SetParentAction extends Action {
  70415. private _parent;
  70416. private _target;
  70417. /**
  70418. * Instantiate the action
  70419. * @param triggerOptions defines the trigger options
  70420. * @param target defines the target containing the parent property
  70421. * @param parent defines from where the animation should start (animation frame)
  70422. * @param condition defines the trigger related conditions
  70423. */
  70424. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70425. /** @hidden */
  70426. _prepare(): void;
  70427. /**
  70428. * Execute the action and set the parent property.
  70429. */
  70430. execute(): void;
  70431. /**
  70432. * Serializes the actions and its related information.
  70433. * @param parent defines the object to serialize in
  70434. * @returns the serialized object
  70435. */
  70436. serialize(parent: any): any;
  70437. }
  70438. }
  70439. declare module BABYLON {
  70440. /**
  70441. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70442. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70444. */
  70445. export class ActionManager extends AbstractActionManager {
  70446. /**
  70447. * Nothing
  70448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70449. */
  70450. static readonly NothingTrigger: number;
  70451. /**
  70452. * On pick
  70453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70454. */
  70455. static readonly OnPickTrigger: number;
  70456. /**
  70457. * On left pick
  70458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70459. */
  70460. static readonly OnLeftPickTrigger: number;
  70461. /**
  70462. * On right pick
  70463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70464. */
  70465. static readonly OnRightPickTrigger: number;
  70466. /**
  70467. * On center pick
  70468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70469. */
  70470. static readonly OnCenterPickTrigger: number;
  70471. /**
  70472. * On pick down
  70473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70474. */
  70475. static readonly OnPickDownTrigger: number;
  70476. /**
  70477. * On double pick
  70478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70479. */
  70480. static readonly OnDoublePickTrigger: number;
  70481. /**
  70482. * On pick up
  70483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70484. */
  70485. static readonly OnPickUpTrigger: number;
  70486. /**
  70487. * On pick out.
  70488. * This trigger will only be raised if you also declared a OnPickDown
  70489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70490. */
  70491. static readonly OnPickOutTrigger: number;
  70492. /**
  70493. * On long press
  70494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70495. */
  70496. static readonly OnLongPressTrigger: number;
  70497. /**
  70498. * On pointer over
  70499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70500. */
  70501. static readonly OnPointerOverTrigger: number;
  70502. /**
  70503. * On pointer out
  70504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70505. */
  70506. static readonly OnPointerOutTrigger: number;
  70507. /**
  70508. * On every frame
  70509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70510. */
  70511. static readonly OnEveryFrameTrigger: number;
  70512. /**
  70513. * On intersection enter
  70514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70515. */
  70516. static readonly OnIntersectionEnterTrigger: number;
  70517. /**
  70518. * On intersection exit
  70519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70520. */
  70521. static readonly OnIntersectionExitTrigger: number;
  70522. /**
  70523. * On key down
  70524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70525. */
  70526. static readonly OnKeyDownTrigger: number;
  70527. /**
  70528. * On key up
  70529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70530. */
  70531. static readonly OnKeyUpTrigger: number;
  70532. private _scene;
  70533. /**
  70534. * Creates a new action manager
  70535. * @param scene defines the hosting scene
  70536. */
  70537. constructor(scene: Scene);
  70538. /**
  70539. * Releases all associated resources
  70540. */
  70541. dispose(): void;
  70542. /**
  70543. * Gets hosting scene
  70544. * @returns the hosting scene
  70545. */
  70546. getScene(): Scene;
  70547. /**
  70548. * Does this action manager handles actions of any of the given triggers
  70549. * @param triggers defines the triggers to be tested
  70550. * @return a boolean indicating whether one (or more) of the triggers is handled
  70551. */
  70552. hasSpecificTriggers(triggers: number[]): boolean;
  70553. /**
  70554. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  70555. * speed.
  70556. * @param triggerA defines the trigger to be tested
  70557. * @param triggerB defines the trigger to be tested
  70558. * @return a boolean indicating whether one (or more) of the triggers is handled
  70559. */
  70560. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  70561. /**
  70562. * Does this action manager handles actions of a given trigger
  70563. * @param trigger defines the trigger to be tested
  70564. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  70565. * @return whether the trigger is handled
  70566. */
  70567. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  70568. /**
  70569. * Does this action manager has pointer triggers
  70570. */
  70571. readonly hasPointerTriggers: boolean;
  70572. /**
  70573. * Does this action manager has pick triggers
  70574. */
  70575. readonly hasPickTriggers: boolean;
  70576. /**
  70577. * Registers an action to this action manager
  70578. * @param action defines the action to be registered
  70579. * @return the action amended (prepared) after registration
  70580. */
  70581. registerAction(action: IAction): Nullable<IAction>;
  70582. /**
  70583. * Unregisters an action to this action manager
  70584. * @param action defines the action to be unregistered
  70585. * @return a boolean indicating whether the action has been unregistered
  70586. */
  70587. unregisterAction(action: IAction): Boolean;
  70588. /**
  70589. * Process a specific trigger
  70590. * @param trigger defines the trigger to process
  70591. * @param evt defines the event details to be processed
  70592. */
  70593. processTrigger(trigger: number, evt?: IActionEvent): void;
  70594. /** @hidden */
  70595. _getEffectiveTarget(target: any, propertyPath: string): any;
  70596. /** @hidden */
  70597. _getProperty(propertyPath: string): string;
  70598. /**
  70599. * Serialize this manager to a JSON object
  70600. * @param name defines the property name to store this manager
  70601. * @returns a JSON representation of this manager
  70602. */
  70603. serialize(name: string): any;
  70604. /**
  70605. * Creates a new ActionManager from a JSON data
  70606. * @param parsedActions defines the JSON data to read from
  70607. * @param object defines the hosting mesh
  70608. * @param scene defines the hosting scene
  70609. */
  70610. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  70611. /**
  70612. * Get a trigger name by index
  70613. * @param trigger defines the trigger index
  70614. * @returns a trigger name
  70615. */
  70616. static GetTriggerName(trigger: number): string;
  70617. }
  70618. }
  70619. declare module BABYLON {
  70620. /**
  70621. * Class representing a ray with position and direction
  70622. */
  70623. export class Ray {
  70624. /** origin point */
  70625. origin: Vector3;
  70626. /** direction */
  70627. direction: Vector3;
  70628. /** length of the ray */
  70629. length: number;
  70630. private static readonly TmpVector3;
  70631. private _tmpRay;
  70632. /**
  70633. * Creates a new ray
  70634. * @param origin origin point
  70635. * @param direction direction
  70636. * @param length length of the ray
  70637. */
  70638. constructor(
  70639. /** origin point */
  70640. origin: Vector3,
  70641. /** direction */
  70642. direction: Vector3,
  70643. /** length of the ray */
  70644. length?: number);
  70645. /**
  70646. * Checks if the ray intersects a box
  70647. * @param minimum bound of the box
  70648. * @param maximum bound of the box
  70649. * @param intersectionTreshold extra extend to be added to the box in all direction
  70650. * @returns if the box was hit
  70651. */
  70652. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  70653. /**
  70654. * Checks if the ray intersects a box
  70655. * @param box the bounding box to check
  70656. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  70657. * @returns if the box was hit
  70658. */
  70659. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  70660. /**
  70661. * If the ray hits a sphere
  70662. * @param sphere the bounding sphere to check
  70663. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  70664. * @returns true if it hits the sphere
  70665. */
  70666. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  70667. /**
  70668. * If the ray hits a triange
  70669. * @param vertex0 triangle vertex
  70670. * @param vertex1 triangle vertex
  70671. * @param vertex2 triangle vertex
  70672. * @returns intersection information if hit
  70673. */
  70674. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  70675. /**
  70676. * Checks if ray intersects a plane
  70677. * @param plane the plane to check
  70678. * @returns the distance away it was hit
  70679. */
  70680. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  70681. /**
  70682. * Checks if ray intersects a mesh
  70683. * @param mesh the mesh to check
  70684. * @param fastCheck if only the bounding box should checked
  70685. * @returns picking info of the intersecton
  70686. */
  70687. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  70688. /**
  70689. * Checks if ray intersects a mesh
  70690. * @param meshes the meshes to check
  70691. * @param fastCheck if only the bounding box should checked
  70692. * @param results array to store result in
  70693. * @returns Array of picking infos
  70694. */
  70695. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  70696. private _comparePickingInfo;
  70697. private static smallnum;
  70698. private static rayl;
  70699. /**
  70700. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  70701. * @param sega the first point of the segment to test the intersection against
  70702. * @param segb the second point of the segment to test the intersection against
  70703. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  70704. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  70705. */
  70706. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  70707. /**
  70708. * Update the ray from viewport position
  70709. * @param x position
  70710. * @param y y position
  70711. * @param viewportWidth viewport width
  70712. * @param viewportHeight viewport height
  70713. * @param world world matrix
  70714. * @param view view matrix
  70715. * @param projection projection matrix
  70716. * @returns this ray updated
  70717. */
  70718. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70719. /**
  70720. * Creates a ray with origin and direction of 0,0,0
  70721. * @returns the new ray
  70722. */
  70723. static Zero(): Ray;
  70724. /**
  70725. * Creates a new ray from screen space and viewport
  70726. * @param x position
  70727. * @param y y position
  70728. * @param viewportWidth viewport width
  70729. * @param viewportHeight viewport height
  70730. * @param world world matrix
  70731. * @param view view matrix
  70732. * @param projection projection matrix
  70733. * @returns new ray
  70734. */
  70735. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70736. /**
  70737. * 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
  70738. * transformed to the given world matrix.
  70739. * @param origin The origin point
  70740. * @param end The end point
  70741. * @param world a matrix to transform the ray to. Default is the identity matrix.
  70742. * @returns the new ray
  70743. */
  70744. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  70745. /**
  70746. * Transforms a ray by a matrix
  70747. * @param ray ray to transform
  70748. * @param matrix matrix to apply
  70749. * @returns the resulting new ray
  70750. */
  70751. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  70752. /**
  70753. * Transforms a ray by a matrix
  70754. * @param ray ray to transform
  70755. * @param matrix matrix to apply
  70756. * @param result ray to store result in
  70757. */
  70758. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  70759. /**
  70760. * Unproject a ray from screen space to object space
  70761. * @param sourceX defines the screen space x coordinate to use
  70762. * @param sourceY defines the screen space y coordinate to use
  70763. * @param viewportWidth defines the current width of the viewport
  70764. * @param viewportHeight defines the current height of the viewport
  70765. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70766. * @param view defines the view matrix to use
  70767. * @param projection defines the projection matrix to use
  70768. */
  70769. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  70770. }
  70771. /**
  70772. * Type used to define predicate used to select faces when a mesh intersection is detected
  70773. */
  70774. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  70775. interface Scene {
  70776. /** @hidden */
  70777. _tempPickingRay: Nullable<Ray>;
  70778. /** @hidden */
  70779. _cachedRayForTransform: Ray;
  70780. /** @hidden */
  70781. _pickWithRayInverseMatrix: Matrix;
  70782. /** @hidden */
  70783. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  70784. /** @hidden */
  70785. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70786. }
  70787. }
  70788. declare module BABYLON {
  70789. /**
  70790. * Groups all the scene component constants in one place to ease maintenance.
  70791. * @hidden
  70792. */
  70793. export class SceneComponentConstants {
  70794. static readonly NAME_EFFECTLAYER: string;
  70795. static readonly NAME_LAYER: string;
  70796. static readonly NAME_LENSFLARESYSTEM: string;
  70797. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70798. static readonly NAME_PARTICLESYSTEM: string;
  70799. static readonly NAME_GAMEPAD: string;
  70800. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70801. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70802. static readonly NAME_DEPTHRENDERER: string;
  70803. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70804. static readonly NAME_SPRITE: string;
  70805. static readonly NAME_OUTLINERENDERER: string;
  70806. static readonly NAME_PROCEDURALTEXTURE: string;
  70807. static readonly NAME_SHADOWGENERATOR: string;
  70808. static readonly NAME_OCTREE: string;
  70809. static readonly NAME_PHYSICSENGINE: string;
  70810. static readonly NAME_AUDIO: string;
  70811. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70812. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70813. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70814. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70815. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70816. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70817. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70818. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70819. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70820. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70821. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70822. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70823. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70824. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70825. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70826. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70827. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70828. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70829. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70830. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70831. static readonly STEP_AFTERRENDER_AUDIO: number;
  70832. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70833. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70834. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70835. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70836. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70837. static readonly STEP_POINTERMOVE_SPRITE: number;
  70838. static readonly STEP_POINTERDOWN_SPRITE: number;
  70839. static readonly STEP_POINTERUP_SPRITE: number;
  70840. }
  70841. /**
  70842. * This represents a scene component.
  70843. *
  70844. * This is used to decouple the dependency the scene is having on the different workloads like
  70845. * layers, post processes...
  70846. */
  70847. export interface ISceneComponent {
  70848. /**
  70849. * The name of the component. Each component must have a unique name.
  70850. */
  70851. name: string;
  70852. /**
  70853. * The scene the component belongs to.
  70854. */
  70855. scene: Scene;
  70856. /**
  70857. * Register the component to one instance of a scene.
  70858. */
  70859. register(): void;
  70860. /**
  70861. * Rebuilds the elements related to this component in case of
  70862. * context lost for instance.
  70863. */
  70864. rebuild(): void;
  70865. /**
  70866. * Disposes the component and the associated ressources.
  70867. */
  70868. dispose(): void;
  70869. }
  70870. /**
  70871. * This represents a SERIALIZABLE scene component.
  70872. *
  70873. * This extends Scene Component to add Serialization methods on top.
  70874. */
  70875. export interface ISceneSerializableComponent extends ISceneComponent {
  70876. /**
  70877. * Adds all the element from the container to the scene
  70878. * @param container the container holding the elements
  70879. */
  70880. addFromContainer(container: AbstractScene): void;
  70881. /**
  70882. * Removes all the elements in the container from the scene
  70883. * @param container contains the elements to remove
  70884. * @param dispose if the removed element should be disposed (default: false)
  70885. */
  70886. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70887. /**
  70888. * Serializes the component data to the specified json object
  70889. * @param serializationObject The object to serialize to
  70890. */
  70891. serialize(serializationObject: any): void;
  70892. }
  70893. /**
  70894. * Strong typing of a Mesh related stage step action
  70895. */
  70896. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  70897. /**
  70898. * Strong typing of a Evaluate Sub Mesh related stage step action
  70899. */
  70900. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  70901. /**
  70902. * Strong typing of a Active Mesh related stage step action
  70903. */
  70904. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  70905. /**
  70906. * Strong typing of a Camera related stage step action
  70907. */
  70908. export type CameraStageAction = (camera: Camera) => void;
  70909. /**
  70910. * Strong typing of a Camera Frame buffer related stage step action
  70911. */
  70912. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  70913. /**
  70914. * Strong typing of a Render Target related stage step action
  70915. */
  70916. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  70917. /**
  70918. * Strong typing of a RenderingGroup related stage step action
  70919. */
  70920. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  70921. /**
  70922. * Strong typing of a Mesh Render related stage step action
  70923. */
  70924. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70925. /**
  70926. * Strong typing of a simple stage step action
  70927. */
  70928. export type SimpleStageAction = () => void;
  70929. /**
  70930. * Strong typing of a render target action.
  70931. */
  70932. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70933. /**
  70934. * Strong typing of a pointer move action.
  70935. */
  70936. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70937. /**
  70938. * Strong typing of a pointer up/down action.
  70939. */
  70940. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70941. /**
  70942. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70943. * @hidden
  70944. */
  70945. export class Stage<T extends Function> extends Array<{
  70946. index: number;
  70947. component: ISceneComponent;
  70948. action: T;
  70949. }> {
  70950. /**
  70951. * Hide ctor from the rest of the world.
  70952. * @param items The items to add.
  70953. */
  70954. private constructor();
  70955. /**
  70956. * Creates a new Stage.
  70957. * @returns A new instance of a Stage
  70958. */
  70959. static Create<T extends Function>(): Stage<T>;
  70960. /**
  70961. * Registers a step in an ordered way in the targeted stage.
  70962. * @param index Defines the position to register the step in
  70963. * @param component Defines the component attached to the step
  70964. * @param action Defines the action to launch during the step
  70965. */
  70966. registerStep(index: number, component: ISceneComponent, action: T): void;
  70967. /**
  70968. * Clears all the steps from the stage.
  70969. */
  70970. clear(): void;
  70971. }
  70972. }
  70973. declare module BABYLON {
  70974. interface Scene {
  70975. /** @hidden */
  70976. _pointerOverSprite: Nullable<Sprite>;
  70977. /** @hidden */
  70978. _pickedDownSprite: Nullable<Sprite>;
  70979. /** @hidden */
  70980. _tempSpritePickingRay: Nullable<Ray>;
  70981. /**
  70982. * All of the sprite managers added to this scene
  70983. * @see http://doc.babylonjs.com/babylon101/sprites
  70984. */
  70985. spriteManagers: Array<ISpriteManager>;
  70986. /**
  70987. * An event triggered when sprites rendering is about to start
  70988. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70989. */
  70990. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70991. /**
  70992. * An event triggered when sprites rendering is done
  70993. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70994. */
  70995. onAfterSpritesRenderingObservable: Observable<Scene>;
  70996. /** @hidden */
  70997. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70998. /** Launch a ray to try to pick a sprite in the scene
  70999. * @param x position on screen
  71000. * @param y position on screen
  71001. * @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
  71002. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71003. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71004. * @returns a PickingInfo
  71005. */
  71006. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71007. /** Use the given ray to pick a sprite in the scene
  71008. * @param ray The ray (in world space) to use to pick meshes
  71009. * @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
  71010. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71011. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71012. * @returns a PickingInfo
  71013. */
  71014. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71015. /**
  71016. * Force the sprite under the pointer
  71017. * @param sprite defines the sprite to use
  71018. */
  71019. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71020. /**
  71021. * Gets the sprite under the pointer
  71022. * @returns a Sprite or null if no sprite is under the pointer
  71023. */
  71024. getPointerOverSprite(): Nullable<Sprite>;
  71025. }
  71026. /**
  71027. * Defines the sprite scene component responsible to manage sprites
  71028. * in a given scene.
  71029. */
  71030. export class SpriteSceneComponent implements ISceneComponent {
  71031. /**
  71032. * The component name helpfull to identify the component in the list of scene components.
  71033. */
  71034. readonly name: string;
  71035. /**
  71036. * The scene the component belongs to.
  71037. */
  71038. scene: Scene;
  71039. /** @hidden */
  71040. private _spritePredicate;
  71041. /**
  71042. * Creates a new instance of the component for the given scene
  71043. * @param scene Defines the scene to register the component in
  71044. */
  71045. constructor(scene: Scene);
  71046. /**
  71047. * Registers the component in a given scene
  71048. */
  71049. register(): void;
  71050. /**
  71051. * Rebuilds the elements related to this component in case of
  71052. * context lost for instance.
  71053. */
  71054. rebuild(): void;
  71055. /**
  71056. * Disposes the component and the associated ressources.
  71057. */
  71058. dispose(): void;
  71059. private _pickSpriteButKeepRay;
  71060. private _pointerMove;
  71061. private _pointerDown;
  71062. private _pointerUp;
  71063. }
  71064. }
  71065. declare module BABYLON {
  71066. /** @hidden */
  71067. export var fogFragmentDeclaration: {
  71068. name: string;
  71069. shader: string;
  71070. };
  71071. }
  71072. declare module BABYLON {
  71073. /** @hidden */
  71074. export var fogFragment: {
  71075. name: string;
  71076. shader: string;
  71077. };
  71078. }
  71079. declare module BABYLON {
  71080. /** @hidden */
  71081. export var spritesPixelShader: {
  71082. name: string;
  71083. shader: string;
  71084. };
  71085. }
  71086. declare module BABYLON {
  71087. /** @hidden */
  71088. export var fogVertexDeclaration: {
  71089. name: string;
  71090. shader: string;
  71091. };
  71092. }
  71093. declare module BABYLON {
  71094. /** @hidden */
  71095. export var spritesVertexShader: {
  71096. name: string;
  71097. shader: string;
  71098. };
  71099. }
  71100. declare module BABYLON {
  71101. /**
  71102. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71103. */
  71104. export interface ISpriteManager extends IDisposable {
  71105. /**
  71106. * Restricts the camera to viewing objects with the same layerMask.
  71107. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71108. */
  71109. layerMask: number;
  71110. /**
  71111. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71112. */
  71113. isPickable: boolean;
  71114. /**
  71115. * Specifies the rendering group id for this mesh (0 by default)
  71116. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71117. */
  71118. renderingGroupId: number;
  71119. /**
  71120. * Defines the list of sprites managed by the manager.
  71121. */
  71122. sprites: Array<Sprite>;
  71123. /**
  71124. * Tests the intersection of a sprite with a specific ray.
  71125. * @param ray The ray we are sending to test the collision
  71126. * @param camera The camera space we are sending rays in
  71127. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71128. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71129. * @returns picking info or null.
  71130. */
  71131. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71132. /**
  71133. * Renders the list of sprites on screen.
  71134. */
  71135. render(): void;
  71136. }
  71137. /**
  71138. * Class used to manage multiple sprites on the same spritesheet
  71139. * @see http://doc.babylonjs.com/babylon101/sprites
  71140. */
  71141. export class SpriteManager implements ISpriteManager {
  71142. /** defines the manager's name */
  71143. name: string;
  71144. /** Gets the list of sprites */
  71145. sprites: Sprite[];
  71146. /** Gets or sets the rendering group id (0 by default) */
  71147. renderingGroupId: number;
  71148. /** Gets or sets camera layer mask */
  71149. layerMask: number;
  71150. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71151. fogEnabled: boolean;
  71152. /** Gets or sets a boolean indicating if the sprites are pickable */
  71153. isPickable: boolean;
  71154. /** Defines the default width of a cell in the spritesheet */
  71155. cellWidth: number;
  71156. /** Defines the default height of a cell in the spritesheet */
  71157. cellHeight: number;
  71158. /**
  71159. * An event triggered when the manager is disposed.
  71160. */
  71161. onDisposeObservable: Observable<SpriteManager>;
  71162. private _onDisposeObserver;
  71163. /**
  71164. * Callback called when the manager is disposed
  71165. */
  71166. onDispose: () => void;
  71167. private _capacity;
  71168. private _spriteTexture;
  71169. private _epsilon;
  71170. private _scene;
  71171. private _vertexData;
  71172. private _buffer;
  71173. private _vertexBuffers;
  71174. private _indexBuffer;
  71175. private _effectBase;
  71176. private _effectFog;
  71177. /**
  71178. * Gets or sets the spritesheet texture
  71179. */
  71180. texture: Texture;
  71181. /**
  71182. * Creates a new sprite manager
  71183. * @param name defines the manager's name
  71184. * @param imgUrl defines the sprite sheet url
  71185. * @param capacity defines the maximum allowed number of sprites
  71186. * @param cellSize defines the size of a sprite cell
  71187. * @param scene defines the hosting scene
  71188. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71189. * @param samplingMode defines the smapling mode to use with spritesheet
  71190. */
  71191. constructor(
  71192. /** defines the manager's name */
  71193. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71194. private _appendSpriteVertex;
  71195. /**
  71196. * Intersects the sprites with a ray
  71197. * @param ray defines the ray to intersect with
  71198. * @param camera defines the current active camera
  71199. * @param predicate defines a predicate used to select candidate sprites
  71200. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71201. * @returns null if no hit or a PickingInfo
  71202. */
  71203. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71204. /**
  71205. * Render all child sprites
  71206. */
  71207. render(): void;
  71208. /**
  71209. * Release associated resources
  71210. */
  71211. dispose(): void;
  71212. }
  71213. }
  71214. declare module BABYLON {
  71215. /**
  71216. * Class used to represent a sprite
  71217. * @see http://doc.babylonjs.com/babylon101/sprites
  71218. */
  71219. export class Sprite {
  71220. /** defines the name */
  71221. name: string;
  71222. /** Gets or sets the current world position */
  71223. position: Vector3;
  71224. /** Gets or sets the main color */
  71225. color: Color4;
  71226. /** Gets or sets the width */
  71227. width: number;
  71228. /** Gets or sets the height */
  71229. height: number;
  71230. /** Gets or sets rotation angle */
  71231. angle: number;
  71232. /** Gets or sets the cell index in the sprite sheet */
  71233. cellIndex: number;
  71234. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71235. invertU: number;
  71236. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71237. invertV: number;
  71238. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71239. disposeWhenFinishedAnimating: boolean;
  71240. /** Gets the list of attached animations */
  71241. animations: Animation[];
  71242. /** Gets or sets a boolean indicating if the sprite can be picked */
  71243. isPickable: boolean;
  71244. /**
  71245. * Gets or sets the associated action manager
  71246. */
  71247. actionManager: Nullable<ActionManager>;
  71248. private _animationStarted;
  71249. private _loopAnimation;
  71250. private _fromIndex;
  71251. private _toIndex;
  71252. private _delay;
  71253. private _direction;
  71254. private _manager;
  71255. private _time;
  71256. private _onAnimationEnd;
  71257. /**
  71258. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71259. */
  71260. isVisible: boolean;
  71261. /**
  71262. * Gets or sets the sprite size
  71263. */
  71264. size: number;
  71265. /**
  71266. * Creates a new Sprite
  71267. * @param name defines the name
  71268. * @param manager defines the manager
  71269. */
  71270. constructor(
  71271. /** defines the name */
  71272. name: string, manager: ISpriteManager);
  71273. /**
  71274. * Starts an animation
  71275. * @param from defines the initial key
  71276. * @param to defines the end key
  71277. * @param loop defines if the animation must loop
  71278. * @param delay defines the start delay (in ms)
  71279. * @param onAnimationEnd defines a callback to call when animation ends
  71280. */
  71281. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71282. /** Stops current animation (if any) */
  71283. stopAnimation(): void;
  71284. /** @hidden */
  71285. _animate(deltaTime: number): void;
  71286. /** Release associated resources */
  71287. dispose(): void;
  71288. }
  71289. }
  71290. declare module BABYLON {
  71291. /**
  71292. * Information about the result of picking within a scene
  71293. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71294. */
  71295. export class PickingInfo {
  71296. /** @hidden */
  71297. _pickingUnavailable: boolean;
  71298. /**
  71299. * If the pick collided with an object
  71300. */
  71301. hit: boolean;
  71302. /**
  71303. * Distance away where the pick collided
  71304. */
  71305. distance: number;
  71306. /**
  71307. * The location of pick collision
  71308. */
  71309. pickedPoint: Nullable<Vector3>;
  71310. /**
  71311. * The mesh corresponding the the pick collision
  71312. */
  71313. pickedMesh: Nullable<AbstractMesh>;
  71314. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71315. bu: number;
  71316. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71317. bv: number;
  71318. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71319. faceId: number;
  71320. /** Id of the the submesh that was picked */
  71321. subMeshId: number;
  71322. /** If a sprite was picked, this will be the sprite the pick collided with */
  71323. pickedSprite: Nullable<Sprite>;
  71324. /**
  71325. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71326. */
  71327. originMesh: Nullable<AbstractMesh>;
  71328. /**
  71329. * The ray that was used to perform the picking.
  71330. */
  71331. ray: Nullable<Ray>;
  71332. /**
  71333. * Gets the normal correspodning to the face the pick collided with
  71334. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71335. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71336. * @returns The normal correspodning to the face the pick collided with
  71337. */
  71338. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71339. /**
  71340. * Gets the texture coordinates of where the pick occured
  71341. * @returns the vector containing the coordnates of the texture
  71342. */
  71343. getTextureCoordinates(): Nullable<Vector2>;
  71344. }
  71345. }
  71346. declare module BABYLON {
  71347. /**
  71348. * Gather the list of pointer event types as constants.
  71349. */
  71350. export class PointerEventTypes {
  71351. /**
  71352. * 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.
  71353. */
  71354. static readonly POINTERDOWN: number;
  71355. /**
  71356. * The pointerup event is fired when a pointer is no longer active.
  71357. */
  71358. static readonly POINTERUP: number;
  71359. /**
  71360. * The pointermove event is fired when a pointer changes coordinates.
  71361. */
  71362. static readonly POINTERMOVE: number;
  71363. /**
  71364. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71365. */
  71366. static readonly POINTERWHEEL: number;
  71367. /**
  71368. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71369. */
  71370. static readonly POINTERPICK: number;
  71371. /**
  71372. * The pointertap event is fired when a the object has been touched and released without drag.
  71373. */
  71374. static readonly POINTERTAP: number;
  71375. /**
  71376. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71377. */
  71378. static readonly POINTERDOUBLETAP: number;
  71379. }
  71380. /**
  71381. * Base class of pointer info types.
  71382. */
  71383. export class PointerInfoBase {
  71384. /**
  71385. * Defines the type of event (PointerEventTypes)
  71386. */
  71387. type: number;
  71388. /**
  71389. * Defines the related dom event
  71390. */
  71391. event: PointerEvent | MouseWheelEvent;
  71392. /**
  71393. * Instantiates the base class of pointers info.
  71394. * @param type Defines the type of event (PointerEventTypes)
  71395. * @param event Defines the related dom event
  71396. */
  71397. constructor(
  71398. /**
  71399. * Defines the type of event (PointerEventTypes)
  71400. */
  71401. type: number,
  71402. /**
  71403. * Defines the related dom event
  71404. */
  71405. event: PointerEvent | MouseWheelEvent);
  71406. }
  71407. /**
  71408. * This class is used to store pointer related info for the onPrePointerObservable event.
  71409. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71410. */
  71411. export class PointerInfoPre extends PointerInfoBase {
  71412. /**
  71413. * Ray from a pointer if availible (eg. 6dof controller)
  71414. */
  71415. ray: Nullable<Ray>;
  71416. /**
  71417. * Defines the local position of the pointer on the canvas.
  71418. */
  71419. localPosition: Vector2;
  71420. /**
  71421. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71422. */
  71423. skipOnPointerObservable: boolean;
  71424. /**
  71425. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71426. * @param type Defines the type of event (PointerEventTypes)
  71427. * @param event Defines the related dom event
  71428. * @param localX Defines the local x coordinates of the pointer when the event occured
  71429. * @param localY Defines the local y coordinates of the pointer when the event occured
  71430. */
  71431. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71432. }
  71433. /**
  71434. * This type contains all the data related to a pointer event in Babylon.js.
  71435. * 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.
  71436. */
  71437. export class PointerInfo extends PointerInfoBase {
  71438. /**
  71439. * Defines the picking info associated to the info (if any)\
  71440. */
  71441. pickInfo: Nullable<PickingInfo>;
  71442. /**
  71443. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71444. * @param type Defines the type of event (PointerEventTypes)
  71445. * @param event Defines the related dom event
  71446. * @param pickInfo Defines the picking info associated to the info (if any)\
  71447. */
  71448. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71449. /**
  71450. * Defines the picking info associated to the info (if any)\
  71451. */
  71452. pickInfo: Nullable<PickingInfo>);
  71453. }
  71454. /**
  71455. * Data relating to a touch event on the screen.
  71456. */
  71457. export interface PointerTouch {
  71458. /**
  71459. * X coordinate of touch.
  71460. */
  71461. x: number;
  71462. /**
  71463. * Y coordinate of touch.
  71464. */
  71465. y: number;
  71466. /**
  71467. * Id of touch. Unique for each finger.
  71468. */
  71469. pointerId: number;
  71470. /**
  71471. * Event type passed from DOM.
  71472. */
  71473. type: any;
  71474. }
  71475. }
  71476. declare module BABYLON {
  71477. /**
  71478. * Manage the mouse inputs to control the movement of a free camera.
  71479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71480. */
  71481. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71482. /**
  71483. * Define if touch is enabled in the mouse input
  71484. */
  71485. touchEnabled: boolean;
  71486. /**
  71487. * Defines the camera the input is attached to.
  71488. */
  71489. camera: FreeCamera;
  71490. /**
  71491. * Defines the buttons associated with the input to handle camera move.
  71492. */
  71493. buttons: number[];
  71494. /**
  71495. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71496. */
  71497. angularSensibility: number;
  71498. private _pointerInput;
  71499. private _onMouseMove;
  71500. private _observer;
  71501. private previousPosition;
  71502. /**
  71503. * Observable for when a pointer move event occurs containing the move offset
  71504. */
  71505. onPointerMovedObservable: Observable<{
  71506. offsetX: number;
  71507. offsetY: number;
  71508. }>;
  71509. /**
  71510. * @hidden
  71511. * If the camera should be rotated automatically based on pointer movement
  71512. */
  71513. _allowCameraRotation: boolean;
  71514. /**
  71515. * Manage the mouse inputs to control the movement of a free camera.
  71516. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71517. * @param touchEnabled Defines if touch is enabled or not
  71518. */
  71519. constructor(
  71520. /**
  71521. * Define if touch is enabled in the mouse input
  71522. */
  71523. touchEnabled?: boolean);
  71524. /**
  71525. * Attach the input controls to a specific dom element to get the input from.
  71526. * @param element Defines the element the controls should be listened from
  71527. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71528. */
  71529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71530. /**
  71531. * Called on JS contextmenu event.
  71532. * Override this method to provide functionality.
  71533. */
  71534. protected onContextMenu(evt: PointerEvent): void;
  71535. /**
  71536. * Detach the current controls from the specified dom element.
  71537. * @param element Defines the element to stop listening the inputs from
  71538. */
  71539. detachControl(element: Nullable<HTMLElement>): void;
  71540. /**
  71541. * Gets the class name of the current intput.
  71542. * @returns the class name
  71543. */
  71544. getClassName(): string;
  71545. /**
  71546. * Get the friendly name associated with the input class.
  71547. * @returns the input friendly name
  71548. */
  71549. getSimpleName(): string;
  71550. }
  71551. }
  71552. declare module BABYLON {
  71553. /**
  71554. * Manage the touch inputs to control the movement of a free camera.
  71555. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71556. */
  71557. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  71558. /**
  71559. * Defines the camera the input is attached to.
  71560. */
  71561. camera: FreeCamera;
  71562. /**
  71563. * Defines the touch sensibility for rotation.
  71564. * The higher the faster.
  71565. */
  71566. touchAngularSensibility: number;
  71567. /**
  71568. * Defines the touch sensibility for move.
  71569. * The higher the faster.
  71570. */
  71571. touchMoveSensibility: number;
  71572. private _offsetX;
  71573. private _offsetY;
  71574. private _pointerPressed;
  71575. private _pointerInput;
  71576. private _observer;
  71577. private _onLostFocus;
  71578. /**
  71579. * Attach the input controls to a specific dom element to get the input from.
  71580. * @param element Defines the element the controls should be listened from
  71581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71582. */
  71583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71584. /**
  71585. * Detach the current controls from the specified dom element.
  71586. * @param element Defines the element to stop listening the inputs from
  71587. */
  71588. detachControl(element: Nullable<HTMLElement>): void;
  71589. /**
  71590. * Update the current camera state depending on the inputs that have been used this frame.
  71591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71592. */
  71593. checkInputs(): void;
  71594. /**
  71595. * Gets the class name of the current intput.
  71596. * @returns the class name
  71597. */
  71598. getClassName(): string;
  71599. /**
  71600. * Get the friendly name associated with the input class.
  71601. * @returns the input friendly name
  71602. */
  71603. getSimpleName(): string;
  71604. }
  71605. }
  71606. declare module BABYLON {
  71607. /**
  71608. * Default Inputs manager for the FreeCamera.
  71609. * It groups all the default supported inputs for ease of use.
  71610. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71611. */
  71612. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  71613. /**
  71614. * @hidden
  71615. */
  71616. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  71617. /**
  71618. * @hidden
  71619. */
  71620. _mouseInput: Nullable<FreeCameraMouseInput>;
  71621. /**
  71622. * Instantiates a new FreeCameraInputsManager.
  71623. * @param camera Defines the camera the inputs belong to
  71624. */
  71625. constructor(camera: FreeCamera);
  71626. /**
  71627. * Add keyboard input support to the input manager.
  71628. * @returns the current input manager
  71629. */
  71630. addKeyboard(): FreeCameraInputsManager;
  71631. /**
  71632. * Add mouse input support to the input manager.
  71633. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  71634. * @returns the current input manager
  71635. */
  71636. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  71637. /**
  71638. * Removes the mouse input support from the manager
  71639. * @returns the current input manager
  71640. */
  71641. removeMouse(): FreeCameraInputsManager;
  71642. /**
  71643. * Add touch input support to the input manager.
  71644. * @returns the current input manager
  71645. */
  71646. addTouch(): FreeCameraInputsManager;
  71647. }
  71648. }
  71649. declare module BABYLON {
  71650. /**
  71651. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71652. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  71653. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71654. */
  71655. export class FreeCamera extends TargetCamera {
  71656. /**
  71657. * Define the collision ellipsoid of the camera.
  71658. * This is helpful to simulate a camera body like the player body around the camera
  71659. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  71660. */
  71661. ellipsoid: Vector3;
  71662. /**
  71663. * Define an offset for the position of the ellipsoid around the camera.
  71664. * This can be helpful to determine the center of the body near the gravity center of the body
  71665. * instead of its head.
  71666. */
  71667. ellipsoidOffset: Vector3;
  71668. /**
  71669. * Enable or disable collisions of the camera with the rest of the scene objects.
  71670. */
  71671. checkCollisions: boolean;
  71672. /**
  71673. * Enable or disable gravity on the camera.
  71674. */
  71675. applyGravity: boolean;
  71676. /**
  71677. * Define the input manager associated to the camera.
  71678. */
  71679. inputs: FreeCameraInputsManager;
  71680. /**
  71681. * Gets the input sensibility for a mouse input. (default is 2000.0)
  71682. * Higher values reduce sensitivity.
  71683. */
  71684. /**
  71685. * Sets the input sensibility for a mouse input. (default is 2000.0)
  71686. * Higher values reduce sensitivity.
  71687. */
  71688. angularSensibility: number;
  71689. /**
  71690. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71691. */
  71692. keysUp: number[];
  71693. /**
  71694. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71695. */
  71696. keysDown: number[];
  71697. /**
  71698. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71699. */
  71700. keysLeft: number[];
  71701. /**
  71702. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71703. */
  71704. keysRight: number[];
  71705. /**
  71706. * Event raised when the camera collide with a mesh in the scene.
  71707. */
  71708. onCollide: (collidedMesh: AbstractMesh) => void;
  71709. private _collider;
  71710. private _needMoveForGravity;
  71711. private _oldPosition;
  71712. private _diffPosition;
  71713. private _newPosition;
  71714. /** @hidden */
  71715. _localDirection: Vector3;
  71716. /** @hidden */
  71717. _transformedDirection: Vector3;
  71718. /**
  71719. * Instantiates a Free Camera.
  71720. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71721. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  71722. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71723. * @param name Define the name of the camera in the scene
  71724. * @param position Define the start position of the camera in the scene
  71725. * @param scene Define the scene the camera belongs to
  71726. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71727. */
  71728. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71729. /**
  71730. * Attached controls to the current camera.
  71731. * @param element Defines the element the controls should be listened from
  71732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71733. */
  71734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71735. /**
  71736. * Detach the current controls from the camera.
  71737. * The camera will stop reacting to inputs.
  71738. * @param element Defines the element to stop listening the inputs from
  71739. */
  71740. detachControl(element: HTMLElement): void;
  71741. private _collisionMask;
  71742. /**
  71743. * Define a collision mask to limit the list of object the camera can collide with
  71744. */
  71745. collisionMask: number;
  71746. /** @hidden */
  71747. _collideWithWorld(displacement: Vector3): void;
  71748. private _onCollisionPositionChange;
  71749. /** @hidden */
  71750. _checkInputs(): void;
  71751. /** @hidden */
  71752. _decideIfNeedsToMove(): boolean;
  71753. /** @hidden */
  71754. _updatePosition(): void;
  71755. /**
  71756. * Destroy the camera and release the current resources hold by it.
  71757. */
  71758. dispose(): void;
  71759. /**
  71760. * Gets the current object class name.
  71761. * @return the class name
  71762. */
  71763. getClassName(): string;
  71764. }
  71765. }
  71766. declare module BABYLON {
  71767. /**
  71768. * Represents a gamepad control stick position
  71769. */
  71770. export class StickValues {
  71771. /**
  71772. * The x component of the control stick
  71773. */
  71774. x: number;
  71775. /**
  71776. * The y component of the control stick
  71777. */
  71778. y: number;
  71779. /**
  71780. * Initializes the gamepad x and y control stick values
  71781. * @param x The x component of the gamepad control stick value
  71782. * @param y The y component of the gamepad control stick value
  71783. */
  71784. constructor(
  71785. /**
  71786. * The x component of the control stick
  71787. */
  71788. x: number,
  71789. /**
  71790. * The y component of the control stick
  71791. */
  71792. y: number);
  71793. }
  71794. /**
  71795. * An interface which manages callbacks for gamepad button changes
  71796. */
  71797. export interface GamepadButtonChanges {
  71798. /**
  71799. * Called when a gamepad has been changed
  71800. */
  71801. changed: boolean;
  71802. /**
  71803. * Called when a gamepad press event has been triggered
  71804. */
  71805. pressChanged: boolean;
  71806. /**
  71807. * Called when a touch event has been triggered
  71808. */
  71809. touchChanged: boolean;
  71810. /**
  71811. * Called when a value has changed
  71812. */
  71813. valueChanged: boolean;
  71814. }
  71815. /**
  71816. * Represents a gamepad
  71817. */
  71818. export class Gamepad {
  71819. /**
  71820. * The id of the gamepad
  71821. */
  71822. id: string;
  71823. /**
  71824. * The index of the gamepad
  71825. */
  71826. index: number;
  71827. /**
  71828. * The browser gamepad
  71829. */
  71830. browserGamepad: any;
  71831. /**
  71832. * Specifies what type of gamepad this represents
  71833. */
  71834. type: number;
  71835. private _leftStick;
  71836. private _rightStick;
  71837. /** @hidden */
  71838. _isConnected: boolean;
  71839. private _leftStickAxisX;
  71840. private _leftStickAxisY;
  71841. private _rightStickAxisX;
  71842. private _rightStickAxisY;
  71843. /**
  71844. * Triggered when the left control stick has been changed
  71845. */
  71846. private _onleftstickchanged;
  71847. /**
  71848. * Triggered when the right control stick has been changed
  71849. */
  71850. private _onrightstickchanged;
  71851. /**
  71852. * Represents a gamepad controller
  71853. */
  71854. static GAMEPAD: number;
  71855. /**
  71856. * Represents a generic controller
  71857. */
  71858. static GENERIC: number;
  71859. /**
  71860. * Represents an XBox controller
  71861. */
  71862. static XBOX: number;
  71863. /**
  71864. * Represents a pose-enabled controller
  71865. */
  71866. static POSE_ENABLED: number;
  71867. /**
  71868. * Specifies whether the left control stick should be Y-inverted
  71869. */
  71870. protected _invertLeftStickY: boolean;
  71871. /**
  71872. * Specifies if the gamepad has been connected
  71873. */
  71874. readonly isConnected: boolean;
  71875. /**
  71876. * Initializes the gamepad
  71877. * @param id The id of the gamepad
  71878. * @param index The index of the gamepad
  71879. * @param browserGamepad The browser gamepad
  71880. * @param leftStickX The x component of the left joystick
  71881. * @param leftStickY The y component of the left joystick
  71882. * @param rightStickX The x component of the right joystick
  71883. * @param rightStickY The y component of the right joystick
  71884. */
  71885. constructor(
  71886. /**
  71887. * The id of the gamepad
  71888. */
  71889. id: string,
  71890. /**
  71891. * The index of the gamepad
  71892. */
  71893. index: number,
  71894. /**
  71895. * The browser gamepad
  71896. */
  71897. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  71898. /**
  71899. * Callback triggered when the left joystick has changed
  71900. * @param callback
  71901. */
  71902. onleftstickchanged(callback: (values: StickValues) => void): void;
  71903. /**
  71904. * Callback triggered when the right joystick has changed
  71905. * @param callback
  71906. */
  71907. onrightstickchanged(callback: (values: StickValues) => void): void;
  71908. /**
  71909. * Gets the left joystick
  71910. */
  71911. /**
  71912. * Sets the left joystick values
  71913. */
  71914. leftStick: StickValues;
  71915. /**
  71916. * Gets the right joystick
  71917. */
  71918. /**
  71919. * Sets the right joystick value
  71920. */
  71921. rightStick: StickValues;
  71922. /**
  71923. * Updates the gamepad joystick positions
  71924. */
  71925. update(): void;
  71926. /**
  71927. * Disposes the gamepad
  71928. */
  71929. dispose(): void;
  71930. }
  71931. /**
  71932. * Represents a generic gamepad
  71933. */
  71934. export class GenericPad extends Gamepad {
  71935. private _buttons;
  71936. private _onbuttondown;
  71937. private _onbuttonup;
  71938. /**
  71939. * Observable triggered when a button has been pressed
  71940. */
  71941. onButtonDownObservable: Observable<number>;
  71942. /**
  71943. * Observable triggered when a button has been released
  71944. */
  71945. onButtonUpObservable: Observable<number>;
  71946. /**
  71947. * Callback triggered when a button has been pressed
  71948. * @param callback Called when a button has been pressed
  71949. */
  71950. onbuttondown(callback: (buttonPressed: number) => void): void;
  71951. /**
  71952. * Callback triggered when a button has been released
  71953. * @param callback Called when a button has been released
  71954. */
  71955. onbuttonup(callback: (buttonReleased: number) => void): void;
  71956. /**
  71957. * Initializes the generic gamepad
  71958. * @param id The id of the generic gamepad
  71959. * @param index The index of the generic gamepad
  71960. * @param browserGamepad The browser gamepad
  71961. */
  71962. constructor(id: string, index: number, browserGamepad: any);
  71963. private _setButtonValue;
  71964. /**
  71965. * Updates the generic gamepad
  71966. */
  71967. update(): void;
  71968. /**
  71969. * Disposes the generic gamepad
  71970. */
  71971. dispose(): void;
  71972. }
  71973. }
  71974. declare module BABYLON {
  71975. /**
  71976. * Defines the types of pose enabled controllers that are supported
  71977. */
  71978. export enum PoseEnabledControllerType {
  71979. /**
  71980. * HTC Vive
  71981. */
  71982. VIVE = 0,
  71983. /**
  71984. * Oculus Rift
  71985. */
  71986. OCULUS = 1,
  71987. /**
  71988. * Windows mixed reality
  71989. */
  71990. WINDOWS = 2,
  71991. /**
  71992. * Samsung gear VR
  71993. */
  71994. GEAR_VR = 3,
  71995. /**
  71996. * Google Daydream
  71997. */
  71998. DAYDREAM = 4,
  71999. /**
  72000. * Generic
  72001. */
  72002. GENERIC = 5
  72003. }
  72004. /**
  72005. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72006. */
  72007. export interface MutableGamepadButton {
  72008. /**
  72009. * Value of the button/trigger
  72010. */
  72011. value: number;
  72012. /**
  72013. * If the button/trigger is currently touched
  72014. */
  72015. touched: boolean;
  72016. /**
  72017. * If the button/trigger is currently pressed
  72018. */
  72019. pressed: boolean;
  72020. }
  72021. /**
  72022. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72023. * @hidden
  72024. */
  72025. export interface ExtendedGamepadButton extends GamepadButton {
  72026. /**
  72027. * If the button/trigger is currently pressed
  72028. */
  72029. readonly pressed: boolean;
  72030. /**
  72031. * If the button/trigger is currently touched
  72032. */
  72033. readonly touched: boolean;
  72034. /**
  72035. * Value of the button/trigger
  72036. */
  72037. readonly value: number;
  72038. }
  72039. /** @hidden */
  72040. export interface _GamePadFactory {
  72041. /**
  72042. * Returns wether or not the current gamepad can be created for this type of controller.
  72043. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72044. * @returns true if it can be created, otherwise false
  72045. */
  72046. canCreate(gamepadInfo: any): boolean;
  72047. /**
  72048. * Creates a new instance of the Gamepad.
  72049. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72050. * @returns the new gamepad instance
  72051. */
  72052. create(gamepadInfo: any): Gamepad;
  72053. }
  72054. /**
  72055. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72056. */
  72057. export class PoseEnabledControllerHelper {
  72058. /** @hidden */
  72059. static _ControllerFactories: _GamePadFactory[];
  72060. /** @hidden */
  72061. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72062. /**
  72063. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72064. * @param vrGamepad the gamepad to initialized
  72065. * @returns a vr controller of the type the gamepad identified as
  72066. */
  72067. static InitiateController(vrGamepad: any): Gamepad;
  72068. }
  72069. /**
  72070. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72071. */
  72072. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72073. private _deviceRoomPosition;
  72074. private _deviceRoomRotationQuaternion;
  72075. /**
  72076. * The device position in babylon space
  72077. */
  72078. devicePosition: Vector3;
  72079. /**
  72080. * The device rotation in babylon space
  72081. */
  72082. deviceRotationQuaternion: Quaternion;
  72083. /**
  72084. * The scale factor of the device in babylon space
  72085. */
  72086. deviceScaleFactor: number;
  72087. /**
  72088. * (Likely devicePosition should be used instead) The device position in its room space
  72089. */
  72090. position: Vector3;
  72091. /**
  72092. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72093. */
  72094. rotationQuaternion: Quaternion;
  72095. /**
  72096. * The type of controller (Eg. Windows mixed reality)
  72097. */
  72098. controllerType: PoseEnabledControllerType;
  72099. protected _calculatedPosition: Vector3;
  72100. private _calculatedRotation;
  72101. /**
  72102. * The raw pose from the device
  72103. */
  72104. rawPose: DevicePose;
  72105. private _trackPosition;
  72106. private _maxRotationDistFromHeadset;
  72107. private _draggedRoomRotation;
  72108. /**
  72109. * @hidden
  72110. */
  72111. _disableTrackPosition(fixedPosition: Vector3): void;
  72112. /**
  72113. * Internal, the mesh attached to the controller
  72114. * @hidden
  72115. */
  72116. _mesh: Nullable<AbstractMesh>;
  72117. private _poseControlledCamera;
  72118. private _leftHandSystemQuaternion;
  72119. /**
  72120. * Internal, matrix used to convert room space to babylon space
  72121. * @hidden
  72122. */
  72123. _deviceToWorld: Matrix;
  72124. /**
  72125. * Node to be used when casting a ray from the controller
  72126. * @hidden
  72127. */
  72128. _pointingPoseNode: Nullable<TransformNode>;
  72129. /**
  72130. * Name of the child mesh that can be used to cast a ray from the controller
  72131. */
  72132. static readonly POINTING_POSE: string;
  72133. /**
  72134. * Creates a new PoseEnabledController from a gamepad
  72135. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72136. */
  72137. constructor(browserGamepad: any);
  72138. private _workingMatrix;
  72139. /**
  72140. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72141. */
  72142. update(): void;
  72143. /**
  72144. * Updates only the pose device and mesh without doing any button event checking
  72145. */
  72146. protected _updatePoseAndMesh(): void;
  72147. /**
  72148. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72149. * @param poseData raw pose fromthe device
  72150. */
  72151. updateFromDevice(poseData: DevicePose): void;
  72152. /**
  72153. * @hidden
  72154. */
  72155. _meshAttachedObservable: Observable<AbstractMesh>;
  72156. /**
  72157. * Attaches a mesh to the controller
  72158. * @param mesh the mesh to be attached
  72159. */
  72160. attachToMesh(mesh: AbstractMesh): void;
  72161. /**
  72162. * Attaches the controllers mesh to a camera
  72163. * @param camera the camera the mesh should be attached to
  72164. */
  72165. attachToPoseControlledCamera(camera: TargetCamera): void;
  72166. /**
  72167. * Disposes of the controller
  72168. */
  72169. dispose(): void;
  72170. /**
  72171. * The mesh that is attached to the controller
  72172. */
  72173. readonly mesh: Nullable<AbstractMesh>;
  72174. /**
  72175. * Gets the ray of the controller in the direction the controller is pointing
  72176. * @param length the length the resulting ray should be
  72177. * @returns a ray in the direction the controller is pointing
  72178. */
  72179. getForwardRay(length?: number): Ray;
  72180. }
  72181. }
  72182. declare module BABYLON {
  72183. /**
  72184. * Defines the WebVRController object that represents controllers tracked in 3D space
  72185. */
  72186. export abstract class WebVRController extends PoseEnabledController {
  72187. /**
  72188. * Internal, the default controller model for the controller
  72189. */
  72190. protected _defaultModel: AbstractMesh;
  72191. /**
  72192. * Fired when the trigger state has changed
  72193. */
  72194. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72195. /**
  72196. * Fired when the main button state has changed
  72197. */
  72198. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72199. /**
  72200. * Fired when the secondary button state has changed
  72201. */
  72202. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72203. /**
  72204. * Fired when the pad state has changed
  72205. */
  72206. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72207. /**
  72208. * Fired when controllers stick values have changed
  72209. */
  72210. onPadValuesChangedObservable: Observable<StickValues>;
  72211. /**
  72212. * Array of button availible on the controller
  72213. */
  72214. protected _buttons: Array<MutableGamepadButton>;
  72215. private _onButtonStateChange;
  72216. /**
  72217. * Fired when a controller button's state has changed
  72218. * @param callback the callback containing the button that was modified
  72219. */
  72220. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72221. /**
  72222. * X and Y axis corrisponding to the controllers joystick
  72223. */
  72224. pad: StickValues;
  72225. /**
  72226. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72227. */
  72228. hand: string;
  72229. /**
  72230. * The default controller model for the controller
  72231. */
  72232. readonly defaultModel: AbstractMesh;
  72233. /**
  72234. * Creates a new WebVRController from a gamepad
  72235. * @param vrGamepad the gamepad that the WebVRController should be created from
  72236. */
  72237. constructor(vrGamepad: any);
  72238. /**
  72239. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72240. */
  72241. update(): void;
  72242. /**
  72243. * Function to be called when a button is modified
  72244. */
  72245. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72246. /**
  72247. * Loads a mesh and attaches it to the controller
  72248. * @param scene the scene the mesh should be added to
  72249. * @param meshLoaded callback for when the mesh has been loaded
  72250. */
  72251. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72252. private _setButtonValue;
  72253. private _changes;
  72254. private _checkChanges;
  72255. /**
  72256. * Disposes of th webVRCOntroller
  72257. */
  72258. dispose(): void;
  72259. }
  72260. }
  72261. declare module BABYLON {
  72262. /**
  72263. * The HemisphericLight simulates the ambient environment light,
  72264. * so the passed direction is the light reflection direction, not the incoming direction.
  72265. */
  72266. export class HemisphericLight extends Light {
  72267. /**
  72268. * The groundColor is the light in the opposite direction to the one specified during creation.
  72269. * 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.
  72270. */
  72271. groundColor: Color3;
  72272. /**
  72273. * The light reflection direction, not the incoming direction.
  72274. */
  72275. direction: Vector3;
  72276. /**
  72277. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72278. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72279. * The HemisphericLight can't cast shadows.
  72280. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72281. * @param name The friendly name of the light
  72282. * @param direction The direction of the light reflection
  72283. * @param scene The scene the light belongs to
  72284. */
  72285. constructor(name: string, direction: Vector3, scene: Scene);
  72286. protected _buildUniformLayout(): void;
  72287. /**
  72288. * Returns the string "HemisphericLight".
  72289. * @return The class name
  72290. */
  72291. getClassName(): string;
  72292. /**
  72293. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72294. * Returns the updated direction.
  72295. * @param target The target the direction should point to
  72296. * @return The computed direction
  72297. */
  72298. setDirectionToTarget(target: Vector3): Vector3;
  72299. /**
  72300. * Returns the shadow generator associated to the light.
  72301. * @returns Always null for hemispheric lights because it does not support shadows.
  72302. */
  72303. getShadowGenerator(): Nullable<IShadowGenerator>;
  72304. /**
  72305. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72306. * @param effect The effect to update
  72307. * @param lightIndex The index of the light in the effect to update
  72308. * @returns The hemispheric light
  72309. */
  72310. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72311. /**
  72312. * Computes the world matrix of the node
  72313. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72314. * @param useWasUpdatedFlag defines a reserved property
  72315. * @returns the world matrix
  72316. */
  72317. computeWorldMatrix(): Matrix;
  72318. /**
  72319. * Returns the integer 3.
  72320. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72321. */
  72322. getTypeID(): number;
  72323. /**
  72324. * Prepares the list of defines specific to the light type.
  72325. * @param defines the list of defines
  72326. * @param lightIndex defines the index of the light for the effect
  72327. */
  72328. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72329. }
  72330. }
  72331. declare module BABYLON {
  72332. /** @hidden */
  72333. export var vrMultiviewToSingleviewPixelShader: {
  72334. name: string;
  72335. shader: string;
  72336. };
  72337. }
  72338. declare module BABYLON {
  72339. /**
  72340. * Renders to multiple views with a single draw call
  72341. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72342. */
  72343. export class MultiviewRenderTarget extends RenderTargetTexture {
  72344. /**
  72345. * Creates a multiview render target
  72346. * @param scene scene used with the render target
  72347. * @param size the size of the render target (used for each view)
  72348. */
  72349. constructor(scene: Scene, size?: number | {
  72350. width: number;
  72351. height: number;
  72352. } | {
  72353. ratio: number;
  72354. });
  72355. /**
  72356. * @hidden
  72357. * @param faceIndex the face index, if its a cube texture
  72358. */
  72359. _bindFrameBuffer(faceIndex?: number): void;
  72360. /**
  72361. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72362. * @returns the view count
  72363. */
  72364. getViewCount(): number;
  72365. }
  72366. }
  72367. declare module BABYLON {
  72368. interface Engine {
  72369. /**
  72370. * Creates a new multiview render target
  72371. * @param width defines the width of the texture
  72372. * @param height defines the height of the texture
  72373. * @returns the created multiview texture
  72374. */
  72375. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72376. /**
  72377. * Binds a multiview framebuffer to be drawn to
  72378. * @param multiviewTexture texture to bind
  72379. */
  72380. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72381. }
  72382. interface Camera {
  72383. /**
  72384. * @hidden
  72385. * 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)
  72386. */
  72387. _useMultiviewToSingleView: boolean;
  72388. /**
  72389. * @hidden
  72390. * 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)
  72391. */
  72392. _multiviewTexture: Nullable<RenderTargetTexture>;
  72393. /**
  72394. * @hidden
  72395. * ensures the multiview texture of the camera exists and has the specified width/height
  72396. * @param width height to set on the multiview texture
  72397. * @param height width to set on the multiview texture
  72398. */
  72399. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72400. }
  72401. interface Scene {
  72402. /** @hidden */
  72403. _transformMatrixR: Matrix;
  72404. /** @hidden */
  72405. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72406. /** @hidden */
  72407. _createMultiviewUbo(): void;
  72408. /** @hidden */
  72409. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72410. /** @hidden */
  72411. _renderMultiviewToSingleView(camera: Camera): void;
  72412. }
  72413. }
  72414. declare module BABYLON {
  72415. /**
  72416. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72417. * This will not be used for webXR as it supports displaying texture arrays directly
  72418. */
  72419. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72420. /**
  72421. * Initializes a VRMultiviewToSingleview
  72422. * @param name name of the post process
  72423. * @param camera camera to be applied to
  72424. * @param scaleFactor scaling factor to the size of the output texture
  72425. */
  72426. constructor(name: string, camera: Camera, scaleFactor: number);
  72427. }
  72428. }
  72429. declare module BABYLON {
  72430. /**
  72431. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72432. * IMPORTANT!! The data is right-hand data.
  72433. * @export
  72434. * @interface DevicePose
  72435. */
  72436. export interface DevicePose {
  72437. /**
  72438. * The position of the device, values in array are [x,y,z].
  72439. */
  72440. readonly position: Nullable<Float32Array>;
  72441. /**
  72442. * The linearVelocity of the device, values in array are [x,y,z].
  72443. */
  72444. readonly linearVelocity: Nullable<Float32Array>;
  72445. /**
  72446. * The linearAcceleration of the device, values in array are [x,y,z].
  72447. */
  72448. readonly linearAcceleration: Nullable<Float32Array>;
  72449. /**
  72450. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72451. */
  72452. readonly orientation: Nullable<Float32Array>;
  72453. /**
  72454. * The angularVelocity of the device, values in array are [x,y,z].
  72455. */
  72456. readonly angularVelocity: Nullable<Float32Array>;
  72457. /**
  72458. * The angularAcceleration of the device, values in array are [x,y,z].
  72459. */
  72460. readonly angularAcceleration: Nullable<Float32Array>;
  72461. }
  72462. /**
  72463. * Interface representing a pose controlled object in Babylon.
  72464. * A pose controlled object has both regular pose values as well as pose values
  72465. * from an external device such as a VR head mounted display
  72466. */
  72467. export interface PoseControlled {
  72468. /**
  72469. * The position of the object in babylon space.
  72470. */
  72471. position: Vector3;
  72472. /**
  72473. * The rotation quaternion of the object in babylon space.
  72474. */
  72475. rotationQuaternion: Quaternion;
  72476. /**
  72477. * The position of the device in babylon space.
  72478. */
  72479. devicePosition?: Vector3;
  72480. /**
  72481. * The rotation quaternion of the device in babylon space.
  72482. */
  72483. deviceRotationQuaternion: Quaternion;
  72484. /**
  72485. * The raw pose coming from the device.
  72486. */
  72487. rawPose: Nullable<DevicePose>;
  72488. /**
  72489. * The scale of the device to be used when translating from device space to babylon space.
  72490. */
  72491. deviceScaleFactor: number;
  72492. /**
  72493. * Updates the poseControlled values based on the input device pose.
  72494. * @param poseData the pose data to update the object with
  72495. */
  72496. updateFromDevice(poseData: DevicePose): void;
  72497. }
  72498. /**
  72499. * Set of options to customize the webVRCamera
  72500. */
  72501. export interface WebVROptions {
  72502. /**
  72503. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72504. */
  72505. trackPosition?: boolean;
  72506. /**
  72507. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72508. */
  72509. positionScale?: number;
  72510. /**
  72511. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72512. */
  72513. displayName?: string;
  72514. /**
  72515. * Should the native controller meshes be initialized. (default: true)
  72516. */
  72517. controllerMeshes?: boolean;
  72518. /**
  72519. * Creating a default HemiLight only on controllers. (default: true)
  72520. */
  72521. defaultLightingOnControllers?: boolean;
  72522. /**
  72523. * If you don't want to use the default VR button of the helper. (default: false)
  72524. */
  72525. useCustomVRButton?: boolean;
  72526. /**
  72527. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72528. */
  72529. customVRButton?: HTMLButtonElement;
  72530. /**
  72531. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72532. */
  72533. rayLength?: number;
  72534. /**
  72535. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72536. */
  72537. defaultHeight?: number;
  72538. /**
  72539. * If multiview should be used if availible (default: false)
  72540. */
  72541. useMultiview?: boolean;
  72542. }
  72543. /**
  72544. * This represents a WebVR camera.
  72545. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  72546. * @example http://doc.babylonjs.com/how_to/webvr_camera
  72547. */
  72548. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  72549. private webVROptions;
  72550. /**
  72551. * @hidden
  72552. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  72553. */
  72554. _vrDevice: any;
  72555. /**
  72556. * The rawPose of the vrDevice.
  72557. */
  72558. rawPose: Nullable<DevicePose>;
  72559. private _onVREnabled;
  72560. private _specsVersion;
  72561. private _attached;
  72562. private _frameData;
  72563. protected _descendants: Array<Node>;
  72564. private _deviceRoomPosition;
  72565. /** @hidden */
  72566. _deviceRoomRotationQuaternion: Quaternion;
  72567. private _standingMatrix;
  72568. /**
  72569. * Represents device position in babylon space.
  72570. */
  72571. devicePosition: Vector3;
  72572. /**
  72573. * Represents device rotation in babylon space.
  72574. */
  72575. deviceRotationQuaternion: Quaternion;
  72576. /**
  72577. * The scale of the device to be used when translating from device space to babylon space.
  72578. */
  72579. deviceScaleFactor: number;
  72580. private _deviceToWorld;
  72581. private _worldToDevice;
  72582. /**
  72583. * References to the webVR controllers for the vrDevice.
  72584. */
  72585. controllers: Array<WebVRController>;
  72586. /**
  72587. * Emits an event when a controller is attached.
  72588. */
  72589. onControllersAttachedObservable: Observable<WebVRController[]>;
  72590. /**
  72591. * Emits an event when a controller's mesh has been loaded;
  72592. */
  72593. onControllerMeshLoadedObservable: Observable<WebVRController>;
  72594. /**
  72595. * Emits an event when the HMD's pose has been updated.
  72596. */
  72597. onPoseUpdatedFromDeviceObservable: Observable<any>;
  72598. private _poseSet;
  72599. /**
  72600. * If the rig cameras be used as parent instead of this camera.
  72601. */
  72602. rigParenting: boolean;
  72603. private _lightOnControllers;
  72604. private _defaultHeight?;
  72605. /**
  72606. * Instantiates a WebVRFreeCamera.
  72607. * @param name The name of the WebVRFreeCamera
  72608. * @param position The starting anchor position for the camera
  72609. * @param scene The scene the camera belongs to
  72610. * @param webVROptions a set of customizable options for the webVRCamera
  72611. */
  72612. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  72613. /**
  72614. * Gets the device distance from the ground in meters.
  72615. * @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.
  72616. */
  72617. deviceDistanceToRoomGround(): number;
  72618. /**
  72619. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72620. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  72621. */
  72622. useStandingMatrix(callback?: (bool: boolean) => void): void;
  72623. /**
  72624. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72625. * @returns A promise with a boolean set to if the standing matrix is supported.
  72626. */
  72627. useStandingMatrixAsync(): Promise<boolean>;
  72628. /**
  72629. * Disposes the camera
  72630. */
  72631. dispose(): void;
  72632. /**
  72633. * Gets a vrController by name.
  72634. * @param name The name of the controller to retreive
  72635. * @returns the controller matching the name specified or null if not found
  72636. */
  72637. getControllerByName(name: string): Nullable<WebVRController>;
  72638. private _leftController;
  72639. /**
  72640. * The controller corrisponding to the users left hand.
  72641. */
  72642. readonly leftController: Nullable<WebVRController>;
  72643. private _rightController;
  72644. /**
  72645. * The controller corrisponding to the users right hand.
  72646. */
  72647. readonly rightController: Nullable<WebVRController>;
  72648. /**
  72649. * Casts a ray forward from the vrCamera's gaze.
  72650. * @param length Length of the ray (default: 100)
  72651. * @returns the ray corrisponding to the gaze
  72652. */
  72653. getForwardRay(length?: number): Ray;
  72654. /**
  72655. * @hidden
  72656. * Updates the camera based on device's frame data
  72657. */
  72658. _checkInputs(): void;
  72659. /**
  72660. * Updates the poseControlled values based on the input device pose.
  72661. * @param poseData Pose coming from the device
  72662. */
  72663. updateFromDevice(poseData: DevicePose): void;
  72664. private _htmlElementAttached;
  72665. private _detachIfAttached;
  72666. /**
  72667. * WebVR's attach control will start broadcasting frames to the device.
  72668. * Note that in certain browsers (chrome for example) this function must be called
  72669. * within a user-interaction callback. Example:
  72670. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  72671. *
  72672. * @param element html element to attach the vrDevice to
  72673. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  72674. */
  72675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72676. /**
  72677. * Detaches the camera from the html element and disables VR
  72678. *
  72679. * @param element html element to detach from
  72680. */
  72681. detachControl(element: HTMLElement): void;
  72682. /**
  72683. * @returns the name of this class
  72684. */
  72685. getClassName(): string;
  72686. /**
  72687. * Calls resetPose on the vrDisplay
  72688. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  72689. */
  72690. resetToCurrentRotation(): void;
  72691. /**
  72692. * @hidden
  72693. * Updates the rig cameras (left and right eye)
  72694. */
  72695. _updateRigCameras(): void;
  72696. private _workingVector;
  72697. private _oneVector;
  72698. private _workingMatrix;
  72699. private updateCacheCalled;
  72700. private _correctPositionIfNotTrackPosition;
  72701. /**
  72702. * @hidden
  72703. * Updates the cached values of the camera
  72704. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  72705. */
  72706. _updateCache(ignoreParentClass?: boolean): void;
  72707. /**
  72708. * @hidden
  72709. * Get current device position in babylon world
  72710. */
  72711. _computeDevicePosition(): void;
  72712. /**
  72713. * Updates the current device position and rotation in the babylon world
  72714. */
  72715. update(): void;
  72716. /**
  72717. * @hidden
  72718. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  72719. * @returns an identity matrix
  72720. */
  72721. _getViewMatrix(): Matrix;
  72722. private _tmpMatrix;
  72723. /**
  72724. * This function is called by the two RIG cameras.
  72725. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  72726. * @hidden
  72727. */
  72728. _getWebVRViewMatrix(): Matrix;
  72729. /** @hidden */
  72730. _getWebVRProjectionMatrix(): Matrix;
  72731. private _onGamepadConnectedObserver;
  72732. private _onGamepadDisconnectedObserver;
  72733. private _updateCacheWhenTrackingDisabledObserver;
  72734. /**
  72735. * Initializes the controllers and their meshes
  72736. */
  72737. initControllers(): void;
  72738. }
  72739. }
  72740. declare module BABYLON {
  72741. /**
  72742. * Size options for a post process
  72743. */
  72744. export type PostProcessOptions = {
  72745. width: number;
  72746. height: number;
  72747. };
  72748. /**
  72749. * PostProcess can be used to apply a shader to a texture after it has been rendered
  72750. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72751. */
  72752. export class PostProcess {
  72753. /** Name of the PostProcess. */
  72754. name: string;
  72755. /**
  72756. * Gets or sets the unique id of the post process
  72757. */
  72758. uniqueId: number;
  72759. /**
  72760. * Width of the texture to apply the post process on
  72761. */
  72762. width: number;
  72763. /**
  72764. * Height of the texture to apply the post process on
  72765. */
  72766. height: number;
  72767. /**
  72768. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  72769. * @hidden
  72770. */
  72771. _outputTexture: Nullable<InternalTexture>;
  72772. /**
  72773. * Sampling mode used by the shader
  72774. * See https://doc.babylonjs.com/classes/3.1/texture
  72775. */
  72776. renderTargetSamplingMode: number;
  72777. /**
  72778. * Clear color to use when screen clearing
  72779. */
  72780. clearColor: Color4;
  72781. /**
  72782. * If the buffer needs to be cleared before applying the post process. (default: true)
  72783. * Should be set to false if shader will overwrite all previous pixels.
  72784. */
  72785. autoClear: boolean;
  72786. /**
  72787. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72788. */
  72789. alphaMode: number;
  72790. /**
  72791. * Sets the setAlphaBlendConstants of the babylon engine
  72792. */
  72793. alphaConstants: Color4;
  72794. /**
  72795. * Animations to be used for the post processing
  72796. */
  72797. animations: Animation[];
  72798. /**
  72799. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72800. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72801. */
  72802. enablePixelPerfectMode: boolean;
  72803. /**
  72804. * Force the postprocess to be applied without taking in account viewport
  72805. */
  72806. forceFullscreenViewport: boolean;
  72807. /**
  72808. * List of inspectable custom properties (used by the Inspector)
  72809. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72810. */
  72811. inspectableCustomProperties: IInspectable[];
  72812. /**
  72813. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72814. *
  72815. * | Value | Type | Description |
  72816. * | ----- | ----------------------------------- | ----------- |
  72817. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72818. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72819. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72820. *
  72821. */
  72822. scaleMode: number;
  72823. /**
  72824. * Force textures to be a power of two (default: false)
  72825. */
  72826. alwaysForcePOT: boolean;
  72827. private _samples;
  72828. /**
  72829. * Number of sample textures (default: 1)
  72830. */
  72831. samples: number;
  72832. /**
  72833. * Modify the scale of the post process to be the same as the viewport (default: false)
  72834. */
  72835. adaptScaleToCurrentViewport: boolean;
  72836. private _camera;
  72837. private _scene;
  72838. private _engine;
  72839. private _options;
  72840. private _reusable;
  72841. private _textureType;
  72842. /**
  72843. * Smart array of input and output textures for the post process.
  72844. * @hidden
  72845. */
  72846. _textures: SmartArray<InternalTexture>;
  72847. /**
  72848. * The index in _textures that corresponds to the output texture.
  72849. * @hidden
  72850. */
  72851. _currentRenderTextureInd: number;
  72852. private _effect;
  72853. private _samplers;
  72854. private _fragmentUrl;
  72855. private _vertexUrl;
  72856. private _parameters;
  72857. private _scaleRatio;
  72858. protected _indexParameters: any;
  72859. private _shareOutputWithPostProcess;
  72860. private _texelSize;
  72861. private _forcedOutputTexture;
  72862. /**
  72863. * Returns the fragment url or shader name used in the post process.
  72864. * @returns the fragment url or name in the shader store.
  72865. */
  72866. getEffectName(): string;
  72867. /**
  72868. * An event triggered when the postprocess is activated.
  72869. */
  72870. onActivateObservable: Observable<Camera>;
  72871. private _onActivateObserver;
  72872. /**
  72873. * A function that is added to the onActivateObservable
  72874. */
  72875. onActivate: Nullable<(camera: Camera) => void>;
  72876. /**
  72877. * An event triggered when the postprocess changes its size.
  72878. */
  72879. onSizeChangedObservable: Observable<PostProcess>;
  72880. private _onSizeChangedObserver;
  72881. /**
  72882. * A function that is added to the onSizeChangedObservable
  72883. */
  72884. onSizeChanged: (postProcess: PostProcess) => void;
  72885. /**
  72886. * An event triggered when the postprocess applies its effect.
  72887. */
  72888. onApplyObservable: Observable<Effect>;
  72889. private _onApplyObserver;
  72890. /**
  72891. * A function that is added to the onApplyObservable
  72892. */
  72893. onApply: (effect: Effect) => void;
  72894. /**
  72895. * An event triggered before rendering the postprocess
  72896. */
  72897. onBeforeRenderObservable: Observable<Effect>;
  72898. private _onBeforeRenderObserver;
  72899. /**
  72900. * A function that is added to the onBeforeRenderObservable
  72901. */
  72902. onBeforeRender: (effect: Effect) => void;
  72903. /**
  72904. * An event triggered after rendering the postprocess
  72905. */
  72906. onAfterRenderObservable: Observable<Effect>;
  72907. private _onAfterRenderObserver;
  72908. /**
  72909. * A function that is added to the onAfterRenderObservable
  72910. */
  72911. onAfterRender: (efect: Effect) => void;
  72912. /**
  72913. * 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
  72914. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  72915. */
  72916. inputTexture: InternalTexture;
  72917. /**
  72918. * Gets the camera which post process is applied to.
  72919. * @returns The camera the post process is applied to.
  72920. */
  72921. getCamera(): Camera;
  72922. /**
  72923. * Gets the texel size of the postprocess.
  72924. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  72925. */
  72926. readonly texelSize: Vector2;
  72927. /**
  72928. * Creates a new instance PostProcess
  72929. * @param name The name of the PostProcess.
  72930. * @param fragmentUrl The url of the fragment shader to be used.
  72931. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  72932. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  72933. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72934. * @param camera The camera to apply the render pass to.
  72935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72936. * @param engine The engine which the post process will be applied. (default: current engine)
  72937. * @param reusable If the post process can be reused on the same frame. (default: false)
  72938. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  72939. * @param textureType Type of textures used when performing the post process. (default: 0)
  72940. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  72941. * @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
  72942. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  72943. */
  72944. constructor(
  72945. /** Name of the PostProcess. */
  72946. 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);
  72947. /**
  72948. * Gets a string idenfifying the name of the class
  72949. * @returns "PostProcess" string
  72950. */
  72951. getClassName(): string;
  72952. /**
  72953. * Gets the engine which this post process belongs to.
  72954. * @returns The engine the post process was enabled with.
  72955. */
  72956. getEngine(): Engine;
  72957. /**
  72958. * The effect that is created when initializing the post process.
  72959. * @returns The created effect corrisponding the the postprocess.
  72960. */
  72961. getEffect(): Effect;
  72962. /**
  72963. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  72964. * @param postProcess The post process to share the output with.
  72965. * @returns This post process.
  72966. */
  72967. shareOutputWith(postProcess: PostProcess): PostProcess;
  72968. /**
  72969. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  72970. * This should be called if the post process that shares output with this post process is disabled/disposed.
  72971. */
  72972. useOwnOutput(): void;
  72973. /**
  72974. * Updates the effect with the current post process compile time values and recompiles the shader.
  72975. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72976. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72977. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72978. * @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
  72979. * @param onCompiled Called when the shader has been compiled.
  72980. * @param onError Called if there is an error when compiling a shader.
  72981. */
  72982. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72983. /**
  72984. * The post process is reusable if it can be used multiple times within one frame.
  72985. * @returns If the post process is reusable
  72986. */
  72987. isReusable(): boolean;
  72988. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  72989. markTextureDirty(): void;
  72990. /**
  72991. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  72992. * 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.
  72993. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  72994. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  72995. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  72996. * @returns The target texture that was bound to be written to.
  72997. */
  72998. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  72999. /**
  73000. * If the post process is supported.
  73001. */
  73002. readonly isSupported: boolean;
  73003. /**
  73004. * The aspect ratio of the output texture.
  73005. */
  73006. readonly aspectRatio: number;
  73007. /**
  73008. * Get a value indicating if the post-process is ready to be used
  73009. * @returns true if the post-process is ready (shader is compiled)
  73010. */
  73011. isReady(): boolean;
  73012. /**
  73013. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73014. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73015. */
  73016. apply(): Nullable<Effect>;
  73017. private _disposeTextures;
  73018. /**
  73019. * Disposes the post process.
  73020. * @param camera The camera to dispose the post process on.
  73021. */
  73022. dispose(camera?: Camera): void;
  73023. }
  73024. }
  73025. declare module BABYLON {
  73026. /**
  73027. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73028. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73029. */
  73030. export class PostProcessManager {
  73031. private _scene;
  73032. private _indexBuffer;
  73033. private _vertexBuffers;
  73034. /**
  73035. * Creates a new instance PostProcess
  73036. * @param scene The scene that the post process is associated with.
  73037. */
  73038. constructor(scene: Scene);
  73039. private _prepareBuffers;
  73040. private _buildIndexBuffer;
  73041. /**
  73042. * Rebuilds the vertex buffers of the manager.
  73043. * @hidden
  73044. */
  73045. _rebuild(): void;
  73046. /**
  73047. * Prepares a frame to be run through a post process.
  73048. * @param sourceTexture The input texture to the post procesess. (default: null)
  73049. * @param postProcesses An array of post processes to be run. (default: null)
  73050. * @returns True if the post processes were able to be run.
  73051. * @hidden
  73052. */
  73053. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73054. /**
  73055. * Manually render a set of post processes to a texture.
  73056. * @param postProcesses An array of post processes to be run.
  73057. * @param targetTexture The target texture to render to.
  73058. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73059. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73060. * @param lodLevel defines which lod of the texture to render to
  73061. */
  73062. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73063. /**
  73064. * Finalize the result of the output of the postprocesses.
  73065. * @param doNotPresent If true the result will not be displayed to the screen.
  73066. * @param targetTexture The target texture to render to.
  73067. * @param faceIndex The index of the face to bind the target texture to.
  73068. * @param postProcesses The array of post processes to render.
  73069. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73070. * @hidden
  73071. */
  73072. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73073. /**
  73074. * Disposes of the post process manager.
  73075. */
  73076. dispose(): void;
  73077. }
  73078. }
  73079. declare module BABYLON {
  73080. interface AbstractScene {
  73081. /**
  73082. * The list of layers (background and foreground) of the scene
  73083. */
  73084. layers: Array<Layer>;
  73085. }
  73086. /**
  73087. * Defines the layer scene component responsible to manage any layers
  73088. * in a given scene.
  73089. */
  73090. export class LayerSceneComponent implements ISceneComponent {
  73091. /**
  73092. * The component name helpfull to identify the component in the list of scene components.
  73093. */
  73094. readonly name: string;
  73095. /**
  73096. * The scene the component belongs to.
  73097. */
  73098. scene: Scene;
  73099. private _engine;
  73100. /**
  73101. * Creates a new instance of the component for the given scene
  73102. * @param scene Defines the scene to register the component in
  73103. */
  73104. constructor(scene: Scene);
  73105. /**
  73106. * Registers the component in a given scene
  73107. */
  73108. register(): void;
  73109. /**
  73110. * Rebuilds the elements related to this component in case of
  73111. * context lost for instance.
  73112. */
  73113. rebuild(): void;
  73114. /**
  73115. * Disposes the component and the associated ressources.
  73116. */
  73117. dispose(): void;
  73118. private _draw;
  73119. private _drawCameraPredicate;
  73120. private _drawCameraBackground;
  73121. private _drawCameraForeground;
  73122. private _drawRenderTargetPredicate;
  73123. private _drawRenderTargetBackground;
  73124. private _drawRenderTargetForeground;
  73125. }
  73126. }
  73127. declare module BABYLON {
  73128. /** @hidden */
  73129. export var layerPixelShader: {
  73130. name: string;
  73131. shader: string;
  73132. };
  73133. }
  73134. declare module BABYLON {
  73135. /** @hidden */
  73136. export var layerVertexShader: {
  73137. name: string;
  73138. shader: string;
  73139. };
  73140. }
  73141. declare module BABYLON {
  73142. /**
  73143. * This represents a full screen 2d layer.
  73144. * This can be useful to display a picture in the background of your scene for instance.
  73145. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73146. */
  73147. export class Layer {
  73148. /**
  73149. * Define the name of the layer.
  73150. */
  73151. name: string;
  73152. /**
  73153. * Define the texture the layer should display.
  73154. */
  73155. texture: Nullable<Texture>;
  73156. /**
  73157. * Is the layer in background or foreground.
  73158. */
  73159. isBackground: boolean;
  73160. /**
  73161. * Define the color of the layer (instead of texture).
  73162. */
  73163. color: Color4;
  73164. /**
  73165. * Define the scale of the layer in order to zoom in out of the texture.
  73166. */
  73167. scale: Vector2;
  73168. /**
  73169. * Define an offset for the layer in order to shift the texture.
  73170. */
  73171. offset: Vector2;
  73172. /**
  73173. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73174. */
  73175. alphaBlendingMode: number;
  73176. /**
  73177. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73178. * Alpha test will not mix with the background color in case of transparency.
  73179. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73180. */
  73181. alphaTest: boolean;
  73182. /**
  73183. * Define a mask to restrict the layer to only some of the scene cameras.
  73184. */
  73185. layerMask: number;
  73186. /**
  73187. * Define the list of render target the layer is visible into.
  73188. */
  73189. renderTargetTextures: RenderTargetTexture[];
  73190. /**
  73191. * Define if the layer is only used in renderTarget or if it also
  73192. * renders in the main frame buffer of the canvas.
  73193. */
  73194. renderOnlyInRenderTargetTextures: boolean;
  73195. private _scene;
  73196. private _vertexBuffers;
  73197. private _indexBuffer;
  73198. private _effect;
  73199. private _alphaTestEffect;
  73200. /**
  73201. * An event triggered when the layer is disposed.
  73202. */
  73203. onDisposeObservable: Observable<Layer>;
  73204. private _onDisposeObserver;
  73205. /**
  73206. * Back compatibility with callback before the onDisposeObservable existed.
  73207. * The set callback will be triggered when the layer has been disposed.
  73208. */
  73209. onDispose: () => void;
  73210. /**
  73211. * An event triggered before rendering the scene
  73212. */
  73213. onBeforeRenderObservable: Observable<Layer>;
  73214. private _onBeforeRenderObserver;
  73215. /**
  73216. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73217. * The set callback will be triggered just before rendering the layer.
  73218. */
  73219. onBeforeRender: () => void;
  73220. /**
  73221. * An event triggered after rendering the scene
  73222. */
  73223. onAfterRenderObservable: Observable<Layer>;
  73224. private _onAfterRenderObserver;
  73225. /**
  73226. * Back compatibility with callback before the onAfterRenderObservable existed.
  73227. * The set callback will be triggered just after rendering the layer.
  73228. */
  73229. onAfterRender: () => void;
  73230. /**
  73231. * Instantiates a new layer.
  73232. * This represents a full screen 2d layer.
  73233. * This can be useful to display a picture in the background of your scene for instance.
  73234. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73235. * @param name Define the name of the layer in the scene
  73236. * @param imgUrl Define the url of the texture to display in the layer
  73237. * @param scene Define the scene the layer belongs to
  73238. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73239. * @param color Defines a color for the layer
  73240. */
  73241. constructor(
  73242. /**
  73243. * Define the name of the layer.
  73244. */
  73245. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73246. private _createIndexBuffer;
  73247. /** @hidden */
  73248. _rebuild(): void;
  73249. /**
  73250. * Renders the layer in the scene.
  73251. */
  73252. render(): void;
  73253. /**
  73254. * Disposes and releases the associated ressources.
  73255. */
  73256. dispose(): void;
  73257. }
  73258. }
  73259. declare module BABYLON {
  73260. interface AbstractScene {
  73261. /**
  73262. * The list of procedural textures added to the scene
  73263. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73264. */
  73265. proceduralTextures: Array<ProceduralTexture>;
  73266. }
  73267. /**
  73268. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  73269. * in a given scene.
  73270. */
  73271. export class ProceduralTextureSceneComponent implements ISceneComponent {
  73272. /**
  73273. * The component name helpfull to identify the component in the list of scene components.
  73274. */
  73275. readonly name: string;
  73276. /**
  73277. * The scene the component belongs to.
  73278. */
  73279. scene: Scene;
  73280. /**
  73281. * Creates a new instance of the component for the given scene
  73282. * @param scene Defines the scene to register the component in
  73283. */
  73284. constructor(scene: Scene);
  73285. /**
  73286. * Registers the component in a given scene
  73287. */
  73288. register(): void;
  73289. /**
  73290. * Rebuilds the elements related to this component in case of
  73291. * context lost for instance.
  73292. */
  73293. rebuild(): void;
  73294. /**
  73295. * Disposes the component and the associated ressources.
  73296. */
  73297. dispose(): void;
  73298. private _beforeClear;
  73299. }
  73300. }
  73301. declare module BABYLON {
  73302. /** @hidden */
  73303. export var proceduralVertexShader: {
  73304. name: string;
  73305. shader: string;
  73306. };
  73307. }
  73308. declare module BABYLON {
  73309. /**
  73310. * 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.
  73311. * This is the base class of any Procedural texture and contains most of the shareable code.
  73312. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73313. */
  73314. export class ProceduralTexture extends Texture {
  73315. isCube: boolean;
  73316. /**
  73317. * Define if the texture is enabled or not (disabled texture will not render)
  73318. */
  73319. isEnabled: boolean;
  73320. /**
  73321. * Define if the texture must be cleared before rendering (default is true)
  73322. */
  73323. autoClear: boolean;
  73324. /**
  73325. * Callback called when the texture is generated
  73326. */
  73327. onGenerated: () => void;
  73328. /**
  73329. * Event raised when the texture is generated
  73330. */
  73331. onGeneratedObservable: Observable<ProceduralTexture>;
  73332. /** @hidden */
  73333. _generateMipMaps: boolean;
  73334. /** @hidden **/
  73335. _effect: Effect;
  73336. /** @hidden */
  73337. _textures: {
  73338. [key: string]: Texture;
  73339. };
  73340. private _size;
  73341. private _currentRefreshId;
  73342. private _refreshRate;
  73343. private _vertexBuffers;
  73344. private _indexBuffer;
  73345. private _uniforms;
  73346. private _samplers;
  73347. private _fragment;
  73348. private _floats;
  73349. private _ints;
  73350. private _floatsArrays;
  73351. private _colors3;
  73352. private _colors4;
  73353. private _vectors2;
  73354. private _vectors3;
  73355. private _matrices;
  73356. private _fallbackTexture;
  73357. private _fallbackTextureUsed;
  73358. private _engine;
  73359. private _cachedDefines;
  73360. private _contentUpdateId;
  73361. private _contentData;
  73362. /**
  73363. * Instantiates a new procedural texture.
  73364. * 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.
  73365. * This is the base class of any Procedural texture and contains most of the shareable code.
  73366. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73367. * @param name Define the name of the texture
  73368. * @param size Define the size of the texture to create
  73369. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73370. * @param scene Define the scene the texture belongs to
  73371. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73372. * @param generateMipMaps Define if the texture should creates mip maps or not
  73373. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73374. */
  73375. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73376. /**
  73377. * The effect that is created when initializing the post process.
  73378. * @returns The created effect corrisponding the the postprocess.
  73379. */
  73380. getEffect(): Effect;
  73381. /**
  73382. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73383. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73384. */
  73385. getContent(): Nullable<ArrayBufferView>;
  73386. private _createIndexBuffer;
  73387. /** @hidden */
  73388. _rebuild(): void;
  73389. /**
  73390. * Resets the texture in order to recreate its associated resources.
  73391. * This can be called in case of context loss
  73392. */
  73393. reset(): void;
  73394. protected _getDefines(): string;
  73395. /**
  73396. * Is the texture ready to be used ? (rendered at least once)
  73397. * @returns true if ready, otherwise, false.
  73398. */
  73399. isReady(): boolean;
  73400. /**
  73401. * Resets the refresh counter of the texture and start bak from scratch.
  73402. * Could be useful to regenerate the texture if it is setup to render only once.
  73403. */
  73404. resetRefreshCounter(): void;
  73405. /**
  73406. * Set the fragment shader to use in order to render the texture.
  73407. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73408. */
  73409. setFragment(fragment: any): void;
  73410. /**
  73411. * Define the refresh rate of the texture or the rendering frequency.
  73412. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73413. */
  73414. refreshRate: number;
  73415. /** @hidden */
  73416. _shouldRender(): boolean;
  73417. /**
  73418. * Get the size the texture is rendering at.
  73419. * @returns the size (texture is always squared)
  73420. */
  73421. getRenderSize(): number;
  73422. /**
  73423. * Resize the texture to new value.
  73424. * @param size Define the new size the texture should have
  73425. * @param generateMipMaps Define whether the new texture should create mip maps
  73426. */
  73427. resize(size: number, generateMipMaps: boolean): void;
  73428. private _checkUniform;
  73429. /**
  73430. * Set a texture in the shader program used to render.
  73431. * @param name Define the name of the uniform samplers as defined in the shader
  73432. * @param texture Define the texture to bind to this sampler
  73433. * @return the texture itself allowing "fluent" like uniform updates
  73434. */
  73435. setTexture(name: string, texture: Texture): ProceduralTexture;
  73436. /**
  73437. * Set a float in the shader.
  73438. * @param name Define the name of the uniform as defined in the shader
  73439. * @param value Define the value to give to the uniform
  73440. * @return the texture itself allowing "fluent" like uniform updates
  73441. */
  73442. setFloat(name: string, value: number): ProceduralTexture;
  73443. /**
  73444. * Set a int in the shader.
  73445. * @param name Define the name of the uniform as defined in the shader
  73446. * @param value Define the value to give to the uniform
  73447. * @return the texture itself allowing "fluent" like uniform updates
  73448. */
  73449. setInt(name: string, value: number): ProceduralTexture;
  73450. /**
  73451. * Set an array of floats in the shader.
  73452. * @param name Define the name of the uniform as defined in the shader
  73453. * @param value Define the value to give to the uniform
  73454. * @return the texture itself allowing "fluent" like uniform updates
  73455. */
  73456. setFloats(name: string, value: number[]): ProceduralTexture;
  73457. /**
  73458. * Set a vec3 in the shader from a Color3.
  73459. * @param name Define the name of the uniform as defined in the shader
  73460. * @param value Define the value to give to the uniform
  73461. * @return the texture itself allowing "fluent" like uniform updates
  73462. */
  73463. setColor3(name: string, value: Color3): ProceduralTexture;
  73464. /**
  73465. * Set a vec4 in the shader from a Color4.
  73466. * @param name Define the name of the uniform as defined in the shader
  73467. * @param value Define the value to give to the uniform
  73468. * @return the texture itself allowing "fluent" like uniform updates
  73469. */
  73470. setColor4(name: string, value: Color4): ProceduralTexture;
  73471. /**
  73472. * Set a vec2 in the shader from a Vector2.
  73473. * @param name Define the name of the uniform as defined in the shader
  73474. * @param value Define the value to give to the uniform
  73475. * @return the texture itself allowing "fluent" like uniform updates
  73476. */
  73477. setVector2(name: string, value: Vector2): ProceduralTexture;
  73478. /**
  73479. * Set a vec3 in the shader from a Vector3.
  73480. * @param name Define the name of the uniform as defined in the shader
  73481. * @param value Define the value to give to the uniform
  73482. * @return the texture itself allowing "fluent" like uniform updates
  73483. */
  73484. setVector3(name: string, value: Vector3): ProceduralTexture;
  73485. /**
  73486. * Set a mat4 in the shader from a MAtrix.
  73487. * @param name Define the name of the uniform as defined in the shader
  73488. * @param value Define the value to give to the uniform
  73489. * @return the texture itself allowing "fluent" like uniform updates
  73490. */
  73491. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73492. /**
  73493. * Render the texture to its associated render target.
  73494. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73495. */
  73496. render(useCameraPostProcess?: boolean): void;
  73497. /**
  73498. * Clone the texture.
  73499. * @returns the cloned texture
  73500. */
  73501. clone(): ProceduralTexture;
  73502. /**
  73503. * Dispose the texture and release its asoociated resources.
  73504. */
  73505. dispose(): void;
  73506. }
  73507. }
  73508. declare module BABYLON {
  73509. /**
  73510. * This represents the base class for particle system in Babylon.
  73511. * 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.
  73512. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73513. * @example https://doc.babylonjs.com/babylon101/particles
  73514. */
  73515. export class BaseParticleSystem {
  73516. /**
  73517. * Source color is added to the destination color without alpha affecting the result
  73518. */
  73519. static BLENDMODE_ONEONE: number;
  73520. /**
  73521. * Blend current color and particle color using particle’s alpha
  73522. */
  73523. static BLENDMODE_STANDARD: number;
  73524. /**
  73525. * Add current color and particle color multiplied by particle’s alpha
  73526. */
  73527. static BLENDMODE_ADD: number;
  73528. /**
  73529. * Multiply current color with particle color
  73530. */
  73531. static BLENDMODE_MULTIPLY: number;
  73532. /**
  73533. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  73534. */
  73535. static BLENDMODE_MULTIPLYADD: number;
  73536. /**
  73537. * List of animations used by the particle system.
  73538. */
  73539. animations: Animation[];
  73540. /**
  73541. * The id of the Particle system.
  73542. */
  73543. id: string;
  73544. /**
  73545. * The friendly name of the Particle system.
  73546. */
  73547. name: string;
  73548. /**
  73549. * The rendering group used by the Particle system to chose when to render.
  73550. */
  73551. renderingGroupId: number;
  73552. /**
  73553. * The emitter represents the Mesh or position we are attaching the particle system to.
  73554. */
  73555. emitter: Nullable<AbstractMesh | Vector3>;
  73556. /**
  73557. * The maximum number of particles to emit per frame
  73558. */
  73559. emitRate: number;
  73560. /**
  73561. * If you want to launch only a few particles at once, that can be done, as well.
  73562. */
  73563. manualEmitCount: number;
  73564. /**
  73565. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73566. */
  73567. updateSpeed: number;
  73568. /**
  73569. * The amount of time the particle system is running (depends of the overall update speed).
  73570. */
  73571. targetStopDuration: number;
  73572. /**
  73573. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73574. */
  73575. disposeOnStop: boolean;
  73576. /**
  73577. * Minimum power of emitting particles.
  73578. */
  73579. minEmitPower: number;
  73580. /**
  73581. * Maximum power of emitting particles.
  73582. */
  73583. maxEmitPower: number;
  73584. /**
  73585. * Minimum life time of emitting particles.
  73586. */
  73587. minLifeTime: number;
  73588. /**
  73589. * Maximum life time of emitting particles.
  73590. */
  73591. maxLifeTime: number;
  73592. /**
  73593. * Minimum Size of emitting particles.
  73594. */
  73595. minSize: number;
  73596. /**
  73597. * Maximum Size of emitting particles.
  73598. */
  73599. maxSize: number;
  73600. /**
  73601. * Minimum scale of emitting particles on X axis.
  73602. */
  73603. minScaleX: number;
  73604. /**
  73605. * Maximum scale of emitting particles on X axis.
  73606. */
  73607. maxScaleX: number;
  73608. /**
  73609. * Minimum scale of emitting particles on Y axis.
  73610. */
  73611. minScaleY: number;
  73612. /**
  73613. * Maximum scale of emitting particles on Y axis.
  73614. */
  73615. maxScaleY: number;
  73616. /**
  73617. * Gets or sets the minimal initial rotation in radians.
  73618. */
  73619. minInitialRotation: number;
  73620. /**
  73621. * Gets or sets the maximal initial rotation in radians.
  73622. */
  73623. maxInitialRotation: number;
  73624. /**
  73625. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73626. */
  73627. minAngularSpeed: number;
  73628. /**
  73629. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73630. */
  73631. maxAngularSpeed: number;
  73632. /**
  73633. * The texture used to render each particle. (this can be a spritesheet)
  73634. */
  73635. particleTexture: Nullable<Texture>;
  73636. /**
  73637. * The layer mask we are rendering the particles through.
  73638. */
  73639. layerMask: number;
  73640. /**
  73641. * This can help using your own shader to render the particle system.
  73642. * The according effect will be created
  73643. */
  73644. customShader: any;
  73645. /**
  73646. * By default particle system starts as soon as they are created. This prevents the
  73647. * automatic start to happen and let you decide when to start emitting particles.
  73648. */
  73649. preventAutoStart: boolean;
  73650. private _noiseTexture;
  73651. /**
  73652. * Gets or sets a texture used to add random noise to particle positions
  73653. */
  73654. noiseTexture: Nullable<ProceduralTexture>;
  73655. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73656. noiseStrength: Vector3;
  73657. /**
  73658. * Callback triggered when the particle animation is ending.
  73659. */
  73660. onAnimationEnd: Nullable<() => void>;
  73661. /**
  73662. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  73663. */
  73664. blendMode: number;
  73665. /**
  73666. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  73667. * to override the particles.
  73668. */
  73669. forceDepthWrite: boolean;
  73670. /** 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 */
  73671. preWarmCycles: number;
  73672. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  73673. preWarmStepOffset: number;
  73674. /**
  73675. * 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)
  73676. */
  73677. spriteCellChangeSpeed: number;
  73678. /**
  73679. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73680. */
  73681. startSpriteCellID: number;
  73682. /**
  73683. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73684. */
  73685. endSpriteCellID: number;
  73686. /**
  73687. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73688. */
  73689. spriteCellWidth: number;
  73690. /**
  73691. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73692. */
  73693. spriteCellHeight: number;
  73694. /**
  73695. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73696. */
  73697. spriteRandomStartCell: boolean;
  73698. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73699. translationPivot: Vector2;
  73700. /** @hidden */
  73701. protected _isAnimationSheetEnabled: boolean;
  73702. /**
  73703. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73704. */
  73705. beginAnimationOnStart: boolean;
  73706. /**
  73707. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73708. */
  73709. beginAnimationFrom: number;
  73710. /**
  73711. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73712. */
  73713. beginAnimationTo: number;
  73714. /**
  73715. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73716. */
  73717. beginAnimationLoop: boolean;
  73718. /**
  73719. * Gets or sets a world offset applied to all particles
  73720. */
  73721. worldOffset: Vector3;
  73722. /**
  73723. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  73724. */
  73725. isAnimationSheetEnabled: boolean;
  73726. /**
  73727. * Get hosting scene
  73728. * @returns the scene
  73729. */
  73730. getScene(): Scene;
  73731. /**
  73732. * You can use gravity if you want to give an orientation to your particles.
  73733. */
  73734. gravity: Vector3;
  73735. protected _colorGradients: Nullable<Array<ColorGradient>>;
  73736. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  73737. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  73738. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  73739. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  73740. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  73741. protected _dragGradients: Nullable<Array<FactorGradient>>;
  73742. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  73743. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  73744. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  73745. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  73746. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  73747. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  73748. /**
  73749. * Defines the delay in milliseconds before starting the system (0 by default)
  73750. */
  73751. startDelay: number;
  73752. /**
  73753. * Gets the current list of drag gradients.
  73754. * You must use addDragGradient and removeDragGradient to udpate this list
  73755. * @returns the list of drag gradients
  73756. */
  73757. getDragGradients(): Nullable<Array<FactorGradient>>;
  73758. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73759. limitVelocityDamping: number;
  73760. /**
  73761. * Gets the current list of limit velocity gradients.
  73762. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73763. * @returns the list of limit velocity gradients
  73764. */
  73765. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73766. /**
  73767. * Gets the current list of color gradients.
  73768. * You must use addColorGradient and removeColorGradient to udpate this list
  73769. * @returns the list of color gradients
  73770. */
  73771. getColorGradients(): Nullable<Array<ColorGradient>>;
  73772. /**
  73773. * Gets the current list of size gradients.
  73774. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73775. * @returns the list of size gradients
  73776. */
  73777. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73778. /**
  73779. * Gets the current list of color remap gradients.
  73780. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73781. * @returns the list of color remap gradients
  73782. */
  73783. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73784. /**
  73785. * Gets the current list of alpha remap gradients.
  73786. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73787. * @returns the list of alpha remap gradients
  73788. */
  73789. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73790. /**
  73791. * Gets the current list of life time gradients.
  73792. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73793. * @returns the list of life time gradients
  73794. */
  73795. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73796. /**
  73797. * Gets the current list of angular speed gradients.
  73798. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73799. * @returns the list of angular speed gradients
  73800. */
  73801. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73802. /**
  73803. * Gets the current list of velocity gradients.
  73804. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73805. * @returns the list of velocity gradients
  73806. */
  73807. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73808. /**
  73809. * Gets the current list of start size gradients.
  73810. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73811. * @returns the list of start size gradients
  73812. */
  73813. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73814. /**
  73815. * Gets the current list of emit rate gradients.
  73816. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73817. * @returns the list of emit rate gradients
  73818. */
  73819. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73820. /**
  73821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73822. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73823. */
  73824. direction1: Vector3;
  73825. /**
  73826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73827. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73828. */
  73829. direction2: Vector3;
  73830. /**
  73831. * 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.
  73832. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73833. */
  73834. minEmitBox: Vector3;
  73835. /**
  73836. * 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.
  73837. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73838. */
  73839. maxEmitBox: Vector3;
  73840. /**
  73841. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73842. */
  73843. color1: Color4;
  73844. /**
  73845. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73846. */
  73847. color2: Color4;
  73848. /**
  73849. * Color the particle will have at the end of its lifetime
  73850. */
  73851. colorDead: Color4;
  73852. /**
  73853. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73854. */
  73855. textureMask: Color4;
  73856. /**
  73857. * The particle emitter type defines the emitter used by the particle system.
  73858. * It can be for example box, sphere, or cone...
  73859. */
  73860. particleEmitterType: IParticleEmitterType;
  73861. /** @hidden */
  73862. _isSubEmitter: boolean;
  73863. /**
  73864. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73865. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73866. */
  73867. billboardMode: number;
  73868. protected _isBillboardBased: boolean;
  73869. /**
  73870. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73871. */
  73872. isBillboardBased: boolean;
  73873. /**
  73874. * The scene the particle system belongs to.
  73875. */
  73876. protected _scene: Scene;
  73877. /**
  73878. * Local cache of defines for image processing.
  73879. */
  73880. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  73881. /**
  73882. * Default configuration related to image processing available in the standard Material.
  73883. */
  73884. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  73885. /**
  73886. * Gets the image processing configuration used either in this material.
  73887. */
  73888. /**
  73889. * Sets the Default image processing configuration used either in the this material.
  73890. *
  73891. * If sets to null, the scene one is in use.
  73892. */
  73893. imageProcessingConfiguration: ImageProcessingConfiguration;
  73894. /**
  73895. * Attaches a new image processing configuration to the Standard Material.
  73896. * @param configuration
  73897. */
  73898. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  73899. /** @hidden */
  73900. protected _reset(): void;
  73901. /** @hidden */
  73902. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  73903. /**
  73904. * Instantiates a particle system.
  73905. * 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.
  73906. * @param name The name of the particle system
  73907. */
  73908. constructor(name: string);
  73909. /**
  73910. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73911. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73912. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73913. * @returns the emitter
  73914. */
  73915. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73916. /**
  73917. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73918. * @param radius The radius of the hemisphere to emit from
  73919. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73920. * @returns the emitter
  73921. */
  73922. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  73923. /**
  73924. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73925. * @param radius The radius of the sphere to emit from
  73926. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73927. * @returns the emitter
  73928. */
  73929. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  73930. /**
  73931. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73932. * @param radius The radius of the sphere to emit from
  73933. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73934. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73935. * @returns the emitter
  73936. */
  73937. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  73938. /**
  73939. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73940. * @param radius The radius of the emission cylinder
  73941. * @param height The height of the emission cylinder
  73942. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73943. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73944. * @returns the emitter
  73945. */
  73946. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  73947. /**
  73948. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73949. * @param radius The radius of the cylinder to emit from
  73950. * @param height The height of the emission cylinder
  73951. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73952. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73953. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73954. * @returns the emitter
  73955. */
  73956. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  73957. /**
  73958. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73959. * @param radius The radius of the cone to emit from
  73960. * @param angle The base angle of the cone
  73961. * @returns the emitter
  73962. */
  73963. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  73964. /**
  73965. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73966. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73967. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73968. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73969. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73970. * @returns the emitter
  73971. */
  73972. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73973. }
  73974. }
  73975. declare module BABYLON {
  73976. /**
  73977. * Type of sub emitter
  73978. */
  73979. export enum SubEmitterType {
  73980. /**
  73981. * Attached to the particle over it's lifetime
  73982. */
  73983. ATTACHED = 0,
  73984. /**
  73985. * Created when the particle dies
  73986. */
  73987. END = 1
  73988. }
  73989. /**
  73990. * Sub emitter class used to emit particles from an existing particle
  73991. */
  73992. export class SubEmitter {
  73993. /**
  73994. * the particle system to be used by the sub emitter
  73995. */
  73996. particleSystem: ParticleSystem;
  73997. /**
  73998. * Type of the submitter (Default: END)
  73999. */
  74000. type: SubEmitterType;
  74001. /**
  74002. * 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)
  74003. * Note: This only is supported when using an emitter of type Mesh
  74004. */
  74005. inheritDirection: boolean;
  74006. /**
  74007. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74008. */
  74009. inheritedVelocityAmount: number;
  74010. /**
  74011. * Creates a sub emitter
  74012. * @param particleSystem the particle system to be used by the sub emitter
  74013. */
  74014. constructor(
  74015. /**
  74016. * the particle system to be used by the sub emitter
  74017. */
  74018. particleSystem: ParticleSystem);
  74019. /**
  74020. * Clones the sub emitter
  74021. * @returns the cloned sub emitter
  74022. */
  74023. clone(): SubEmitter;
  74024. /**
  74025. * Serialize current object to a JSON object
  74026. * @returns the serialized object
  74027. */
  74028. serialize(): any;
  74029. /** @hidden */
  74030. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74031. /**
  74032. * Creates a new SubEmitter from a serialized JSON version
  74033. * @param serializationObject defines the JSON object to read from
  74034. * @param scene defines the hosting scene
  74035. * @param rootUrl defines the rootUrl for data loading
  74036. * @returns a new SubEmitter
  74037. */
  74038. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74039. /** Release associated resources */
  74040. dispose(): void;
  74041. }
  74042. }
  74043. declare module BABYLON {
  74044. /** @hidden */
  74045. export var clipPlaneFragmentDeclaration: {
  74046. name: string;
  74047. shader: string;
  74048. };
  74049. }
  74050. declare module BABYLON {
  74051. /** @hidden */
  74052. export var imageProcessingDeclaration: {
  74053. name: string;
  74054. shader: string;
  74055. };
  74056. }
  74057. declare module BABYLON {
  74058. /** @hidden */
  74059. export var imageProcessingFunctions: {
  74060. name: string;
  74061. shader: string;
  74062. };
  74063. }
  74064. declare module BABYLON {
  74065. /** @hidden */
  74066. export var clipPlaneFragment: {
  74067. name: string;
  74068. shader: string;
  74069. };
  74070. }
  74071. declare module BABYLON {
  74072. /** @hidden */
  74073. export var particlesPixelShader: {
  74074. name: string;
  74075. shader: string;
  74076. };
  74077. }
  74078. declare module BABYLON {
  74079. /** @hidden */
  74080. export var clipPlaneVertexDeclaration: {
  74081. name: string;
  74082. shader: string;
  74083. };
  74084. }
  74085. declare module BABYLON {
  74086. /** @hidden */
  74087. export var clipPlaneVertex: {
  74088. name: string;
  74089. shader: string;
  74090. };
  74091. }
  74092. declare module BABYLON {
  74093. /** @hidden */
  74094. export var particlesVertexShader: {
  74095. name: string;
  74096. shader: string;
  74097. };
  74098. }
  74099. declare module BABYLON {
  74100. /**
  74101. * This represents a particle system in Babylon.
  74102. * 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.
  74103. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74104. * @example https://doc.babylonjs.com/babylon101/particles
  74105. */
  74106. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74107. /**
  74108. * Billboard mode will only apply to Y axis
  74109. */
  74110. static readonly BILLBOARDMODE_Y: number;
  74111. /**
  74112. * Billboard mode will apply to all axes
  74113. */
  74114. static readonly BILLBOARDMODE_ALL: number;
  74115. /**
  74116. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74117. */
  74118. static readonly BILLBOARDMODE_STRETCHED: number;
  74119. /**
  74120. * This function can be defined to provide custom update for active particles.
  74121. * This function will be called instead of regular update (age, position, color, etc.).
  74122. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74123. */
  74124. updateFunction: (particles: Particle[]) => void;
  74125. private _emitterWorldMatrix;
  74126. /**
  74127. * This function can be defined to specify initial direction for every new particle.
  74128. * It by default use the emitterType defined function
  74129. */
  74130. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74131. /**
  74132. * This function can be defined to specify initial position for every new particle.
  74133. * It by default use the emitterType defined function
  74134. */
  74135. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74136. /**
  74137. * @hidden
  74138. */
  74139. _inheritedVelocityOffset: Vector3;
  74140. /**
  74141. * An event triggered when the system is disposed
  74142. */
  74143. onDisposeObservable: Observable<ParticleSystem>;
  74144. private _onDisposeObserver;
  74145. /**
  74146. * Sets a callback that will be triggered when the system is disposed
  74147. */
  74148. onDispose: () => void;
  74149. private _particles;
  74150. private _epsilon;
  74151. private _capacity;
  74152. private _stockParticles;
  74153. private _newPartsExcess;
  74154. private _vertexData;
  74155. private _vertexBuffer;
  74156. private _vertexBuffers;
  74157. private _spriteBuffer;
  74158. private _indexBuffer;
  74159. private _effect;
  74160. private _customEffect;
  74161. private _cachedDefines;
  74162. private _scaledColorStep;
  74163. private _colorDiff;
  74164. private _scaledDirection;
  74165. private _scaledGravity;
  74166. private _currentRenderId;
  74167. private _alive;
  74168. private _useInstancing;
  74169. private _started;
  74170. private _stopped;
  74171. private _actualFrame;
  74172. private _scaledUpdateSpeed;
  74173. private _vertexBufferSize;
  74174. /** @hidden */
  74175. _currentEmitRateGradient: Nullable<FactorGradient>;
  74176. /** @hidden */
  74177. _currentEmitRate1: number;
  74178. /** @hidden */
  74179. _currentEmitRate2: number;
  74180. /** @hidden */
  74181. _currentStartSizeGradient: Nullable<FactorGradient>;
  74182. /** @hidden */
  74183. _currentStartSize1: number;
  74184. /** @hidden */
  74185. _currentStartSize2: number;
  74186. private readonly _rawTextureWidth;
  74187. private _rampGradientsTexture;
  74188. private _useRampGradients;
  74189. /** Gets or sets a boolean indicating that ramp gradients must be used
  74190. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74191. */
  74192. useRampGradients: boolean;
  74193. /**
  74194. * 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.
  74195. * 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: [])
  74196. */
  74197. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74198. private _subEmitters;
  74199. /**
  74200. * @hidden
  74201. * If the particle systems emitter should be disposed when the particle system is disposed
  74202. */
  74203. _disposeEmitterOnDispose: boolean;
  74204. /**
  74205. * The current active Sub-systems, this property is used by the root particle system only.
  74206. */
  74207. activeSubSystems: Array<ParticleSystem>;
  74208. private _rootParticleSystem;
  74209. /**
  74210. * Gets the current list of active particles
  74211. */
  74212. readonly particles: Particle[];
  74213. /**
  74214. * Returns the string "ParticleSystem"
  74215. * @returns a string containing the class name
  74216. */
  74217. getClassName(): string;
  74218. /**
  74219. * Instantiates a particle system.
  74220. * 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.
  74221. * @param name The name of the particle system
  74222. * @param capacity The max number of particles alive at the same time
  74223. * @param scene The scene the particle system belongs to
  74224. * @param customEffect a custom effect used to change the way particles are rendered by default
  74225. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74226. * @param epsilon Offset used to render the particles
  74227. */
  74228. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74229. private _addFactorGradient;
  74230. private _removeFactorGradient;
  74231. /**
  74232. * Adds a new life time gradient
  74233. * @param gradient defines the gradient to use (between 0 and 1)
  74234. * @param factor defines the life time factor to affect to the specified gradient
  74235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74236. * @returns the current particle system
  74237. */
  74238. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74239. /**
  74240. * Remove a specific life time gradient
  74241. * @param gradient defines the gradient to remove
  74242. * @returns the current particle system
  74243. */
  74244. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74245. /**
  74246. * Adds a new size gradient
  74247. * @param gradient defines the gradient to use (between 0 and 1)
  74248. * @param factor defines the size factor to affect to the specified gradient
  74249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74250. * @returns the current particle system
  74251. */
  74252. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74253. /**
  74254. * Remove a specific size gradient
  74255. * @param gradient defines the gradient to remove
  74256. * @returns the current particle system
  74257. */
  74258. removeSizeGradient(gradient: number): IParticleSystem;
  74259. /**
  74260. * Adds a new color remap gradient
  74261. * @param gradient defines the gradient to use (between 0 and 1)
  74262. * @param min defines the color remap minimal range
  74263. * @param max defines the color remap maximal range
  74264. * @returns the current particle system
  74265. */
  74266. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74267. /**
  74268. * Remove a specific color remap gradient
  74269. * @param gradient defines the gradient to remove
  74270. * @returns the current particle system
  74271. */
  74272. removeColorRemapGradient(gradient: number): IParticleSystem;
  74273. /**
  74274. * Adds a new alpha remap gradient
  74275. * @param gradient defines the gradient to use (between 0 and 1)
  74276. * @param min defines the alpha remap minimal range
  74277. * @param max defines the alpha remap maximal range
  74278. * @returns the current particle system
  74279. */
  74280. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74281. /**
  74282. * Remove a specific alpha remap gradient
  74283. * @param gradient defines the gradient to remove
  74284. * @returns the current particle system
  74285. */
  74286. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  74287. /**
  74288. * Adds a new angular speed gradient
  74289. * @param gradient defines the gradient to use (between 0 and 1)
  74290. * @param factor defines the angular speed to affect to the specified gradient
  74291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74292. * @returns the current particle system
  74293. */
  74294. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74295. /**
  74296. * Remove a specific angular speed gradient
  74297. * @param gradient defines the gradient to remove
  74298. * @returns the current particle system
  74299. */
  74300. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74301. /**
  74302. * Adds a new velocity gradient
  74303. * @param gradient defines the gradient to use (between 0 and 1)
  74304. * @param factor defines the velocity to affect to the specified gradient
  74305. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74306. * @returns the current particle system
  74307. */
  74308. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74309. /**
  74310. * Remove a specific velocity gradient
  74311. * @param gradient defines the gradient to remove
  74312. * @returns the current particle system
  74313. */
  74314. removeVelocityGradient(gradient: number): IParticleSystem;
  74315. /**
  74316. * Adds a new limit velocity gradient
  74317. * @param gradient defines the gradient to use (between 0 and 1)
  74318. * @param factor defines the limit velocity value to affect to the specified gradient
  74319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74320. * @returns the current particle system
  74321. */
  74322. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74323. /**
  74324. * Remove a specific limit velocity gradient
  74325. * @param gradient defines the gradient to remove
  74326. * @returns the current particle system
  74327. */
  74328. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74329. /**
  74330. * Adds a new drag gradient
  74331. * @param gradient defines the gradient to use (between 0 and 1)
  74332. * @param factor defines the drag value to affect to the specified gradient
  74333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74334. * @returns the current particle system
  74335. */
  74336. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74337. /**
  74338. * Remove a specific drag gradient
  74339. * @param gradient defines the gradient to remove
  74340. * @returns the current particle system
  74341. */
  74342. removeDragGradient(gradient: number): IParticleSystem;
  74343. /**
  74344. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74345. * @param gradient defines the gradient to use (between 0 and 1)
  74346. * @param factor defines the emit rate value to affect to the specified gradient
  74347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74348. * @returns the current particle system
  74349. */
  74350. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74351. /**
  74352. * Remove a specific emit rate gradient
  74353. * @param gradient defines the gradient to remove
  74354. * @returns the current particle system
  74355. */
  74356. removeEmitRateGradient(gradient: number): IParticleSystem;
  74357. /**
  74358. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74359. * @param gradient defines the gradient to use (between 0 and 1)
  74360. * @param factor defines the start size value to affect to the specified gradient
  74361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74362. * @returns the current particle system
  74363. */
  74364. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74365. /**
  74366. * Remove a specific start size gradient
  74367. * @param gradient defines the gradient to remove
  74368. * @returns the current particle system
  74369. */
  74370. removeStartSizeGradient(gradient: number): IParticleSystem;
  74371. private _createRampGradientTexture;
  74372. /**
  74373. * Gets the current list of ramp gradients.
  74374. * You must use addRampGradient and removeRampGradient to udpate this list
  74375. * @returns the list of ramp gradients
  74376. */
  74377. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74378. /**
  74379. * Adds a new ramp gradient used to remap particle colors
  74380. * @param gradient defines the gradient to use (between 0 and 1)
  74381. * @param color defines the color to affect to the specified gradient
  74382. * @returns the current particle system
  74383. */
  74384. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74385. /**
  74386. * Remove a specific ramp gradient
  74387. * @param gradient defines the gradient to remove
  74388. * @returns the current particle system
  74389. */
  74390. removeRampGradient(gradient: number): ParticleSystem;
  74391. /**
  74392. * Adds a new color gradient
  74393. * @param gradient defines the gradient to use (between 0 and 1)
  74394. * @param color1 defines the color to affect to the specified gradient
  74395. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74396. * @returns this particle system
  74397. */
  74398. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74399. /**
  74400. * Remove a specific color gradient
  74401. * @param gradient defines the gradient to remove
  74402. * @returns this particle system
  74403. */
  74404. removeColorGradient(gradient: number): IParticleSystem;
  74405. private _fetchR;
  74406. protected _reset(): void;
  74407. private _resetEffect;
  74408. private _createVertexBuffers;
  74409. private _createIndexBuffer;
  74410. /**
  74411. * Gets the maximum number of particles active at the same time.
  74412. * @returns The max number of active particles.
  74413. */
  74414. getCapacity(): number;
  74415. /**
  74416. * Gets whether there are still active particles in the system.
  74417. * @returns True if it is alive, otherwise false.
  74418. */
  74419. isAlive(): boolean;
  74420. /**
  74421. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74422. * @returns True if it has been started, otherwise false.
  74423. */
  74424. isStarted(): boolean;
  74425. private _prepareSubEmitterInternalArray;
  74426. /**
  74427. * Starts the particle system and begins to emit
  74428. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74429. */
  74430. start(delay?: number): void;
  74431. /**
  74432. * Stops the particle system.
  74433. * @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.
  74434. */
  74435. stop(stopSubEmitters?: boolean): void;
  74436. /**
  74437. * Remove all active particles
  74438. */
  74439. reset(): void;
  74440. /**
  74441. * @hidden (for internal use only)
  74442. */
  74443. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74444. /**
  74445. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74446. * Its lifetime will start back at 0.
  74447. */
  74448. recycleParticle: (particle: Particle) => void;
  74449. private _stopSubEmitters;
  74450. private _createParticle;
  74451. private _removeFromRoot;
  74452. private _emitFromParticle;
  74453. private _update;
  74454. /** @hidden */
  74455. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74456. /** @hidden */
  74457. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74458. /** @hidden */
  74459. private _getEffect;
  74460. /**
  74461. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74462. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74463. */
  74464. animate(preWarmOnly?: boolean): void;
  74465. private _appendParticleVertices;
  74466. /**
  74467. * Rebuilds the particle system.
  74468. */
  74469. rebuild(): void;
  74470. /**
  74471. * Is this system ready to be used/rendered
  74472. * @return true if the system is ready
  74473. */
  74474. isReady(): boolean;
  74475. private _render;
  74476. /**
  74477. * Renders the particle system in its current state.
  74478. * @returns the current number of particles
  74479. */
  74480. render(): number;
  74481. /**
  74482. * Disposes the particle system and free the associated resources
  74483. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74484. */
  74485. dispose(disposeTexture?: boolean): void;
  74486. /**
  74487. * Clones the particle system.
  74488. * @param name The name of the cloned object
  74489. * @param newEmitter The new emitter to use
  74490. * @returns the cloned particle system
  74491. */
  74492. clone(name: string, newEmitter: any): ParticleSystem;
  74493. /**
  74494. * Serializes the particle system to a JSON object.
  74495. * @returns the JSON object
  74496. */
  74497. serialize(): any;
  74498. /** @hidden */
  74499. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74500. /** @hidden */
  74501. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74502. /**
  74503. * Parses a JSON object to create a particle system.
  74504. * @param parsedParticleSystem The JSON object to parse
  74505. * @param scene The scene to create the particle system in
  74506. * @param rootUrl The root url to use to load external dependencies like texture
  74507. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74508. * @returns the Parsed particle system
  74509. */
  74510. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74511. }
  74512. }
  74513. declare module BABYLON {
  74514. /**
  74515. * A particle represents one of the element emitted by a particle system.
  74516. * This is mainly define by its coordinates, direction, velocity and age.
  74517. */
  74518. export class Particle {
  74519. /**
  74520. * The particle system the particle belongs to.
  74521. */
  74522. particleSystem: ParticleSystem;
  74523. private static _Count;
  74524. /**
  74525. * Unique ID of the particle
  74526. */
  74527. id: number;
  74528. /**
  74529. * The world position of the particle in the scene.
  74530. */
  74531. position: Vector3;
  74532. /**
  74533. * The world direction of the particle in the scene.
  74534. */
  74535. direction: Vector3;
  74536. /**
  74537. * The color of the particle.
  74538. */
  74539. color: Color4;
  74540. /**
  74541. * The color change of the particle per step.
  74542. */
  74543. colorStep: Color4;
  74544. /**
  74545. * Defines how long will the life of the particle be.
  74546. */
  74547. lifeTime: number;
  74548. /**
  74549. * The current age of the particle.
  74550. */
  74551. age: number;
  74552. /**
  74553. * The current size of the particle.
  74554. */
  74555. size: number;
  74556. /**
  74557. * The current scale of the particle.
  74558. */
  74559. scale: Vector2;
  74560. /**
  74561. * The current angle of the particle.
  74562. */
  74563. angle: number;
  74564. /**
  74565. * Defines how fast is the angle changing.
  74566. */
  74567. angularSpeed: number;
  74568. /**
  74569. * Defines the cell index used by the particle to be rendered from a sprite.
  74570. */
  74571. cellIndex: number;
  74572. /**
  74573. * The information required to support color remapping
  74574. */
  74575. remapData: Vector4;
  74576. /** @hidden */
  74577. _randomCellOffset?: number;
  74578. /** @hidden */
  74579. _initialDirection: Nullable<Vector3>;
  74580. /** @hidden */
  74581. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  74582. /** @hidden */
  74583. _initialStartSpriteCellID: number;
  74584. /** @hidden */
  74585. _initialEndSpriteCellID: number;
  74586. /** @hidden */
  74587. _currentColorGradient: Nullable<ColorGradient>;
  74588. /** @hidden */
  74589. _currentColor1: Color4;
  74590. /** @hidden */
  74591. _currentColor2: Color4;
  74592. /** @hidden */
  74593. _currentSizeGradient: Nullable<FactorGradient>;
  74594. /** @hidden */
  74595. _currentSize1: number;
  74596. /** @hidden */
  74597. _currentSize2: number;
  74598. /** @hidden */
  74599. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  74600. /** @hidden */
  74601. _currentAngularSpeed1: number;
  74602. /** @hidden */
  74603. _currentAngularSpeed2: number;
  74604. /** @hidden */
  74605. _currentVelocityGradient: Nullable<FactorGradient>;
  74606. /** @hidden */
  74607. _currentVelocity1: number;
  74608. /** @hidden */
  74609. _currentVelocity2: number;
  74610. /** @hidden */
  74611. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  74612. /** @hidden */
  74613. _currentLimitVelocity1: number;
  74614. /** @hidden */
  74615. _currentLimitVelocity2: number;
  74616. /** @hidden */
  74617. _currentDragGradient: Nullable<FactorGradient>;
  74618. /** @hidden */
  74619. _currentDrag1: number;
  74620. /** @hidden */
  74621. _currentDrag2: number;
  74622. /** @hidden */
  74623. _randomNoiseCoordinates1: Vector3;
  74624. /** @hidden */
  74625. _randomNoiseCoordinates2: Vector3;
  74626. /**
  74627. * Creates a new instance Particle
  74628. * @param particleSystem the particle system the particle belongs to
  74629. */
  74630. constructor(
  74631. /**
  74632. * The particle system the particle belongs to.
  74633. */
  74634. particleSystem: ParticleSystem);
  74635. private updateCellInfoFromSystem;
  74636. /**
  74637. * Defines how the sprite cell index is updated for the particle
  74638. */
  74639. updateCellIndex(): void;
  74640. /** @hidden */
  74641. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  74642. /** @hidden */
  74643. _inheritParticleInfoToSubEmitters(): void;
  74644. /** @hidden */
  74645. _reset(): void;
  74646. /**
  74647. * Copy the properties of particle to another one.
  74648. * @param other the particle to copy the information to.
  74649. */
  74650. copyTo(other: Particle): void;
  74651. }
  74652. }
  74653. declare module BABYLON {
  74654. /**
  74655. * Particle emitter represents a volume emitting particles.
  74656. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  74657. */
  74658. export interface IParticleEmitterType {
  74659. /**
  74660. * Called by the particle System when the direction is computed for the created particle.
  74661. * @param worldMatrix is the world matrix of the particle system
  74662. * @param directionToUpdate is the direction vector to update with the result
  74663. * @param particle is the particle we are computed the direction for
  74664. */
  74665. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74666. /**
  74667. * Called by the particle System when the position is computed for the created particle.
  74668. * @param worldMatrix is the world matrix of the particle system
  74669. * @param positionToUpdate is the position vector to update with the result
  74670. * @param particle is the particle we are computed the position for
  74671. */
  74672. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74673. /**
  74674. * Clones the current emitter and returns a copy of it
  74675. * @returns the new emitter
  74676. */
  74677. clone(): IParticleEmitterType;
  74678. /**
  74679. * Called by the GPUParticleSystem to setup the update shader
  74680. * @param effect defines the update shader
  74681. */
  74682. applyToShader(effect: Effect): void;
  74683. /**
  74684. * Returns a string to use to update the GPU particles update shader
  74685. * @returns the effect defines string
  74686. */
  74687. getEffectDefines(): string;
  74688. /**
  74689. * Returns a string representing the class name
  74690. * @returns a string containing the class name
  74691. */
  74692. getClassName(): string;
  74693. /**
  74694. * Serializes the particle system to a JSON object.
  74695. * @returns the JSON object
  74696. */
  74697. serialize(): any;
  74698. /**
  74699. * Parse properties from a JSON object
  74700. * @param serializationObject defines the JSON object
  74701. */
  74702. parse(serializationObject: any): void;
  74703. }
  74704. }
  74705. declare module BABYLON {
  74706. /**
  74707. * Particle emitter emitting particles from the inside of a box.
  74708. * It emits the particles randomly between 2 given directions.
  74709. */
  74710. export class BoxParticleEmitter implements IParticleEmitterType {
  74711. /**
  74712. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74713. */
  74714. direction1: Vector3;
  74715. /**
  74716. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74717. */
  74718. direction2: Vector3;
  74719. /**
  74720. * 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.
  74721. */
  74722. minEmitBox: Vector3;
  74723. /**
  74724. * 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.
  74725. */
  74726. maxEmitBox: Vector3;
  74727. /**
  74728. * Creates a new instance BoxParticleEmitter
  74729. */
  74730. constructor();
  74731. /**
  74732. * Called by the particle System when the direction is computed for the created particle.
  74733. * @param worldMatrix is the world matrix of the particle system
  74734. * @param directionToUpdate is the direction vector to update with the result
  74735. * @param particle is the particle we are computed the direction for
  74736. */
  74737. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74738. /**
  74739. * Called by the particle System when the position is computed for the created particle.
  74740. * @param worldMatrix is the world matrix of the particle system
  74741. * @param positionToUpdate is the position vector to update with the result
  74742. * @param particle is the particle we are computed the position for
  74743. */
  74744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74745. /**
  74746. * Clones the current emitter and returns a copy of it
  74747. * @returns the new emitter
  74748. */
  74749. clone(): BoxParticleEmitter;
  74750. /**
  74751. * Called by the GPUParticleSystem to setup the update shader
  74752. * @param effect defines the update shader
  74753. */
  74754. applyToShader(effect: Effect): void;
  74755. /**
  74756. * Returns a string to use to update the GPU particles update shader
  74757. * @returns a string containng the defines string
  74758. */
  74759. getEffectDefines(): string;
  74760. /**
  74761. * Returns the string "BoxParticleEmitter"
  74762. * @returns a string containing the class name
  74763. */
  74764. getClassName(): string;
  74765. /**
  74766. * Serializes the particle system to a JSON object.
  74767. * @returns the JSON object
  74768. */
  74769. serialize(): any;
  74770. /**
  74771. * Parse properties from a JSON object
  74772. * @param serializationObject defines the JSON object
  74773. */
  74774. parse(serializationObject: any): void;
  74775. }
  74776. }
  74777. declare module BABYLON {
  74778. /**
  74779. * Particle emitter emitting particles from the inside of a cone.
  74780. * It emits the particles alongside the cone volume from the base to the particle.
  74781. * The emission direction might be randomized.
  74782. */
  74783. export class ConeParticleEmitter implements IParticleEmitterType {
  74784. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74785. directionRandomizer: number;
  74786. private _radius;
  74787. private _angle;
  74788. private _height;
  74789. /**
  74790. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74791. */
  74792. radiusRange: number;
  74793. /**
  74794. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74795. */
  74796. heightRange: number;
  74797. /**
  74798. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74799. */
  74800. emitFromSpawnPointOnly: boolean;
  74801. /**
  74802. * Gets or sets the radius of the emission cone
  74803. */
  74804. radius: number;
  74805. /**
  74806. * Gets or sets the angle of the emission cone
  74807. */
  74808. angle: number;
  74809. private _buildHeight;
  74810. /**
  74811. * Creates a new instance ConeParticleEmitter
  74812. * @param radius the radius of the emission cone (1 by default)
  74813. * @param angle the cone base angle (PI by default)
  74814. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74815. */
  74816. constructor(radius?: number, angle?: number,
  74817. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74818. directionRandomizer?: number);
  74819. /**
  74820. * Called by the particle System when the direction is computed for the created particle.
  74821. * @param worldMatrix is the world matrix of the particle system
  74822. * @param directionToUpdate is the direction vector to update with the result
  74823. * @param particle is the particle we are computed the direction for
  74824. */
  74825. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74826. /**
  74827. * Called by the particle System when the position is computed for the created particle.
  74828. * @param worldMatrix is the world matrix of the particle system
  74829. * @param positionToUpdate is the position vector to update with the result
  74830. * @param particle is the particle we are computed the position for
  74831. */
  74832. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74833. /**
  74834. * Clones the current emitter and returns a copy of it
  74835. * @returns the new emitter
  74836. */
  74837. clone(): ConeParticleEmitter;
  74838. /**
  74839. * Called by the GPUParticleSystem to setup the update shader
  74840. * @param effect defines the update shader
  74841. */
  74842. applyToShader(effect: Effect): void;
  74843. /**
  74844. * Returns a string to use to update the GPU particles update shader
  74845. * @returns a string containng the defines string
  74846. */
  74847. getEffectDefines(): string;
  74848. /**
  74849. * Returns the string "ConeParticleEmitter"
  74850. * @returns a string containing the class name
  74851. */
  74852. getClassName(): string;
  74853. /**
  74854. * Serializes the particle system to a JSON object.
  74855. * @returns the JSON object
  74856. */
  74857. serialize(): any;
  74858. /**
  74859. * Parse properties from a JSON object
  74860. * @param serializationObject defines the JSON object
  74861. */
  74862. parse(serializationObject: any): void;
  74863. }
  74864. }
  74865. declare module BABYLON {
  74866. /**
  74867. * Particle emitter emitting particles from the inside of a cylinder.
  74868. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  74869. */
  74870. export class CylinderParticleEmitter implements IParticleEmitterType {
  74871. /**
  74872. * The radius of the emission cylinder.
  74873. */
  74874. radius: number;
  74875. /**
  74876. * The height of the emission cylinder.
  74877. */
  74878. height: number;
  74879. /**
  74880. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74881. */
  74882. radiusRange: number;
  74883. /**
  74884. * How much to randomize the particle direction [0-1].
  74885. */
  74886. directionRandomizer: number;
  74887. /**
  74888. * Creates a new instance CylinderParticleEmitter
  74889. * @param radius the radius of the emission cylinder (1 by default)
  74890. * @param height the height of the emission cylinder (1 by default)
  74891. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74892. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74893. */
  74894. constructor(
  74895. /**
  74896. * The radius of the emission cylinder.
  74897. */
  74898. radius?: number,
  74899. /**
  74900. * The height of the emission cylinder.
  74901. */
  74902. height?: number,
  74903. /**
  74904. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74905. */
  74906. radiusRange?: number,
  74907. /**
  74908. * How much to randomize the particle direction [0-1].
  74909. */
  74910. directionRandomizer?: number);
  74911. /**
  74912. * Called by the particle System when the direction is computed for the created particle.
  74913. * @param worldMatrix is the world matrix of the particle system
  74914. * @param directionToUpdate is the direction vector to update with the result
  74915. * @param particle is the particle we are computed the direction for
  74916. */
  74917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74918. /**
  74919. * Called by the particle System when the position is computed for the created particle.
  74920. * @param worldMatrix is the world matrix of the particle system
  74921. * @param positionToUpdate is the position vector to update with the result
  74922. * @param particle is the particle we are computed the position for
  74923. */
  74924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74925. /**
  74926. * Clones the current emitter and returns a copy of it
  74927. * @returns the new emitter
  74928. */
  74929. clone(): CylinderParticleEmitter;
  74930. /**
  74931. * Called by the GPUParticleSystem to setup the update shader
  74932. * @param effect defines the update shader
  74933. */
  74934. applyToShader(effect: Effect): void;
  74935. /**
  74936. * Returns a string to use to update the GPU particles update shader
  74937. * @returns a string containng the defines string
  74938. */
  74939. getEffectDefines(): string;
  74940. /**
  74941. * Returns the string "CylinderParticleEmitter"
  74942. * @returns a string containing the class name
  74943. */
  74944. getClassName(): string;
  74945. /**
  74946. * Serializes the particle system to a JSON object.
  74947. * @returns the JSON object
  74948. */
  74949. serialize(): any;
  74950. /**
  74951. * Parse properties from a JSON object
  74952. * @param serializationObject defines the JSON object
  74953. */
  74954. parse(serializationObject: any): void;
  74955. }
  74956. /**
  74957. * Particle emitter emitting particles from the inside of a cylinder.
  74958. * It emits the particles randomly between two vectors.
  74959. */
  74960. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  74961. /**
  74962. * The min limit of the emission direction.
  74963. */
  74964. direction1: Vector3;
  74965. /**
  74966. * The max limit of the emission direction.
  74967. */
  74968. direction2: Vector3;
  74969. /**
  74970. * Creates a new instance CylinderDirectedParticleEmitter
  74971. * @param radius the radius of the emission cylinder (1 by default)
  74972. * @param height the height of the emission cylinder (1 by default)
  74973. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74974. * @param direction1 the min limit of the emission direction (up vector by default)
  74975. * @param direction2 the max limit of the emission direction (up vector by default)
  74976. */
  74977. constructor(radius?: number, height?: number, radiusRange?: number,
  74978. /**
  74979. * The min limit of the emission direction.
  74980. */
  74981. direction1?: Vector3,
  74982. /**
  74983. * The max limit of the emission direction.
  74984. */
  74985. direction2?: Vector3);
  74986. /**
  74987. * Called by the particle System when the direction is computed for the created particle.
  74988. * @param worldMatrix is the world matrix of the particle system
  74989. * @param directionToUpdate is the direction vector to update with the result
  74990. * @param particle is the particle we are computed the direction for
  74991. */
  74992. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74993. /**
  74994. * Clones the current emitter and returns a copy of it
  74995. * @returns the new emitter
  74996. */
  74997. clone(): CylinderDirectedParticleEmitter;
  74998. /**
  74999. * Called by the GPUParticleSystem to setup the update shader
  75000. * @param effect defines the update shader
  75001. */
  75002. applyToShader(effect: Effect): void;
  75003. /**
  75004. * Returns a string to use to update the GPU particles update shader
  75005. * @returns a string containng the defines string
  75006. */
  75007. getEffectDefines(): string;
  75008. /**
  75009. * Returns the string "CylinderDirectedParticleEmitter"
  75010. * @returns a string containing the class name
  75011. */
  75012. getClassName(): string;
  75013. /**
  75014. * Serializes the particle system to a JSON object.
  75015. * @returns the JSON object
  75016. */
  75017. serialize(): any;
  75018. /**
  75019. * Parse properties from a JSON object
  75020. * @param serializationObject defines the JSON object
  75021. */
  75022. parse(serializationObject: any): void;
  75023. }
  75024. }
  75025. declare module BABYLON {
  75026. /**
  75027. * Particle emitter emitting particles from the inside of a hemisphere.
  75028. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75029. */
  75030. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75031. /**
  75032. * The radius of the emission hemisphere.
  75033. */
  75034. radius: number;
  75035. /**
  75036. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75037. */
  75038. radiusRange: number;
  75039. /**
  75040. * How much to randomize the particle direction [0-1].
  75041. */
  75042. directionRandomizer: number;
  75043. /**
  75044. * Creates a new instance HemisphericParticleEmitter
  75045. * @param radius the radius of the emission hemisphere (1 by default)
  75046. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75047. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75048. */
  75049. constructor(
  75050. /**
  75051. * The radius of the emission hemisphere.
  75052. */
  75053. radius?: number,
  75054. /**
  75055. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75056. */
  75057. radiusRange?: number,
  75058. /**
  75059. * How much to randomize the particle direction [0-1].
  75060. */
  75061. directionRandomizer?: number);
  75062. /**
  75063. * Called by the particle System when the direction is computed for the created particle.
  75064. * @param worldMatrix is the world matrix of the particle system
  75065. * @param directionToUpdate is the direction vector to update with the result
  75066. * @param particle is the particle we are computed the direction for
  75067. */
  75068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75069. /**
  75070. * Called by the particle System when the position is computed for the created particle.
  75071. * @param worldMatrix is the world matrix of the particle system
  75072. * @param positionToUpdate is the position vector to update with the result
  75073. * @param particle is the particle we are computed the position for
  75074. */
  75075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75076. /**
  75077. * Clones the current emitter and returns a copy of it
  75078. * @returns the new emitter
  75079. */
  75080. clone(): HemisphericParticleEmitter;
  75081. /**
  75082. * Called by the GPUParticleSystem to setup the update shader
  75083. * @param effect defines the update shader
  75084. */
  75085. applyToShader(effect: Effect): void;
  75086. /**
  75087. * Returns a string to use to update the GPU particles update shader
  75088. * @returns a string containng the defines string
  75089. */
  75090. getEffectDefines(): string;
  75091. /**
  75092. * Returns the string "HemisphericParticleEmitter"
  75093. * @returns a string containing the class name
  75094. */
  75095. getClassName(): string;
  75096. /**
  75097. * Serializes the particle system to a JSON object.
  75098. * @returns the JSON object
  75099. */
  75100. serialize(): any;
  75101. /**
  75102. * Parse properties from a JSON object
  75103. * @param serializationObject defines the JSON object
  75104. */
  75105. parse(serializationObject: any): void;
  75106. }
  75107. }
  75108. declare module BABYLON {
  75109. /**
  75110. * Particle emitter emitting particles from a point.
  75111. * It emits the particles randomly between 2 given directions.
  75112. */
  75113. export class PointParticleEmitter implements IParticleEmitterType {
  75114. /**
  75115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75116. */
  75117. direction1: Vector3;
  75118. /**
  75119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75120. */
  75121. direction2: Vector3;
  75122. /**
  75123. * Creates a new instance PointParticleEmitter
  75124. */
  75125. constructor();
  75126. /**
  75127. * Called by the particle System when the direction is computed for the created particle.
  75128. * @param worldMatrix is the world matrix of the particle system
  75129. * @param directionToUpdate is the direction vector to update with the result
  75130. * @param particle is the particle we are computed the direction for
  75131. */
  75132. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75133. /**
  75134. * Called by the particle System when the position is computed for the created particle.
  75135. * @param worldMatrix is the world matrix of the particle system
  75136. * @param positionToUpdate is the position vector to update with the result
  75137. * @param particle is the particle we are computed the position for
  75138. */
  75139. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75140. /**
  75141. * Clones the current emitter and returns a copy of it
  75142. * @returns the new emitter
  75143. */
  75144. clone(): PointParticleEmitter;
  75145. /**
  75146. * Called by the GPUParticleSystem to setup the update shader
  75147. * @param effect defines the update shader
  75148. */
  75149. applyToShader(effect: Effect): void;
  75150. /**
  75151. * Returns a string to use to update the GPU particles update shader
  75152. * @returns a string containng the defines string
  75153. */
  75154. getEffectDefines(): string;
  75155. /**
  75156. * Returns the string "PointParticleEmitter"
  75157. * @returns a string containing the class name
  75158. */
  75159. getClassName(): string;
  75160. /**
  75161. * Serializes the particle system to a JSON object.
  75162. * @returns the JSON object
  75163. */
  75164. serialize(): any;
  75165. /**
  75166. * Parse properties from a JSON object
  75167. * @param serializationObject defines the JSON object
  75168. */
  75169. parse(serializationObject: any): void;
  75170. }
  75171. }
  75172. declare module BABYLON {
  75173. /**
  75174. * Particle emitter emitting particles from the inside of a sphere.
  75175. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75176. */
  75177. export class SphereParticleEmitter implements IParticleEmitterType {
  75178. /**
  75179. * The radius of the emission sphere.
  75180. */
  75181. radius: number;
  75182. /**
  75183. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75184. */
  75185. radiusRange: number;
  75186. /**
  75187. * How much to randomize the particle direction [0-1].
  75188. */
  75189. directionRandomizer: number;
  75190. /**
  75191. * Creates a new instance SphereParticleEmitter
  75192. * @param radius the radius of the emission sphere (1 by default)
  75193. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75194. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75195. */
  75196. constructor(
  75197. /**
  75198. * The radius of the emission sphere.
  75199. */
  75200. radius?: number,
  75201. /**
  75202. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75203. */
  75204. radiusRange?: number,
  75205. /**
  75206. * How much to randomize the particle direction [0-1].
  75207. */
  75208. directionRandomizer?: number);
  75209. /**
  75210. * Called by the particle System when the direction is computed for the created particle.
  75211. * @param worldMatrix is the world matrix of the particle system
  75212. * @param directionToUpdate is the direction vector to update with the result
  75213. * @param particle is the particle we are computed the direction for
  75214. */
  75215. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75216. /**
  75217. * Called by the particle System when the position is computed for the created particle.
  75218. * @param worldMatrix is the world matrix of the particle system
  75219. * @param positionToUpdate is the position vector to update with the result
  75220. * @param particle is the particle we are computed the position for
  75221. */
  75222. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75223. /**
  75224. * Clones the current emitter and returns a copy of it
  75225. * @returns the new emitter
  75226. */
  75227. clone(): SphereParticleEmitter;
  75228. /**
  75229. * Called by the GPUParticleSystem to setup the update shader
  75230. * @param effect defines the update shader
  75231. */
  75232. applyToShader(effect: Effect): void;
  75233. /**
  75234. * Returns a string to use to update the GPU particles update shader
  75235. * @returns a string containng the defines string
  75236. */
  75237. getEffectDefines(): string;
  75238. /**
  75239. * Returns the string "SphereParticleEmitter"
  75240. * @returns a string containing the class name
  75241. */
  75242. getClassName(): string;
  75243. /**
  75244. * Serializes the particle system to a JSON object.
  75245. * @returns the JSON object
  75246. */
  75247. serialize(): any;
  75248. /**
  75249. * Parse properties from a JSON object
  75250. * @param serializationObject defines the JSON object
  75251. */
  75252. parse(serializationObject: any): void;
  75253. }
  75254. /**
  75255. * Particle emitter emitting particles from the inside of a sphere.
  75256. * It emits the particles randomly between two vectors.
  75257. */
  75258. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  75259. /**
  75260. * The min limit of the emission direction.
  75261. */
  75262. direction1: Vector3;
  75263. /**
  75264. * The max limit of the emission direction.
  75265. */
  75266. direction2: Vector3;
  75267. /**
  75268. * Creates a new instance SphereDirectedParticleEmitter
  75269. * @param radius the radius of the emission sphere (1 by default)
  75270. * @param direction1 the min limit of the emission direction (up vector by default)
  75271. * @param direction2 the max limit of the emission direction (up vector by default)
  75272. */
  75273. constructor(radius?: number,
  75274. /**
  75275. * The min limit of the emission direction.
  75276. */
  75277. direction1?: Vector3,
  75278. /**
  75279. * The max limit of the emission direction.
  75280. */
  75281. direction2?: Vector3);
  75282. /**
  75283. * Called by the particle System when the direction is computed for the created particle.
  75284. * @param worldMatrix is the world matrix of the particle system
  75285. * @param directionToUpdate is the direction vector to update with the result
  75286. * @param particle is the particle we are computed the direction for
  75287. */
  75288. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75289. /**
  75290. * Clones the current emitter and returns a copy of it
  75291. * @returns the new emitter
  75292. */
  75293. clone(): SphereDirectedParticleEmitter;
  75294. /**
  75295. * Called by the GPUParticleSystem to setup the update shader
  75296. * @param effect defines the update shader
  75297. */
  75298. applyToShader(effect: Effect): void;
  75299. /**
  75300. * Returns a string to use to update the GPU particles update shader
  75301. * @returns a string containng the defines string
  75302. */
  75303. getEffectDefines(): string;
  75304. /**
  75305. * Returns the string "SphereDirectedParticleEmitter"
  75306. * @returns a string containing the class name
  75307. */
  75308. getClassName(): string;
  75309. /**
  75310. * Serializes the particle system to a JSON object.
  75311. * @returns the JSON object
  75312. */
  75313. serialize(): any;
  75314. /**
  75315. * Parse properties from a JSON object
  75316. * @param serializationObject defines the JSON object
  75317. */
  75318. parse(serializationObject: any): void;
  75319. }
  75320. }
  75321. declare module BABYLON {
  75322. /**
  75323. * Interface representing a particle system in Babylon.js.
  75324. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75325. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75326. */
  75327. export interface IParticleSystem {
  75328. /**
  75329. * List of animations used by the particle system.
  75330. */
  75331. animations: Animation[];
  75332. /**
  75333. * The id of the Particle system.
  75334. */
  75335. id: string;
  75336. /**
  75337. * The name of the Particle system.
  75338. */
  75339. name: string;
  75340. /**
  75341. * The emitter represents the Mesh or position we are attaching the particle system to.
  75342. */
  75343. emitter: Nullable<AbstractMesh | Vector3>;
  75344. /**
  75345. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75346. */
  75347. isBillboardBased: boolean;
  75348. /**
  75349. * The rendering group used by the Particle system to chose when to render.
  75350. */
  75351. renderingGroupId: number;
  75352. /**
  75353. * The layer mask we are rendering the particles through.
  75354. */
  75355. layerMask: number;
  75356. /**
  75357. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75358. */
  75359. updateSpeed: number;
  75360. /**
  75361. * The amount of time the particle system is running (depends of the overall update speed).
  75362. */
  75363. targetStopDuration: number;
  75364. /**
  75365. * The texture used to render each particle. (this can be a spritesheet)
  75366. */
  75367. particleTexture: Nullable<Texture>;
  75368. /**
  75369. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75370. */
  75371. blendMode: number;
  75372. /**
  75373. * Minimum life time of emitting particles.
  75374. */
  75375. minLifeTime: number;
  75376. /**
  75377. * Maximum life time of emitting particles.
  75378. */
  75379. maxLifeTime: number;
  75380. /**
  75381. * Minimum Size of emitting particles.
  75382. */
  75383. minSize: number;
  75384. /**
  75385. * Maximum Size of emitting particles.
  75386. */
  75387. maxSize: number;
  75388. /**
  75389. * Minimum scale of emitting particles on X axis.
  75390. */
  75391. minScaleX: number;
  75392. /**
  75393. * Maximum scale of emitting particles on X axis.
  75394. */
  75395. maxScaleX: number;
  75396. /**
  75397. * Minimum scale of emitting particles on Y axis.
  75398. */
  75399. minScaleY: number;
  75400. /**
  75401. * Maximum scale of emitting particles on Y axis.
  75402. */
  75403. maxScaleY: number;
  75404. /**
  75405. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75406. */
  75407. color1: Color4;
  75408. /**
  75409. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75410. */
  75411. color2: Color4;
  75412. /**
  75413. * Color the particle will have at the end of its lifetime.
  75414. */
  75415. colorDead: Color4;
  75416. /**
  75417. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75418. */
  75419. emitRate: number;
  75420. /**
  75421. * You can use gravity if you want to give an orientation to your particles.
  75422. */
  75423. gravity: Vector3;
  75424. /**
  75425. * Minimum power of emitting particles.
  75426. */
  75427. minEmitPower: number;
  75428. /**
  75429. * Maximum power of emitting particles.
  75430. */
  75431. maxEmitPower: number;
  75432. /**
  75433. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75434. */
  75435. minAngularSpeed: number;
  75436. /**
  75437. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75438. */
  75439. maxAngularSpeed: number;
  75440. /**
  75441. * Gets or sets the minimal initial rotation in radians.
  75442. */
  75443. minInitialRotation: number;
  75444. /**
  75445. * Gets or sets the maximal initial rotation in radians.
  75446. */
  75447. maxInitialRotation: number;
  75448. /**
  75449. * The particle emitter type defines the emitter used by the particle system.
  75450. * It can be for example box, sphere, or cone...
  75451. */
  75452. particleEmitterType: Nullable<IParticleEmitterType>;
  75453. /**
  75454. * Defines the delay in milliseconds before starting the system (0 by default)
  75455. */
  75456. startDelay: number;
  75457. /**
  75458. * 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
  75459. */
  75460. preWarmCycles: number;
  75461. /**
  75462. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75463. */
  75464. preWarmStepOffset: number;
  75465. /**
  75466. * 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)
  75467. */
  75468. spriteCellChangeSpeed: number;
  75469. /**
  75470. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75471. */
  75472. startSpriteCellID: number;
  75473. /**
  75474. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75475. */
  75476. endSpriteCellID: number;
  75477. /**
  75478. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75479. */
  75480. spriteCellWidth: number;
  75481. /**
  75482. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75483. */
  75484. spriteCellHeight: number;
  75485. /**
  75486. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75487. */
  75488. spriteRandomStartCell: boolean;
  75489. /**
  75490. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75491. */
  75492. isAnimationSheetEnabled: boolean;
  75493. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75494. translationPivot: Vector2;
  75495. /**
  75496. * Gets or sets a texture used to add random noise to particle positions
  75497. */
  75498. noiseTexture: Nullable<BaseTexture>;
  75499. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75500. noiseStrength: Vector3;
  75501. /**
  75502. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75503. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75504. */
  75505. billboardMode: number;
  75506. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75507. limitVelocityDamping: number;
  75508. /**
  75509. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75510. */
  75511. beginAnimationOnStart: boolean;
  75512. /**
  75513. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75514. */
  75515. beginAnimationFrom: number;
  75516. /**
  75517. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75518. */
  75519. beginAnimationTo: number;
  75520. /**
  75521. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75522. */
  75523. beginAnimationLoop: boolean;
  75524. /**
  75525. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75526. */
  75527. disposeOnStop: boolean;
  75528. /**
  75529. * Gets the maximum number of particles active at the same time.
  75530. * @returns The max number of active particles.
  75531. */
  75532. getCapacity(): number;
  75533. /**
  75534. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75535. * @returns True if it has been started, otherwise false.
  75536. */
  75537. isStarted(): boolean;
  75538. /**
  75539. * Animates the particle system for this frame.
  75540. */
  75541. animate(): void;
  75542. /**
  75543. * Renders the particle system in its current state.
  75544. * @returns the current number of particles
  75545. */
  75546. render(): number;
  75547. /**
  75548. * Dispose the particle system and frees its associated resources.
  75549. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75550. */
  75551. dispose(disposeTexture?: boolean): void;
  75552. /**
  75553. * Clones the particle system.
  75554. * @param name The name of the cloned object
  75555. * @param newEmitter The new emitter to use
  75556. * @returns the cloned particle system
  75557. */
  75558. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  75559. /**
  75560. * Serializes the particle system to a JSON object.
  75561. * @returns the JSON object
  75562. */
  75563. serialize(): any;
  75564. /**
  75565. * Rebuild the particle system
  75566. */
  75567. rebuild(): void;
  75568. /**
  75569. * Starts the particle system and begins to emit
  75570. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  75571. */
  75572. start(delay?: number): void;
  75573. /**
  75574. * Stops the particle system.
  75575. */
  75576. stop(): void;
  75577. /**
  75578. * Remove all active particles
  75579. */
  75580. reset(): void;
  75581. /**
  75582. * Is this system ready to be used/rendered
  75583. * @return true if the system is ready
  75584. */
  75585. isReady(): boolean;
  75586. /**
  75587. * Adds a new color gradient
  75588. * @param gradient defines the gradient to use (between 0 and 1)
  75589. * @param color1 defines the color to affect to the specified gradient
  75590. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75591. * @returns the current particle system
  75592. */
  75593. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75594. /**
  75595. * Remove a specific color gradient
  75596. * @param gradient defines the gradient to remove
  75597. * @returns the current particle system
  75598. */
  75599. removeColorGradient(gradient: number): IParticleSystem;
  75600. /**
  75601. * Adds a new size gradient
  75602. * @param gradient defines the gradient to use (between 0 and 1)
  75603. * @param factor defines the size factor to affect to the specified gradient
  75604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75605. * @returns the current particle system
  75606. */
  75607. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75608. /**
  75609. * Remove a specific size gradient
  75610. * @param gradient defines the gradient to remove
  75611. * @returns the current particle system
  75612. */
  75613. removeSizeGradient(gradient: number): IParticleSystem;
  75614. /**
  75615. * Gets the current list of color gradients.
  75616. * You must use addColorGradient and removeColorGradient to udpate this list
  75617. * @returns the list of color gradients
  75618. */
  75619. getColorGradients(): Nullable<Array<ColorGradient>>;
  75620. /**
  75621. * Gets the current list of size gradients.
  75622. * You must use addSizeGradient and removeSizeGradient to udpate this list
  75623. * @returns the list of size gradients
  75624. */
  75625. getSizeGradients(): Nullable<Array<FactorGradient>>;
  75626. /**
  75627. * Gets the current list of angular speed gradients.
  75628. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  75629. * @returns the list of angular speed gradients
  75630. */
  75631. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  75632. /**
  75633. * Adds a new angular speed gradient
  75634. * @param gradient defines the gradient to use (between 0 and 1)
  75635. * @param factor defines the angular speed to affect to the specified gradient
  75636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75637. * @returns the current particle system
  75638. */
  75639. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75640. /**
  75641. * Remove a specific angular speed gradient
  75642. * @param gradient defines the gradient to remove
  75643. * @returns the current particle system
  75644. */
  75645. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75646. /**
  75647. * Gets the current list of velocity gradients.
  75648. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  75649. * @returns the list of velocity gradients
  75650. */
  75651. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  75652. /**
  75653. * Adds a new velocity gradient
  75654. * @param gradient defines the gradient to use (between 0 and 1)
  75655. * @param factor defines the velocity to affect to the specified gradient
  75656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75657. * @returns the current particle system
  75658. */
  75659. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75660. /**
  75661. * Remove a specific velocity gradient
  75662. * @param gradient defines the gradient to remove
  75663. * @returns the current particle system
  75664. */
  75665. removeVelocityGradient(gradient: number): IParticleSystem;
  75666. /**
  75667. * Gets the current list of limit velocity gradients.
  75668. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  75669. * @returns the list of limit velocity gradients
  75670. */
  75671. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  75672. /**
  75673. * Adds a new limit velocity gradient
  75674. * @param gradient defines the gradient to use (between 0 and 1)
  75675. * @param factor defines the limit velocity to affect to the specified gradient
  75676. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75677. * @returns the current particle system
  75678. */
  75679. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75680. /**
  75681. * Remove a specific limit velocity gradient
  75682. * @param gradient defines the gradient to remove
  75683. * @returns the current particle system
  75684. */
  75685. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75686. /**
  75687. * Adds a new drag gradient
  75688. * @param gradient defines the gradient to use (between 0 and 1)
  75689. * @param factor defines the drag to affect to the specified gradient
  75690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75691. * @returns the current particle system
  75692. */
  75693. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75694. /**
  75695. * Remove a specific drag gradient
  75696. * @param gradient defines the gradient to remove
  75697. * @returns the current particle system
  75698. */
  75699. removeDragGradient(gradient: number): IParticleSystem;
  75700. /**
  75701. * Gets the current list of drag gradients.
  75702. * You must use addDragGradient and removeDragGradient to udpate this list
  75703. * @returns the list of drag gradients
  75704. */
  75705. getDragGradients(): Nullable<Array<FactorGradient>>;
  75706. /**
  75707. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75708. * @param gradient defines the gradient to use (between 0 and 1)
  75709. * @param factor defines the emit rate to affect to the specified gradient
  75710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75711. * @returns the current particle system
  75712. */
  75713. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75714. /**
  75715. * Remove a specific emit rate gradient
  75716. * @param gradient defines the gradient to remove
  75717. * @returns the current particle system
  75718. */
  75719. removeEmitRateGradient(gradient: number): IParticleSystem;
  75720. /**
  75721. * Gets the current list of emit rate gradients.
  75722. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  75723. * @returns the list of emit rate gradients
  75724. */
  75725. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  75726. /**
  75727. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75728. * @param gradient defines the gradient to use (between 0 and 1)
  75729. * @param factor defines the start size to affect to the specified gradient
  75730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75731. * @returns the current particle system
  75732. */
  75733. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75734. /**
  75735. * Remove a specific start size gradient
  75736. * @param gradient defines the gradient to remove
  75737. * @returns the current particle system
  75738. */
  75739. removeStartSizeGradient(gradient: number): IParticleSystem;
  75740. /**
  75741. * Gets the current list of start size gradients.
  75742. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  75743. * @returns the list of start size gradients
  75744. */
  75745. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  75746. /**
  75747. * Adds a new life time gradient
  75748. * @param gradient defines the gradient to use (between 0 and 1)
  75749. * @param factor defines the life time factor to affect to the specified gradient
  75750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75751. * @returns the current particle system
  75752. */
  75753. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75754. /**
  75755. * Remove a specific life time gradient
  75756. * @param gradient defines the gradient to remove
  75757. * @returns the current particle system
  75758. */
  75759. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75760. /**
  75761. * Gets the current list of life time gradients.
  75762. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  75763. * @returns the list of life time gradients
  75764. */
  75765. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  75766. /**
  75767. * Gets the current list of color gradients.
  75768. * You must use addColorGradient and removeColorGradient to udpate this list
  75769. * @returns the list of color gradients
  75770. */
  75771. getColorGradients(): Nullable<Array<ColorGradient>>;
  75772. /**
  75773. * Adds a new ramp gradient used to remap particle colors
  75774. * @param gradient defines the gradient to use (between 0 and 1)
  75775. * @param color defines the color to affect to the specified gradient
  75776. * @returns the current particle system
  75777. */
  75778. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75779. /**
  75780. * Gets the current list of ramp gradients.
  75781. * You must use addRampGradient and removeRampGradient to udpate this list
  75782. * @returns the list of ramp gradients
  75783. */
  75784. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75785. /** Gets or sets a boolean indicating that ramp gradients must be used
  75786. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75787. */
  75788. useRampGradients: boolean;
  75789. /**
  75790. * Adds a new color remap gradient
  75791. * @param gradient defines the gradient to use (between 0 and 1)
  75792. * @param min defines the color remap minimal range
  75793. * @param max defines the color remap maximal range
  75794. * @returns the current particle system
  75795. */
  75796. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75797. /**
  75798. * Gets the current list of color remap gradients.
  75799. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75800. * @returns the list of color remap gradients
  75801. */
  75802. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75803. /**
  75804. * Adds a new alpha remap gradient
  75805. * @param gradient defines the gradient to use (between 0 and 1)
  75806. * @param min defines the alpha remap minimal range
  75807. * @param max defines the alpha remap maximal range
  75808. * @returns the current particle system
  75809. */
  75810. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75811. /**
  75812. * Gets the current list of alpha remap gradients.
  75813. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75814. * @returns the list of alpha remap gradients
  75815. */
  75816. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75817. /**
  75818. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75819. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75820. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75821. * @returns the emitter
  75822. */
  75823. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75824. /**
  75825. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75826. * @param radius The radius of the hemisphere to emit from
  75827. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75828. * @returns the emitter
  75829. */
  75830. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75831. /**
  75832. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75833. * @param radius The radius of the sphere to emit from
  75834. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75835. * @returns the emitter
  75836. */
  75837. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75838. /**
  75839. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75840. * @param radius The radius of the sphere to emit from
  75841. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75842. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75843. * @returns the emitter
  75844. */
  75845. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75846. /**
  75847. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75848. * @param radius The radius of the emission cylinder
  75849. * @param height The height of the emission cylinder
  75850. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75851. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75852. * @returns the emitter
  75853. */
  75854. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75855. /**
  75856. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  75857. * @param radius The radius of the cylinder to emit from
  75858. * @param height The height of the emission cylinder
  75859. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75860. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  75861. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  75862. * @returns the emitter
  75863. */
  75864. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75865. /**
  75866. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  75867. * @param radius The radius of the cone to emit from
  75868. * @param angle The base angle of the cone
  75869. * @returns the emitter
  75870. */
  75871. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  75872. /**
  75873. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  75874. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75875. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75876. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75877. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75878. * @returns the emitter
  75879. */
  75880. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  75881. /**
  75882. * Get hosting scene
  75883. * @returns the scene
  75884. */
  75885. getScene(): Scene;
  75886. }
  75887. }
  75888. declare module BABYLON {
  75889. /**
  75890. * Creates an instance based on a source mesh.
  75891. */
  75892. export class InstancedMesh extends AbstractMesh {
  75893. private _sourceMesh;
  75894. private _currentLOD;
  75895. /** @hidden */
  75896. _indexInSourceMeshInstanceArray: number;
  75897. constructor(name: string, source: Mesh);
  75898. /**
  75899. * Returns the string "InstancedMesh".
  75900. */
  75901. getClassName(): string;
  75902. /**
  75903. * If the source mesh receives shadows
  75904. */
  75905. readonly receiveShadows: boolean;
  75906. /**
  75907. * The material of the source mesh
  75908. */
  75909. readonly material: Nullable<Material>;
  75910. /**
  75911. * Visibility of the source mesh
  75912. */
  75913. readonly visibility: number;
  75914. /**
  75915. * Skeleton of the source mesh
  75916. */
  75917. readonly skeleton: Nullable<Skeleton>;
  75918. /**
  75919. * Rendering ground id of the source mesh
  75920. */
  75921. renderingGroupId: number;
  75922. /**
  75923. * Returns the total number of vertices (integer).
  75924. */
  75925. getTotalVertices(): number;
  75926. /**
  75927. * Returns a positive integer : the total number of indices in this mesh geometry.
  75928. * @returns the numner of indices or zero if the mesh has no geometry.
  75929. */
  75930. getTotalIndices(): number;
  75931. /**
  75932. * The source mesh of the instance
  75933. */
  75934. readonly sourceMesh: Mesh;
  75935. /**
  75936. * Is this node ready to be used/rendered
  75937. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75938. * @return {boolean} is it ready
  75939. */
  75940. isReady(completeCheck?: boolean): boolean;
  75941. /**
  75942. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75943. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75944. * @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.
  75945. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75946. */
  75947. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75948. /**
  75949. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75950. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75951. * The `data` are either a numeric array either a Float32Array.
  75952. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75953. * 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).
  75954. * Note that a new underlying VertexBuffer object is created each call.
  75955. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75956. *
  75957. * Possible `kind` values :
  75958. * - VertexBuffer.PositionKind
  75959. * - VertexBuffer.UVKind
  75960. * - VertexBuffer.UV2Kind
  75961. * - VertexBuffer.UV3Kind
  75962. * - VertexBuffer.UV4Kind
  75963. * - VertexBuffer.UV5Kind
  75964. * - VertexBuffer.UV6Kind
  75965. * - VertexBuffer.ColorKind
  75966. * - VertexBuffer.MatricesIndicesKind
  75967. * - VertexBuffer.MatricesIndicesExtraKind
  75968. * - VertexBuffer.MatricesWeightsKind
  75969. * - VertexBuffer.MatricesWeightsExtraKind
  75970. *
  75971. * Returns the Mesh.
  75972. */
  75973. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75974. /**
  75975. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75976. * If the mesh has no geometry, it is simply returned as it is.
  75977. * The `data` are either a numeric array either a Float32Array.
  75978. * No new underlying VertexBuffer object is created.
  75979. * 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.
  75980. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75981. *
  75982. * Possible `kind` values :
  75983. * - VertexBuffer.PositionKind
  75984. * - VertexBuffer.UVKind
  75985. * - VertexBuffer.UV2Kind
  75986. * - VertexBuffer.UV3Kind
  75987. * - VertexBuffer.UV4Kind
  75988. * - VertexBuffer.UV5Kind
  75989. * - VertexBuffer.UV6Kind
  75990. * - VertexBuffer.ColorKind
  75991. * - VertexBuffer.MatricesIndicesKind
  75992. * - VertexBuffer.MatricesIndicesExtraKind
  75993. * - VertexBuffer.MatricesWeightsKind
  75994. * - VertexBuffer.MatricesWeightsExtraKind
  75995. *
  75996. * Returns the Mesh.
  75997. */
  75998. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75999. /**
  76000. * Sets the mesh indices.
  76001. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76002. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76003. * This method creates a new index buffer each call.
  76004. * Returns the Mesh.
  76005. */
  76006. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76007. /**
  76008. * Boolean : True if the mesh owns the requested kind of data.
  76009. */
  76010. isVerticesDataPresent(kind: string): boolean;
  76011. /**
  76012. * Returns an array of indices (IndicesArray).
  76013. */
  76014. getIndices(): Nullable<IndicesArray>;
  76015. readonly _positions: Nullable<Vector3[]>;
  76016. /**
  76017. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76018. * This means the mesh underlying bounding box and sphere are recomputed.
  76019. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76020. * @returns the current mesh
  76021. */
  76022. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76023. /** @hidden */
  76024. _preActivate(): InstancedMesh;
  76025. /** @hidden */
  76026. _activate(renderId: number): boolean;
  76027. /**
  76028. * Returns the current associated LOD AbstractMesh.
  76029. */
  76030. getLOD(camera: Camera): AbstractMesh;
  76031. /** @hidden */
  76032. _syncSubMeshes(): InstancedMesh;
  76033. /** @hidden */
  76034. _generatePointsArray(): boolean;
  76035. /**
  76036. * Creates a new InstancedMesh from the current mesh.
  76037. * - name (string) : the cloned mesh name
  76038. * - newParent (optional Node) : the optional Node to parent the clone to.
  76039. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76040. *
  76041. * Returns the clone.
  76042. */
  76043. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76044. /**
  76045. * Disposes the InstancedMesh.
  76046. * Returns nothing.
  76047. */
  76048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76049. }
  76050. }
  76051. declare module BABYLON {
  76052. /**
  76053. * Defines the options associated with the creation of a shader material.
  76054. */
  76055. export interface IShaderMaterialOptions {
  76056. /**
  76057. * Does the material work in alpha blend mode
  76058. */
  76059. needAlphaBlending: boolean;
  76060. /**
  76061. * Does the material work in alpha test mode
  76062. */
  76063. needAlphaTesting: boolean;
  76064. /**
  76065. * The list of attribute names used in the shader
  76066. */
  76067. attributes: string[];
  76068. /**
  76069. * The list of unifrom names used in the shader
  76070. */
  76071. uniforms: string[];
  76072. /**
  76073. * The list of UBO names used in the shader
  76074. */
  76075. uniformBuffers: string[];
  76076. /**
  76077. * The list of sampler names used in the shader
  76078. */
  76079. samplers: string[];
  76080. /**
  76081. * The list of defines used in the shader
  76082. */
  76083. defines: string[];
  76084. }
  76085. /**
  76086. * 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.
  76087. *
  76088. * This returned material effects how the mesh will look based on the code in the shaders.
  76089. *
  76090. * @see http://doc.babylonjs.com/how_to/shader_material
  76091. */
  76092. export class ShaderMaterial extends Material {
  76093. private _shaderPath;
  76094. private _options;
  76095. private _textures;
  76096. private _textureArrays;
  76097. private _floats;
  76098. private _ints;
  76099. private _floatsArrays;
  76100. private _colors3;
  76101. private _colors3Arrays;
  76102. private _colors4;
  76103. private _vectors2;
  76104. private _vectors3;
  76105. private _vectors4;
  76106. private _matrices;
  76107. private _matrices3x3;
  76108. private _matrices2x2;
  76109. private _vectors2Arrays;
  76110. private _vectors3Arrays;
  76111. private _cachedWorldViewMatrix;
  76112. private _renderId;
  76113. /**
  76114. * Instantiate a new shader material.
  76115. * 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.
  76116. * This returned material effects how the mesh will look based on the code in the shaders.
  76117. * @see http://doc.babylonjs.com/how_to/shader_material
  76118. * @param name Define the name of the material in the scene
  76119. * @param scene Define the scene the material belongs to
  76120. * @param shaderPath Defines the route to the shader code in one of three ways:
  76121. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76122. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76123. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76124. * @param options Define the options used to create the shader
  76125. */
  76126. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76127. /**
  76128. * Gets the options used to compile the shader.
  76129. * They can be modified to trigger a new compilation
  76130. */
  76131. readonly options: IShaderMaterialOptions;
  76132. /**
  76133. * Gets the current class name of the material e.g. "ShaderMaterial"
  76134. * Mainly use in serialization.
  76135. * @returns the class name
  76136. */
  76137. getClassName(): string;
  76138. /**
  76139. * Specifies if the material will require alpha blending
  76140. * @returns a boolean specifying if alpha blending is needed
  76141. */
  76142. needAlphaBlending(): boolean;
  76143. /**
  76144. * Specifies if this material should be rendered in alpha test mode
  76145. * @returns a boolean specifying if an alpha test is needed.
  76146. */
  76147. needAlphaTesting(): boolean;
  76148. private _checkUniform;
  76149. /**
  76150. * Set a texture in the shader.
  76151. * @param name Define the name of the uniform samplers as defined in the shader
  76152. * @param texture Define the texture to bind to this sampler
  76153. * @return the material itself allowing "fluent" like uniform updates
  76154. */
  76155. setTexture(name: string, texture: Texture): ShaderMaterial;
  76156. /**
  76157. * Set a texture array in the shader.
  76158. * @param name Define the name of the uniform sampler array as defined in the shader
  76159. * @param textures Define the list of textures to bind to this sampler
  76160. * @return the material itself allowing "fluent" like uniform updates
  76161. */
  76162. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76163. /**
  76164. * Set a float in the shader.
  76165. * @param name Define the name of the uniform as defined in the shader
  76166. * @param value Define the value to give to the uniform
  76167. * @return the material itself allowing "fluent" like uniform updates
  76168. */
  76169. setFloat(name: string, value: number): ShaderMaterial;
  76170. /**
  76171. * Set a int in the shader.
  76172. * @param name Define the name of the uniform as defined in the shader
  76173. * @param value Define the value to give to the uniform
  76174. * @return the material itself allowing "fluent" like uniform updates
  76175. */
  76176. setInt(name: string, value: number): ShaderMaterial;
  76177. /**
  76178. * Set an array of floats in the shader.
  76179. * @param name Define the name of the uniform as defined in the shader
  76180. * @param value Define the value to give to the uniform
  76181. * @return the material itself allowing "fluent" like uniform updates
  76182. */
  76183. setFloats(name: string, value: number[]): ShaderMaterial;
  76184. /**
  76185. * Set a vec3 in the shader from a Color3.
  76186. * @param name Define the name of the uniform as defined in the shader
  76187. * @param value Define the value to give to the uniform
  76188. * @return the material itself allowing "fluent" like uniform updates
  76189. */
  76190. setColor3(name: string, value: Color3): ShaderMaterial;
  76191. /**
  76192. * Set a vec3 array in the shader from a Color3 array.
  76193. * @param name Define the name of the uniform as defined in the shader
  76194. * @param value Define the value to give to the uniform
  76195. * @return the material itself allowing "fluent" like uniform updates
  76196. */
  76197. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76198. /**
  76199. * Set a vec4 in the shader from a Color4.
  76200. * @param name Define the name of the uniform as defined in the shader
  76201. * @param value Define the value to give to the uniform
  76202. * @return the material itself allowing "fluent" like uniform updates
  76203. */
  76204. setColor4(name: string, value: Color4): ShaderMaterial;
  76205. /**
  76206. * Set a vec2 in the shader from a Vector2.
  76207. * @param name Define the name of the uniform as defined in the shader
  76208. * @param value Define the value to give to the uniform
  76209. * @return the material itself allowing "fluent" like uniform updates
  76210. */
  76211. setVector2(name: string, value: Vector2): ShaderMaterial;
  76212. /**
  76213. * Set a vec3 in the shader from a Vector3.
  76214. * @param name Define the name of the uniform as defined in the shader
  76215. * @param value Define the value to give to the uniform
  76216. * @return the material itself allowing "fluent" like uniform updates
  76217. */
  76218. setVector3(name: string, value: Vector3): ShaderMaterial;
  76219. /**
  76220. * Set a vec4 in the shader from a Vector4.
  76221. * @param name Define the name of the uniform as defined in the shader
  76222. * @param value Define the value to give to the uniform
  76223. * @return the material itself allowing "fluent" like uniform updates
  76224. */
  76225. setVector4(name: string, value: Vector4): ShaderMaterial;
  76226. /**
  76227. * Set a mat4 in the shader from a Matrix.
  76228. * @param name Define the name of the uniform as defined in the shader
  76229. * @param value Define the value to give to the uniform
  76230. * @return the material itself allowing "fluent" like uniform updates
  76231. */
  76232. setMatrix(name: string, value: Matrix): ShaderMaterial;
  76233. /**
  76234. * Set a mat3 in the shader from a Float32Array.
  76235. * @param name Define the name of the uniform as defined in the shader
  76236. * @param value Define the value to give to the uniform
  76237. * @return the material itself allowing "fluent" like uniform updates
  76238. */
  76239. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  76240. /**
  76241. * Set a mat2 in the shader from a Float32Array.
  76242. * @param name Define the name of the uniform as defined in the shader
  76243. * @param value Define the value to give to the uniform
  76244. * @return the material itself allowing "fluent" like uniform updates
  76245. */
  76246. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  76247. /**
  76248. * Set a vec2 array in the shader from a number array.
  76249. * @param name Define the name of the uniform as defined in the shader
  76250. * @param value Define the value to give to the uniform
  76251. * @return the material itself allowing "fluent" like uniform updates
  76252. */
  76253. setArray2(name: string, value: number[]): ShaderMaterial;
  76254. /**
  76255. * Set a vec3 array in the shader from a number array.
  76256. * @param name Define the name of the uniform as defined in the shader
  76257. * @param value Define the value to give to the uniform
  76258. * @return the material itself allowing "fluent" like uniform updates
  76259. */
  76260. setArray3(name: string, value: number[]): ShaderMaterial;
  76261. private _checkCache;
  76262. /**
  76263. * Specifies that the submesh is ready to be used
  76264. * @param mesh defines the mesh to check
  76265. * @param subMesh defines which submesh to check
  76266. * @param useInstances specifies that instances should be used
  76267. * @returns a boolean indicating that the submesh is ready or not
  76268. */
  76269. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  76270. /**
  76271. * Checks if the material is ready to render the requested mesh
  76272. * @param mesh Define the mesh to render
  76273. * @param useInstances Define whether or not the material is used with instances
  76274. * @returns true if ready, otherwise false
  76275. */
  76276. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76277. /**
  76278. * Binds the world matrix to the material
  76279. * @param world defines the world transformation matrix
  76280. */
  76281. bindOnlyWorldMatrix(world: Matrix): void;
  76282. /**
  76283. * Binds the material to the mesh
  76284. * @param world defines the world transformation matrix
  76285. * @param mesh defines the mesh to bind the material to
  76286. */
  76287. bind(world: Matrix, mesh?: Mesh): void;
  76288. /**
  76289. * Gets the active textures from the material
  76290. * @returns an array of textures
  76291. */
  76292. getActiveTextures(): BaseTexture[];
  76293. /**
  76294. * Specifies if the material uses a texture
  76295. * @param texture defines the texture to check against the material
  76296. * @returns a boolean specifying if the material uses the texture
  76297. */
  76298. hasTexture(texture: BaseTexture): boolean;
  76299. /**
  76300. * Makes a duplicate of the material, and gives it a new name
  76301. * @param name defines the new name for the duplicated material
  76302. * @returns the cloned material
  76303. */
  76304. clone(name: string): ShaderMaterial;
  76305. /**
  76306. * Disposes the material
  76307. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76308. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  76309. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  76310. */
  76311. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  76312. /**
  76313. * Serializes this material in a JSON representation
  76314. * @returns the serialized material object
  76315. */
  76316. serialize(): any;
  76317. /**
  76318. * Creates a shader material from parsed shader material data
  76319. * @param source defines the JSON represnetation of the material
  76320. * @param scene defines the hosting scene
  76321. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76322. * @returns a new material
  76323. */
  76324. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76325. }
  76326. }
  76327. declare module BABYLON {
  76328. /** @hidden */
  76329. export var colorPixelShader: {
  76330. name: string;
  76331. shader: string;
  76332. };
  76333. }
  76334. declare module BABYLON {
  76335. /** @hidden */
  76336. export var colorVertexShader: {
  76337. name: string;
  76338. shader: string;
  76339. };
  76340. }
  76341. declare module BABYLON {
  76342. /**
  76343. * Line mesh
  76344. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76345. */
  76346. export class LinesMesh extends Mesh {
  76347. /**
  76348. * If vertex color should be applied to the mesh
  76349. */
  76350. useVertexColor?: boolean | undefined;
  76351. /**
  76352. * If vertex alpha should be applied to the mesh
  76353. */
  76354. useVertexAlpha?: boolean | undefined;
  76355. /**
  76356. * Color of the line (Default: White)
  76357. */
  76358. color: Color3;
  76359. /**
  76360. * Alpha of the line (Default: 1)
  76361. */
  76362. alpha: number;
  76363. /**
  76364. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76365. * This margin is expressed in world space coordinates, so its value may vary.
  76366. * Default value is 0.1
  76367. */
  76368. intersectionThreshold: number;
  76369. private _colorShader;
  76370. /**
  76371. * Creates a new LinesMesh
  76372. * @param name defines the name
  76373. * @param scene defines the hosting scene
  76374. * @param parent defines the parent mesh if any
  76375. * @param source defines the optional source LinesMesh used to clone data from
  76376. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76377. * When false, achieved by calling a clone(), also passing False.
  76378. * This will make creation of children, recursive.
  76379. * @param useVertexColor defines if this LinesMesh supports vertex color
  76380. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76381. */
  76382. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76383. /**
  76384. * If vertex color should be applied to the mesh
  76385. */
  76386. useVertexColor?: boolean | undefined,
  76387. /**
  76388. * If vertex alpha should be applied to the mesh
  76389. */
  76390. useVertexAlpha?: boolean | undefined);
  76391. private _addClipPlaneDefine;
  76392. private _removeClipPlaneDefine;
  76393. isReady(): boolean;
  76394. /**
  76395. * Returns the string "LineMesh"
  76396. */
  76397. getClassName(): string;
  76398. /**
  76399. * @hidden
  76400. */
  76401. /**
  76402. * @hidden
  76403. */
  76404. material: Material;
  76405. /**
  76406. * @hidden
  76407. */
  76408. readonly checkCollisions: boolean;
  76409. /** @hidden */
  76410. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76411. /** @hidden */
  76412. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76413. /**
  76414. * Disposes of the line mesh
  76415. * @param doNotRecurse If children should be disposed
  76416. */
  76417. dispose(doNotRecurse?: boolean): void;
  76418. /**
  76419. * Returns a new LineMesh object cloned from the current one.
  76420. */
  76421. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76422. /**
  76423. * Creates a new InstancedLinesMesh object from the mesh model.
  76424. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76425. * @param name defines the name of the new instance
  76426. * @returns a new InstancedLinesMesh
  76427. */
  76428. createInstance(name: string): InstancedLinesMesh;
  76429. }
  76430. /**
  76431. * Creates an instance based on a source LinesMesh
  76432. */
  76433. export class InstancedLinesMesh extends InstancedMesh {
  76434. /**
  76435. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76436. * This margin is expressed in world space coordinates, so its value may vary.
  76437. * Initilized with the intersectionThreshold value of the source LinesMesh
  76438. */
  76439. intersectionThreshold: number;
  76440. constructor(name: string, source: LinesMesh);
  76441. /**
  76442. * Returns the string "InstancedLinesMesh".
  76443. */
  76444. getClassName(): string;
  76445. }
  76446. }
  76447. declare module BABYLON {
  76448. /** @hidden */
  76449. export var linePixelShader: {
  76450. name: string;
  76451. shader: string;
  76452. };
  76453. }
  76454. declare module BABYLON {
  76455. /** @hidden */
  76456. export var lineVertexShader: {
  76457. name: string;
  76458. shader: string;
  76459. };
  76460. }
  76461. declare module BABYLON {
  76462. interface AbstractMesh {
  76463. /**
  76464. * Disables the mesh edge rendering mode
  76465. * @returns the currentAbstractMesh
  76466. */
  76467. disableEdgesRendering(): AbstractMesh;
  76468. /**
  76469. * Enables the edge rendering mode on the mesh.
  76470. * This mode makes the mesh edges visible
  76471. * @param epsilon defines the maximal distance between two angles to detect a face
  76472. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76473. * @returns the currentAbstractMesh
  76474. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76475. */
  76476. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76477. /**
  76478. * Gets the edgesRenderer associated with the mesh
  76479. */
  76480. edgesRenderer: Nullable<EdgesRenderer>;
  76481. }
  76482. interface LinesMesh {
  76483. /**
  76484. * Enables the edge rendering mode on the mesh.
  76485. * This mode makes the mesh edges visible
  76486. * @param epsilon defines the maximal distance between two angles to detect a face
  76487. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76488. * @returns the currentAbstractMesh
  76489. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76490. */
  76491. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76492. }
  76493. interface InstancedLinesMesh {
  76494. /**
  76495. * Enables the edge rendering mode on the mesh.
  76496. * This mode makes the mesh edges visible
  76497. * @param epsilon defines the maximal distance between two angles to detect a face
  76498. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76499. * @returns the current InstancedLinesMesh
  76500. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76501. */
  76502. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76503. }
  76504. /**
  76505. * Defines the minimum contract an Edges renderer should follow.
  76506. */
  76507. export interface IEdgesRenderer extends IDisposable {
  76508. /**
  76509. * Gets or sets a boolean indicating if the edgesRenderer is active
  76510. */
  76511. isEnabled: boolean;
  76512. /**
  76513. * Renders the edges of the attached mesh,
  76514. */
  76515. render(): void;
  76516. /**
  76517. * Checks wether or not the edges renderer is ready to render.
  76518. * @return true if ready, otherwise false.
  76519. */
  76520. isReady(): boolean;
  76521. }
  76522. /**
  76523. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76524. */
  76525. export class EdgesRenderer implements IEdgesRenderer {
  76526. /**
  76527. * Define the size of the edges with an orthographic camera
  76528. */
  76529. edgesWidthScalerForOrthographic: number;
  76530. /**
  76531. * Define the size of the edges with a perspective camera
  76532. */
  76533. edgesWidthScalerForPerspective: number;
  76534. protected _source: AbstractMesh;
  76535. protected _linesPositions: number[];
  76536. protected _linesNormals: number[];
  76537. protected _linesIndices: number[];
  76538. protected _epsilon: number;
  76539. protected _indicesCount: number;
  76540. protected _lineShader: ShaderMaterial;
  76541. protected _ib: WebGLBuffer;
  76542. protected _buffers: {
  76543. [key: string]: Nullable<VertexBuffer>;
  76544. };
  76545. protected _checkVerticesInsteadOfIndices: boolean;
  76546. private _meshRebuildObserver;
  76547. private _meshDisposeObserver;
  76548. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  76549. isEnabled: boolean;
  76550. /**
  76551. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  76552. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  76553. * @param source Mesh used to create edges
  76554. * @param epsilon sum of angles in adjacency to check for edge
  76555. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  76556. * @param generateEdgesLines - should generate Lines or only prepare resources.
  76557. */
  76558. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  76559. protected _prepareRessources(): void;
  76560. /** @hidden */
  76561. _rebuild(): void;
  76562. /**
  76563. * Releases the required resources for the edges renderer
  76564. */
  76565. dispose(): void;
  76566. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  76567. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  76568. /**
  76569. * Checks if the pair of p0 and p1 is en edge
  76570. * @param faceIndex
  76571. * @param edge
  76572. * @param faceNormals
  76573. * @param p0
  76574. * @param p1
  76575. * @private
  76576. */
  76577. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  76578. /**
  76579. * push line into the position, normal and index buffer
  76580. * @protected
  76581. */
  76582. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  76583. /**
  76584. * Generates lines edges from adjacencjes
  76585. * @private
  76586. */
  76587. _generateEdgesLines(): void;
  76588. /**
  76589. * Checks wether or not the edges renderer is ready to render.
  76590. * @return true if ready, otherwise false.
  76591. */
  76592. isReady(): boolean;
  76593. /**
  76594. * Renders the edges of the attached mesh,
  76595. */
  76596. render(): void;
  76597. }
  76598. /**
  76599. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  76600. */
  76601. export class LineEdgesRenderer extends EdgesRenderer {
  76602. /**
  76603. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  76604. * @param source LineMesh used to generate edges
  76605. * @param epsilon not important (specified angle for edge detection)
  76606. * @param checkVerticesInsteadOfIndices not important for LineMesh
  76607. */
  76608. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  76609. /**
  76610. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  76611. */
  76612. _generateEdgesLines(): void;
  76613. }
  76614. }
  76615. declare module BABYLON {
  76616. /**
  76617. * This represents the object necessary to create a rendering group.
  76618. * This is exclusively used and created by the rendering manager.
  76619. * To modify the behavior, you use the available helpers in your scene or meshes.
  76620. * @hidden
  76621. */
  76622. export class RenderingGroup {
  76623. index: number;
  76624. private _scene;
  76625. private _opaqueSubMeshes;
  76626. private _transparentSubMeshes;
  76627. private _alphaTestSubMeshes;
  76628. private _depthOnlySubMeshes;
  76629. private _particleSystems;
  76630. private _spriteManagers;
  76631. private _opaqueSortCompareFn;
  76632. private _alphaTestSortCompareFn;
  76633. private _transparentSortCompareFn;
  76634. private _renderOpaque;
  76635. private _renderAlphaTest;
  76636. private _renderTransparent;
  76637. /** @hidden */
  76638. _edgesRenderers: SmartArray<IEdgesRenderer>;
  76639. onBeforeTransparentRendering: () => void;
  76640. /**
  76641. * Set the opaque sort comparison function.
  76642. * If null the sub meshes will be render in the order they were created
  76643. */
  76644. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76645. /**
  76646. * Set the alpha test sort comparison function.
  76647. * If null the sub meshes will be render in the order they were created
  76648. */
  76649. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76650. /**
  76651. * Set the transparent sort comparison function.
  76652. * If null the sub meshes will be render in the order they were created
  76653. */
  76654. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76655. /**
  76656. * Creates a new rendering group.
  76657. * @param index The rendering group index
  76658. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  76659. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  76660. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  76661. */
  76662. 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>);
  76663. /**
  76664. * Render all the sub meshes contained in the group.
  76665. * @param customRenderFunction Used to override the default render behaviour of the group.
  76666. * @returns true if rendered some submeshes.
  76667. */
  76668. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  76669. /**
  76670. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  76671. * @param subMeshes The submeshes to render
  76672. */
  76673. private renderOpaqueSorted;
  76674. /**
  76675. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  76676. * @param subMeshes The submeshes to render
  76677. */
  76678. private renderAlphaTestSorted;
  76679. /**
  76680. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  76681. * @param subMeshes The submeshes to render
  76682. */
  76683. private renderTransparentSorted;
  76684. /**
  76685. * Renders the submeshes in a specified order.
  76686. * @param subMeshes The submeshes to sort before render
  76687. * @param sortCompareFn The comparison function use to sort
  76688. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  76689. * @param transparent Specifies to activate blending if true
  76690. */
  76691. private static renderSorted;
  76692. /**
  76693. * Renders the submeshes in the order they were dispatched (no sort applied).
  76694. * @param subMeshes The submeshes to render
  76695. */
  76696. private static renderUnsorted;
  76697. /**
  76698. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76699. * are rendered back to front if in the same alpha index.
  76700. *
  76701. * @param a The first submesh
  76702. * @param b The second submesh
  76703. * @returns The result of the comparison
  76704. */
  76705. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  76706. /**
  76707. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76708. * are rendered back to front.
  76709. *
  76710. * @param a The first submesh
  76711. * @param b The second submesh
  76712. * @returns The result of the comparison
  76713. */
  76714. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  76715. /**
  76716. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76717. * are rendered front to back (prevent overdraw).
  76718. *
  76719. * @param a The first submesh
  76720. * @param b The second submesh
  76721. * @returns The result of the comparison
  76722. */
  76723. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  76724. /**
  76725. * Resets the different lists of submeshes to prepare a new frame.
  76726. */
  76727. prepare(): void;
  76728. dispose(): void;
  76729. /**
  76730. * Inserts the submesh in its correct queue depending on its material.
  76731. * @param subMesh The submesh to dispatch
  76732. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76733. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76734. */
  76735. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76736. dispatchSprites(spriteManager: ISpriteManager): void;
  76737. dispatchParticles(particleSystem: IParticleSystem): void;
  76738. private _renderParticles;
  76739. private _renderSprites;
  76740. }
  76741. }
  76742. declare module BABYLON {
  76743. /**
  76744. * Interface describing the different options available in the rendering manager
  76745. * regarding Auto Clear between groups.
  76746. */
  76747. export interface IRenderingManagerAutoClearSetup {
  76748. /**
  76749. * Defines whether or not autoclear is enable.
  76750. */
  76751. autoClear: boolean;
  76752. /**
  76753. * Defines whether or not to autoclear the depth buffer.
  76754. */
  76755. depth: boolean;
  76756. /**
  76757. * Defines whether or not to autoclear the stencil buffer.
  76758. */
  76759. stencil: boolean;
  76760. }
  76761. /**
  76762. * This class is used by the onRenderingGroupObservable
  76763. */
  76764. export class RenderingGroupInfo {
  76765. /**
  76766. * The Scene that being rendered
  76767. */
  76768. scene: Scene;
  76769. /**
  76770. * The camera currently used for the rendering pass
  76771. */
  76772. camera: Nullable<Camera>;
  76773. /**
  76774. * The ID of the renderingGroup being processed
  76775. */
  76776. renderingGroupId: number;
  76777. }
  76778. /**
  76779. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76780. * It is enable to manage the different groups as well as the different necessary sort functions.
  76781. * This should not be used directly aside of the few static configurations
  76782. */
  76783. export class RenderingManager {
  76784. /**
  76785. * The max id used for rendering groups (not included)
  76786. */
  76787. static MAX_RENDERINGGROUPS: number;
  76788. /**
  76789. * The min id used for rendering groups (included)
  76790. */
  76791. static MIN_RENDERINGGROUPS: number;
  76792. /**
  76793. * Used to globally prevent autoclearing scenes.
  76794. */
  76795. static AUTOCLEAR: boolean;
  76796. /**
  76797. * @hidden
  76798. */
  76799. _useSceneAutoClearSetup: boolean;
  76800. private _scene;
  76801. private _renderingGroups;
  76802. private _depthStencilBufferAlreadyCleaned;
  76803. private _autoClearDepthStencil;
  76804. private _customOpaqueSortCompareFn;
  76805. private _customAlphaTestSortCompareFn;
  76806. private _customTransparentSortCompareFn;
  76807. private _renderingGroupInfo;
  76808. /**
  76809. * Instantiates a new rendering group for a particular scene
  76810. * @param scene Defines the scene the groups belongs to
  76811. */
  76812. constructor(scene: Scene);
  76813. private _clearDepthStencilBuffer;
  76814. /**
  76815. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76816. * @hidden
  76817. */
  76818. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76819. /**
  76820. * Resets the different information of the group to prepare a new frame
  76821. * @hidden
  76822. */
  76823. reset(): void;
  76824. /**
  76825. * Dispose and release the group and its associated resources.
  76826. * @hidden
  76827. */
  76828. dispose(): void;
  76829. /**
  76830. * Clear the info related to rendering groups preventing retention points during dispose.
  76831. */
  76832. freeRenderingGroups(): void;
  76833. private _prepareRenderingGroup;
  76834. /**
  76835. * Add a sprite manager to the rendering manager in order to render it this frame.
  76836. * @param spriteManager Define the sprite manager to render
  76837. */
  76838. dispatchSprites(spriteManager: ISpriteManager): void;
  76839. /**
  76840. * Add a particle system to the rendering manager in order to render it this frame.
  76841. * @param particleSystem Define the particle system to render
  76842. */
  76843. dispatchParticles(particleSystem: IParticleSystem): void;
  76844. /**
  76845. * Add a submesh to the manager in order to render it this frame
  76846. * @param subMesh The submesh to dispatch
  76847. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76848. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76849. */
  76850. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76851. /**
  76852. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76853. * This allowed control for front to back rendering or reversly depending of the special needs.
  76854. *
  76855. * @param renderingGroupId The rendering group id corresponding to its index
  76856. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76857. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76858. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76859. */
  76860. 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;
  76861. /**
  76862. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76863. *
  76864. * @param renderingGroupId The rendering group id corresponding to its index
  76865. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76866. * @param depth Automatically clears depth between groups if true and autoClear is true.
  76867. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  76868. */
  76869. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  76870. /**
  76871. * Gets the current auto clear configuration for one rendering group of the rendering
  76872. * manager.
  76873. * @param index the rendering group index to get the information for
  76874. * @returns The auto clear setup for the requested rendering group
  76875. */
  76876. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  76877. }
  76878. }
  76879. declare module BABYLON {
  76880. /**
  76881. * This Helps creating a texture that will be created from a camera in your scene.
  76882. * It is basically a dynamic texture that could be used to create special effects for instance.
  76883. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  76884. */
  76885. export class RenderTargetTexture extends Texture {
  76886. isCube: boolean;
  76887. /**
  76888. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  76889. */
  76890. static readonly REFRESHRATE_RENDER_ONCE: number;
  76891. /**
  76892. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  76893. */
  76894. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  76895. /**
  76896. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  76897. * the central point of your effect and can save a lot of performances.
  76898. */
  76899. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  76900. /**
  76901. * Use this predicate to dynamically define the list of mesh you want to render.
  76902. * If set, the renderList property will be overwritten.
  76903. */
  76904. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  76905. private _renderList;
  76906. /**
  76907. * Use this list to define the list of mesh you want to render.
  76908. */
  76909. renderList: Nullable<Array<AbstractMesh>>;
  76910. private _hookArray;
  76911. /**
  76912. * Define if particles should be rendered in your texture.
  76913. */
  76914. renderParticles: boolean;
  76915. /**
  76916. * Define if sprites should be rendered in your texture.
  76917. */
  76918. renderSprites: boolean;
  76919. /**
  76920. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  76921. */
  76922. coordinatesMode: number;
  76923. /**
  76924. * Define the camera used to render the texture.
  76925. */
  76926. activeCamera: Nullable<Camera>;
  76927. /**
  76928. * Override the render function of the texture with your own one.
  76929. */
  76930. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  76931. /**
  76932. * Define if camera post processes should be use while rendering the texture.
  76933. */
  76934. useCameraPostProcesses: boolean;
  76935. /**
  76936. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  76937. */
  76938. ignoreCameraViewport: boolean;
  76939. private _postProcessManager;
  76940. private _postProcesses;
  76941. private _resizeObserver;
  76942. /**
  76943. * An event triggered when the texture is unbind.
  76944. */
  76945. onBeforeBindObservable: Observable<RenderTargetTexture>;
  76946. /**
  76947. * An event triggered when the texture is unbind.
  76948. */
  76949. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  76950. private _onAfterUnbindObserver;
  76951. /**
  76952. * Set a after unbind callback in the texture.
  76953. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  76954. */
  76955. onAfterUnbind: () => void;
  76956. /**
  76957. * An event triggered before rendering the texture
  76958. */
  76959. onBeforeRenderObservable: Observable<number>;
  76960. private _onBeforeRenderObserver;
  76961. /**
  76962. * Set a before render callback in the texture.
  76963. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  76964. */
  76965. onBeforeRender: (faceIndex: number) => void;
  76966. /**
  76967. * An event triggered after rendering the texture
  76968. */
  76969. onAfterRenderObservable: Observable<number>;
  76970. private _onAfterRenderObserver;
  76971. /**
  76972. * Set a after render callback in the texture.
  76973. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  76974. */
  76975. onAfterRender: (faceIndex: number) => void;
  76976. /**
  76977. * An event triggered after the texture clear
  76978. */
  76979. onClearObservable: Observable<Engine>;
  76980. private _onClearObserver;
  76981. /**
  76982. * Set a clear callback in the texture.
  76983. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  76984. */
  76985. onClear: (Engine: Engine) => void;
  76986. /**
  76987. * Define the clear color of the Render Target if it should be different from the scene.
  76988. */
  76989. clearColor: Color4;
  76990. protected _size: number | {
  76991. width: number;
  76992. height: number;
  76993. };
  76994. protected _initialSizeParameter: number | {
  76995. width: number;
  76996. height: number;
  76997. } | {
  76998. ratio: number;
  76999. };
  77000. protected _sizeRatio: Nullable<number>;
  77001. /** @hidden */
  77002. _generateMipMaps: boolean;
  77003. protected _renderingManager: RenderingManager;
  77004. /** @hidden */
  77005. _waitingRenderList: string[];
  77006. protected _doNotChangeAspectRatio: boolean;
  77007. protected _currentRefreshId: number;
  77008. protected _refreshRate: number;
  77009. protected _textureMatrix: Matrix;
  77010. protected _samples: number;
  77011. protected _renderTargetOptions: RenderTargetCreationOptions;
  77012. /**
  77013. * Gets render target creation options that were used.
  77014. */
  77015. readonly renderTargetOptions: RenderTargetCreationOptions;
  77016. protected _engine: Engine;
  77017. protected _onRatioRescale(): void;
  77018. /**
  77019. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77020. * It must define where the camera used to render the texture is set
  77021. */
  77022. boundingBoxPosition: Vector3;
  77023. private _boundingBoxSize;
  77024. /**
  77025. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77026. * When defined, the cubemap will switch to local mode
  77027. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77028. * @example https://www.babylonjs-playground.com/#RNASML
  77029. */
  77030. boundingBoxSize: Vector3;
  77031. /**
  77032. * In case the RTT has been created with a depth texture, get the associated
  77033. * depth texture.
  77034. * Otherwise, return null.
  77035. */
  77036. depthStencilTexture: Nullable<InternalTexture>;
  77037. /**
  77038. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77039. * or used a shadow, depth texture...
  77040. * @param name The friendly name of the texture
  77041. * @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)
  77042. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77043. * @param generateMipMaps True if mip maps need to be generated after render.
  77044. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77045. * @param type The type of the buffer in the RTT (int, half float, float...)
  77046. * @param isCube True if a cube texture needs to be created
  77047. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77048. * @param generateDepthBuffer True to generate a depth buffer
  77049. * @param generateStencilBuffer True to generate a stencil buffer
  77050. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77051. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77052. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77053. */
  77054. constructor(name: string, size: number | {
  77055. width: number;
  77056. height: number;
  77057. } | {
  77058. ratio: number;
  77059. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77060. /**
  77061. * Creates a depth stencil texture.
  77062. * This is only available in WebGL 2 or with the depth texture extension available.
  77063. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77064. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77065. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77066. */
  77067. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77068. private _processSizeParameter;
  77069. /**
  77070. * Define the number of samples to use in case of MSAA.
  77071. * It defaults to one meaning no MSAA has been enabled.
  77072. */
  77073. samples: number;
  77074. /**
  77075. * Resets the refresh counter of the texture and start bak from scratch.
  77076. * Could be useful to regenerate the texture if it is setup to render only once.
  77077. */
  77078. resetRefreshCounter(): void;
  77079. /**
  77080. * Define the refresh rate of the texture or the rendering frequency.
  77081. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77082. */
  77083. refreshRate: number;
  77084. /**
  77085. * Adds a post process to the render target rendering passes.
  77086. * @param postProcess define the post process to add
  77087. */
  77088. addPostProcess(postProcess: PostProcess): void;
  77089. /**
  77090. * Clear all the post processes attached to the render target
  77091. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77092. */
  77093. clearPostProcesses(dispose?: boolean): void;
  77094. /**
  77095. * Remove one of the post process from the list of attached post processes to the texture
  77096. * @param postProcess define the post process to remove from the list
  77097. */
  77098. removePostProcess(postProcess: PostProcess): void;
  77099. /** @hidden */
  77100. _shouldRender(): boolean;
  77101. /**
  77102. * Gets the actual render size of the texture.
  77103. * @returns the width of the render size
  77104. */
  77105. getRenderSize(): number;
  77106. /**
  77107. * Gets the actual render width of the texture.
  77108. * @returns the width of the render size
  77109. */
  77110. getRenderWidth(): number;
  77111. /**
  77112. * Gets the actual render height of the texture.
  77113. * @returns the height of the render size
  77114. */
  77115. getRenderHeight(): number;
  77116. /**
  77117. * Get if the texture can be rescaled or not.
  77118. */
  77119. readonly canRescale: boolean;
  77120. /**
  77121. * Resize the texture using a ratio.
  77122. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77123. */
  77124. scale(ratio: number): void;
  77125. /**
  77126. * Get the texture reflection matrix used to rotate/transform the reflection.
  77127. * @returns the reflection matrix
  77128. */
  77129. getReflectionTextureMatrix(): Matrix;
  77130. /**
  77131. * Resize the texture to a new desired size.
  77132. * Be carrefull as it will recreate all the data in the new texture.
  77133. * @param size Define the new size. It can be:
  77134. * - a number for squared texture,
  77135. * - an object containing { width: number, height: number }
  77136. * - or an object containing a ratio { ratio: number }
  77137. */
  77138. resize(size: number | {
  77139. width: number;
  77140. height: number;
  77141. } | {
  77142. ratio: number;
  77143. }): void;
  77144. /**
  77145. * Renders all the objects from the render list into the texture.
  77146. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77147. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77148. */
  77149. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77150. private _bestReflectionRenderTargetDimension;
  77151. /**
  77152. * @hidden
  77153. * @param faceIndex face index to bind to if this is a cubetexture
  77154. */
  77155. _bindFrameBuffer(faceIndex?: number): void;
  77156. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77157. private renderToTarget;
  77158. /**
  77159. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77160. * This allowed control for front to back rendering or reversly depending of the special needs.
  77161. *
  77162. * @param renderingGroupId The rendering group id corresponding to its index
  77163. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77164. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77165. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77166. */
  77167. 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;
  77168. /**
  77169. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77170. *
  77171. * @param renderingGroupId The rendering group id corresponding to its index
  77172. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77173. */
  77174. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77175. /**
  77176. * Clones the texture.
  77177. * @returns the cloned texture
  77178. */
  77179. clone(): RenderTargetTexture;
  77180. /**
  77181. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77182. * @returns The JSON representation of the texture
  77183. */
  77184. serialize(): any;
  77185. /**
  77186. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77187. */
  77188. disposeFramebufferObjects(): void;
  77189. /**
  77190. * Dispose the texture and release its associated resources.
  77191. */
  77192. dispose(): void;
  77193. /** @hidden */
  77194. _rebuild(): void;
  77195. /**
  77196. * Clear the info related to rendering groups preventing retention point in material dispose.
  77197. */
  77198. freeRenderingGroups(): void;
  77199. /**
  77200. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77201. * @returns the view count
  77202. */
  77203. getViewCount(): number;
  77204. }
  77205. }
  77206. declare module BABYLON {
  77207. /**
  77208. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77209. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77210. * You can then easily use it as a reflectionTexture on a flat surface.
  77211. * In case the surface is not a plane, please consider relying on reflection probes.
  77212. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77213. */
  77214. export class MirrorTexture extends RenderTargetTexture {
  77215. private scene;
  77216. /**
  77217. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77218. * 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.
  77219. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77220. */
  77221. mirrorPlane: Plane;
  77222. /**
  77223. * Define the blur ratio used to blur the reflection if needed.
  77224. */
  77225. blurRatio: number;
  77226. /**
  77227. * Define the adaptive blur kernel used to blur the reflection if needed.
  77228. * This will autocompute the closest best match for the `blurKernel`
  77229. */
  77230. adaptiveBlurKernel: number;
  77231. /**
  77232. * Define the blur kernel used to blur the reflection if needed.
  77233. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77234. */
  77235. blurKernel: number;
  77236. /**
  77237. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  77238. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77239. */
  77240. blurKernelX: number;
  77241. /**
  77242. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  77243. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77244. */
  77245. blurKernelY: number;
  77246. private _autoComputeBlurKernel;
  77247. protected _onRatioRescale(): void;
  77248. private _updateGammaSpace;
  77249. private _imageProcessingConfigChangeObserver;
  77250. private _transformMatrix;
  77251. private _mirrorMatrix;
  77252. private _savedViewMatrix;
  77253. private _blurX;
  77254. private _blurY;
  77255. private _adaptiveBlurKernel;
  77256. private _blurKernelX;
  77257. private _blurKernelY;
  77258. private _blurRatio;
  77259. /**
  77260. * Instantiates a Mirror Texture.
  77261. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77262. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77263. * You can then easily use it as a reflectionTexture on a flat surface.
  77264. * In case the surface is not a plane, please consider relying on reflection probes.
  77265. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77266. * @param name
  77267. * @param size
  77268. * @param scene
  77269. * @param generateMipMaps
  77270. * @param type
  77271. * @param samplingMode
  77272. * @param generateDepthBuffer
  77273. */
  77274. constructor(name: string, size: number | {
  77275. width: number;
  77276. height: number;
  77277. } | {
  77278. ratio: number;
  77279. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  77280. private _preparePostProcesses;
  77281. /**
  77282. * Clone the mirror texture.
  77283. * @returns the cloned texture
  77284. */
  77285. clone(): MirrorTexture;
  77286. /**
  77287. * Serialize the texture to a JSON representation you could use in Parse later on
  77288. * @returns the serialized JSON representation
  77289. */
  77290. serialize(): any;
  77291. /**
  77292. * Dispose the texture and release its associated resources.
  77293. */
  77294. dispose(): void;
  77295. }
  77296. }
  77297. declare module BABYLON {
  77298. /**
  77299. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77300. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77301. */
  77302. export class Texture extends BaseTexture {
  77303. /** @hidden */
  77304. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  77305. /** @hidden */
  77306. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  77307. /** @hidden */
  77308. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  77309. /** nearest is mag = nearest and min = nearest and mip = linear */
  77310. static readonly NEAREST_SAMPLINGMODE: number;
  77311. /** nearest is mag = nearest and min = nearest and mip = linear */
  77312. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  77313. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77314. static readonly BILINEAR_SAMPLINGMODE: number;
  77315. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77316. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  77317. /** Trilinear is mag = linear and min = linear and mip = linear */
  77318. static readonly TRILINEAR_SAMPLINGMODE: number;
  77319. /** Trilinear is mag = linear and min = linear and mip = linear */
  77320. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  77321. /** mag = nearest and min = nearest and mip = nearest */
  77322. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  77323. /** mag = nearest and min = linear and mip = nearest */
  77324. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  77325. /** mag = nearest and min = linear and mip = linear */
  77326. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77327. /** mag = nearest and min = linear and mip = none */
  77328. static readonly NEAREST_LINEAR: number;
  77329. /** mag = nearest and min = nearest and mip = none */
  77330. static readonly NEAREST_NEAREST: number;
  77331. /** mag = linear and min = nearest and mip = nearest */
  77332. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77333. /** mag = linear and min = nearest and mip = linear */
  77334. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77335. /** mag = linear and min = linear and mip = none */
  77336. static readonly LINEAR_LINEAR: number;
  77337. /** mag = linear and min = nearest and mip = none */
  77338. static readonly LINEAR_NEAREST: number;
  77339. /** Explicit coordinates mode */
  77340. static readonly EXPLICIT_MODE: number;
  77341. /** Spherical coordinates mode */
  77342. static readonly SPHERICAL_MODE: number;
  77343. /** Planar coordinates mode */
  77344. static readonly PLANAR_MODE: number;
  77345. /** Cubic coordinates mode */
  77346. static readonly CUBIC_MODE: number;
  77347. /** Projection coordinates mode */
  77348. static readonly PROJECTION_MODE: number;
  77349. /** Inverse Cubic coordinates mode */
  77350. static readonly SKYBOX_MODE: number;
  77351. /** Inverse Cubic coordinates mode */
  77352. static readonly INVCUBIC_MODE: number;
  77353. /** Equirectangular coordinates mode */
  77354. static readonly EQUIRECTANGULAR_MODE: number;
  77355. /** Equirectangular Fixed coordinates mode */
  77356. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77357. /** Equirectangular Fixed Mirrored coordinates mode */
  77358. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77359. /** Texture is not repeating outside of 0..1 UVs */
  77360. static readonly CLAMP_ADDRESSMODE: number;
  77361. /** Texture is repeating outside of 0..1 UVs */
  77362. static readonly WRAP_ADDRESSMODE: number;
  77363. /** Texture is repeating and mirrored */
  77364. static readonly MIRROR_ADDRESSMODE: number;
  77365. /**
  77366. * 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
  77367. */
  77368. static UseSerializedUrlIfAny: boolean;
  77369. /**
  77370. * Define the url of the texture.
  77371. */
  77372. url: Nullable<string>;
  77373. /**
  77374. * Define an offset on the texture to offset the u coordinates of the UVs
  77375. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77376. */
  77377. uOffset: number;
  77378. /**
  77379. * Define an offset on the texture to offset the v coordinates of the UVs
  77380. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77381. */
  77382. vOffset: number;
  77383. /**
  77384. * Define an offset on the texture to scale the u coordinates of the UVs
  77385. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77386. */
  77387. uScale: number;
  77388. /**
  77389. * Define an offset on the texture to scale the v coordinates of the UVs
  77390. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77391. */
  77392. vScale: number;
  77393. /**
  77394. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77395. * @see http://doc.babylonjs.com/how_to/more_materials
  77396. */
  77397. uAng: number;
  77398. /**
  77399. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77400. * @see http://doc.babylonjs.com/how_to/more_materials
  77401. */
  77402. vAng: number;
  77403. /**
  77404. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77405. * @see http://doc.babylonjs.com/how_to/more_materials
  77406. */
  77407. wAng: number;
  77408. /**
  77409. * Defines the center of rotation (U)
  77410. */
  77411. uRotationCenter: number;
  77412. /**
  77413. * Defines the center of rotation (V)
  77414. */
  77415. vRotationCenter: number;
  77416. /**
  77417. * Defines the center of rotation (W)
  77418. */
  77419. wRotationCenter: number;
  77420. /**
  77421. * Are mip maps generated for this texture or not.
  77422. */
  77423. readonly noMipmap: boolean;
  77424. /**
  77425. * List of inspectable custom properties (used by the Inspector)
  77426. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77427. */
  77428. inspectableCustomProperties: IInspectable[];
  77429. private _noMipmap;
  77430. /** @hidden */
  77431. _invertY: boolean;
  77432. private _rowGenerationMatrix;
  77433. private _cachedTextureMatrix;
  77434. private _projectionModeMatrix;
  77435. private _t0;
  77436. private _t1;
  77437. private _t2;
  77438. private _cachedUOffset;
  77439. private _cachedVOffset;
  77440. private _cachedUScale;
  77441. private _cachedVScale;
  77442. private _cachedUAng;
  77443. private _cachedVAng;
  77444. private _cachedWAng;
  77445. private _cachedProjectionMatrixId;
  77446. private _cachedCoordinatesMode;
  77447. /** @hidden */
  77448. protected _initialSamplingMode: number;
  77449. /** @hidden */
  77450. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77451. private _deleteBuffer;
  77452. protected _format: Nullable<number>;
  77453. private _delayedOnLoad;
  77454. private _delayedOnError;
  77455. /**
  77456. * Observable triggered once the texture has been loaded.
  77457. */
  77458. onLoadObservable: Observable<Texture>;
  77459. protected _isBlocking: boolean;
  77460. /**
  77461. * Is the texture preventing material to render while loading.
  77462. * If false, a default texture will be used instead of the loading one during the preparation step.
  77463. */
  77464. isBlocking: boolean;
  77465. /**
  77466. * Get the current sampling mode associated with the texture.
  77467. */
  77468. readonly samplingMode: number;
  77469. /**
  77470. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77471. */
  77472. readonly invertY: boolean;
  77473. /**
  77474. * Instantiates a new texture.
  77475. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77476. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77477. * @param url define the url of the picture to load as a texture
  77478. * @param scene define the scene the texture will belong to
  77479. * @param noMipmap define if the texture will require mip maps or not
  77480. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77481. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77482. * @param onLoad define a callback triggered when the texture has been loaded
  77483. * @param onError define a callback triggered when an error occurred during the loading session
  77484. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77485. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77486. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77487. */
  77488. 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);
  77489. /**
  77490. * Update the url (and optional buffer) of this texture if url was null during construction.
  77491. * @param url the url of the texture
  77492. * @param buffer the buffer of the texture (defaults to null)
  77493. * @param onLoad callback called when the texture is loaded (defaults to null)
  77494. */
  77495. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77496. /**
  77497. * Finish the loading sequence of a texture flagged as delayed load.
  77498. * @hidden
  77499. */
  77500. delayLoad(): void;
  77501. private _prepareRowForTextureGeneration;
  77502. /**
  77503. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77504. * @returns the transform matrix of the texture.
  77505. */
  77506. getTextureMatrix(): Matrix;
  77507. /**
  77508. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77509. * @returns The reflection texture transform
  77510. */
  77511. getReflectionTextureMatrix(): Matrix;
  77512. /**
  77513. * Clones the texture.
  77514. * @returns the cloned texture
  77515. */
  77516. clone(): Texture;
  77517. /**
  77518. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77519. * @returns The JSON representation of the texture
  77520. */
  77521. serialize(): any;
  77522. /**
  77523. * Get the current class name of the texture useful for serialization or dynamic coding.
  77524. * @returns "Texture"
  77525. */
  77526. getClassName(): string;
  77527. /**
  77528. * Dispose the texture and release its associated resources.
  77529. */
  77530. dispose(): void;
  77531. /**
  77532. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  77533. * @param parsedTexture Define the JSON representation of the texture
  77534. * @param scene Define the scene the parsed texture should be instantiated in
  77535. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  77536. * @returns The parsed texture if successful
  77537. */
  77538. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  77539. /**
  77540. * Creates a texture from its base 64 representation.
  77541. * @param data Define the base64 payload without the data: prefix
  77542. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77543. * @param scene Define the scene the texture should belong to
  77544. * @param noMipmap Forces the texture to not create mip map information if true
  77545. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77546. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77547. * @param onLoad define a callback triggered when the texture has been loaded
  77548. * @param onError define a callback triggered when an error occurred during the loading session
  77549. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77550. * @returns the created texture
  77551. */
  77552. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  77553. /**
  77554. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  77555. * @param data Define the base64 payload without the data: prefix
  77556. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77557. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77558. * @param scene Define the scene the texture should belong to
  77559. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77560. * @param noMipmap Forces the texture to not create mip map information if true
  77561. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77562. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77563. * @param onLoad define a callback triggered when the texture has been loaded
  77564. * @param onError define a callback triggered when an error occurred during the loading session
  77565. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77566. * @returns the created texture
  77567. */
  77568. 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;
  77569. }
  77570. }
  77571. declare module BABYLON {
  77572. /**
  77573. * Raw texture can help creating a texture directly from an array of data.
  77574. * This can be super useful if you either get the data from an uncompressed source or
  77575. * if you wish to create your texture pixel by pixel.
  77576. */
  77577. export class RawTexture extends Texture {
  77578. /**
  77579. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77580. */
  77581. format: number;
  77582. private _engine;
  77583. /**
  77584. * Instantiates a new RawTexture.
  77585. * Raw texture can help creating a texture directly from an array of data.
  77586. * This can be super useful if you either get the data from an uncompressed source or
  77587. * if you wish to create your texture pixel by pixel.
  77588. * @param data define the array of data to use to create the texture
  77589. * @param width define the width of the texture
  77590. * @param height define the height of the texture
  77591. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77592. * @param scene define the scene the texture belongs to
  77593. * @param generateMipMaps define whether mip maps should be generated or not
  77594. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77595. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77596. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77597. */
  77598. constructor(data: ArrayBufferView, width: number, height: number,
  77599. /**
  77600. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77601. */
  77602. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77603. /**
  77604. * Updates the texture underlying data.
  77605. * @param data Define the new data of the texture
  77606. */
  77607. update(data: ArrayBufferView): void;
  77608. /**
  77609. * Creates a luminance texture from some data.
  77610. * @param data Define the texture data
  77611. * @param width Define the width of the texture
  77612. * @param height Define the height of the texture
  77613. * @param scene Define the scene the texture belongs to
  77614. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77615. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77616. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77617. * @returns the luminance texture
  77618. */
  77619. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77620. /**
  77621. * Creates a luminance alpha texture from some data.
  77622. * @param data Define the texture data
  77623. * @param width Define the width of the texture
  77624. * @param height Define the height of the texture
  77625. * @param scene Define the scene the texture belongs to
  77626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77629. * @returns the luminance alpha texture
  77630. */
  77631. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77632. /**
  77633. * Creates an alpha texture from some data.
  77634. * @param data Define the texture data
  77635. * @param width Define the width of the texture
  77636. * @param height Define the height of the texture
  77637. * @param scene Define the scene the texture belongs to
  77638. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77639. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77640. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77641. * @returns the alpha texture
  77642. */
  77643. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77644. /**
  77645. * Creates a RGB texture from some data.
  77646. * @param data Define the texture data
  77647. * @param width Define the width of the texture
  77648. * @param height Define the height of the texture
  77649. * @param scene Define the scene the texture belongs to
  77650. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77651. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77652. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77653. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77654. * @returns the RGB alpha texture
  77655. */
  77656. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77657. /**
  77658. * Creates a RGBA texture from some data.
  77659. * @param data Define the texture data
  77660. * @param width Define the width of the texture
  77661. * @param height Define the height of the texture
  77662. * @param scene Define the scene the texture belongs to
  77663. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77666. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77667. * @returns the RGBA texture
  77668. */
  77669. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77670. /**
  77671. * Creates a R texture from some data.
  77672. * @param data Define the texture data
  77673. * @param width Define the width of the texture
  77674. * @param height Define the height of the texture
  77675. * @param scene Define the scene the texture belongs to
  77676. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77677. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77678. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77679. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77680. * @returns the R texture
  77681. */
  77682. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77683. }
  77684. }
  77685. declare module BABYLON {
  77686. /**
  77687. * Defines a runtime animation
  77688. */
  77689. export class RuntimeAnimation {
  77690. private _events;
  77691. /**
  77692. * The current frame of the runtime animation
  77693. */
  77694. private _currentFrame;
  77695. /**
  77696. * The animation used by the runtime animation
  77697. */
  77698. private _animation;
  77699. /**
  77700. * The target of the runtime animation
  77701. */
  77702. private _target;
  77703. /**
  77704. * The initiating animatable
  77705. */
  77706. private _host;
  77707. /**
  77708. * The original value of the runtime animation
  77709. */
  77710. private _originalValue;
  77711. /**
  77712. * The original blend value of the runtime animation
  77713. */
  77714. private _originalBlendValue;
  77715. /**
  77716. * The offsets cache of the runtime animation
  77717. */
  77718. private _offsetsCache;
  77719. /**
  77720. * The high limits cache of the runtime animation
  77721. */
  77722. private _highLimitsCache;
  77723. /**
  77724. * Specifies if the runtime animation has been stopped
  77725. */
  77726. private _stopped;
  77727. /**
  77728. * The blending factor of the runtime animation
  77729. */
  77730. private _blendingFactor;
  77731. /**
  77732. * The BabylonJS scene
  77733. */
  77734. private _scene;
  77735. /**
  77736. * The current value of the runtime animation
  77737. */
  77738. private _currentValue;
  77739. /** @hidden */
  77740. _animationState: _IAnimationState;
  77741. /**
  77742. * The active target of the runtime animation
  77743. */
  77744. private _activeTargets;
  77745. private _currentActiveTarget;
  77746. private _directTarget;
  77747. /**
  77748. * The target path of the runtime animation
  77749. */
  77750. private _targetPath;
  77751. /**
  77752. * The weight of the runtime animation
  77753. */
  77754. private _weight;
  77755. /**
  77756. * The ratio offset of the runtime animation
  77757. */
  77758. private _ratioOffset;
  77759. /**
  77760. * The previous delay of the runtime animation
  77761. */
  77762. private _previousDelay;
  77763. /**
  77764. * The previous ratio of the runtime animation
  77765. */
  77766. private _previousRatio;
  77767. private _enableBlending;
  77768. private _keys;
  77769. private _minFrame;
  77770. private _maxFrame;
  77771. private _minValue;
  77772. private _maxValue;
  77773. private _targetIsArray;
  77774. /**
  77775. * Gets the current frame of the runtime animation
  77776. */
  77777. readonly currentFrame: number;
  77778. /**
  77779. * Gets the weight of the runtime animation
  77780. */
  77781. readonly weight: number;
  77782. /**
  77783. * Gets the current value of the runtime animation
  77784. */
  77785. readonly currentValue: any;
  77786. /**
  77787. * Gets the target path of the runtime animation
  77788. */
  77789. readonly targetPath: string;
  77790. /**
  77791. * Gets the actual target of the runtime animation
  77792. */
  77793. readonly target: any;
  77794. /** @hidden */
  77795. _onLoop: () => void;
  77796. /**
  77797. * Create a new RuntimeAnimation object
  77798. * @param target defines the target of the animation
  77799. * @param animation defines the source animation object
  77800. * @param scene defines the hosting scene
  77801. * @param host defines the initiating Animatable
  77802. */
  77803. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77804. private _preparePath;
  77805. /**
  77806. * Gets the animation from the runtime animation
  77807. */
  77808. readonly animation: Animation;
  77809. /**
  77810. * Resets the runtime animation to the beginning
  77811. * @param restoreOriginal defines whether to restore the target property to the original value
  77812. */
  77813. reset(restoreOriginal?: boolean): void;
  77814. /**
  77815. * Specifies if the runtime animation is stopped
  77816. * @returns Boolean specifying if the runtime animation is stopped
  77817. */
  77818. isStopped(): boolean;
  77819. /**
  77820. * Disposes of the runtime animation
  77821. */
  77822. dispose(): void;
  77823. /**
  77824. * Apply the interpolated value to the target
  77825. * @param currentValue defines the value computed by the animation
  77826. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77827. */
  77828. setValue(currentValue: any, weight: number): void;
  77829. private _getOriginalValues;
  77830. private _setValue;
  77831. /**
  77832. * Gets the loop pmode of the runtime animation
  77833. * @returns Loop Mode
  77834. */
  77835. private _getCorrectLoopMode;
  77836. /**
  77837. * Move the current animation to a given frame
  77838. * @param frame defines the frame to move to
  77839. */
  77840. goToFrame(frame: number): void;
  77841. /**
  77842. * @hidden Internal use only
  77843. */
  77844. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77845. /**
  77846. * Execute the current animation
  77847. * @param delay defines the delay to add to the current frame
  77848. * @param from defines the lower bound of the animation range
  77849. * @param to defines the upper bound of the animation range
  77850. * @param loop defines if the current animation must loop
  77851. * @param speedRatio defines the current speed ratio
  77852. * @param weight defines the weight of the animation (default is -1 so no weight)
  77853. * @param onLoop optional callback called when animation loops
  77854. * @returns a boolean indicating if the animation is running
  77855. */
  77856. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  77857. }
  77858. }
  77859. declare module BABYLON {
  77860. /**
  77861. * Class used to store an actual running animation
  77862. */
  77863. export class Animatable {
  77864. /** defines the target object */
  77865. target: any;
  77866. /** defines the starting frame number (default is 0) */
  77867. fromFrame: number;
  77868. /** defines the ending frame number (default is 100) */
  77869. toFrame: number;
  77870. /** defines if the animation must loop (default is false) */
  77871. loopAnimation: boolean;
  77872. /** defines a callback to call when animation ends if it is not looping */
  77873. onAnimationEnd?: (() => void) | null | undefined;
  77874. /** defines a callback to call when animation loops */
  77875. onAnimationLoop?: (() => void) | null | undefined;
  77876. private _localDelayOffset;
  77877. private _pausedDelay;
  77878. private _runtimeAnimations;
  77879. private _paused;
  77880. private _scene;
  77881. private _speedRatio;
  77882. private _weight;
  77883. private _syncRoot;
  77884. /**
  77885. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77886. * This will only apply for non looping animation (default is true)
  77887. */
  77888. disposeOnEnd: boolean;
  77889. /**
  77890. * Gets a boolean indicating if the animation has started
  77891. */
  77892. animationStarted: boolean;
  77893. /**
  77894. * Observer raised when the animation ends
  77895. */
  77896. onAnimationEndObservable: Observable<Animatable>;
  77897. /**
  77898. * Observer raised when the animation loops
  77899. */
  77900. onAnimationLoopObservable: Observable<Animatable>;
  77901. /**
  77902. * Gets the root Animatable used to synchronize and normalize animations
  77903. */
  77904. readonly syncRoot: Animatable;
  77905. /**
  77906. * Gets the current frame of the first RuntimeAnimation
  77907. * Used to synchronize Animatables
  77908. */
  77909. readonly masterFrame: number;
  77910. /**
  77911. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77912. */
  77913. weight: number;
  77914. /**
  77915. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77916. */
  77917. speedRatio: number;
  77918. /**
  77919. * Creates a new Animatable
  77920. * @param scene defines the hosting scene
  77921. * @param target defines the target object
  77922. * @param fromFrame defines the starting frame number (default is 0)
  77923. * @param toFrame defines the ending frame number (default is 100)
  77924. * @param loopAnimation defines if the animation must loop (default is false)
  77925. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77926. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77927. * @param animations defines a group of animation to add to the new Animatable
  77928. * @param onAnimationLoop defines a callback to call when animation loops
  77929. */
  77930. constructor(scene: Scene,
  77931. /** defines the target object */
  77932. target: any,
  77933. /** defines the starting frame number (default is 0) */
  77934. fromFrame?: number,
  77935. /** defines the ending frame number (default is 100) */
  77936. toFrame?: number,
  77937. /** defines if the animation must loop (default is false) */
  77938. loopAnimation?: boolean, speedRatio?: number,
  77939. /** defines a callback to call when animation ends if it is not looping */
  77940. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77941. /** defines a callback to call when animation loops */
  77942. onAnimationLoop?: (() => void) | null | undefined);
  77943. /**
  77944. * Synchronize and normalize current Animatable with a source Animatable
  77945. * This is useful when using animation weights and when animations are not of the same length
  77946. * @param root defines the root Animatable to synchronize with
  77947. * @returns the current Animatable
  77948. */
  77949. syncWith(root: Animatable): Animatable;
  77950. /**
  77951. * Gets the list of runtime animations
  77952. * @returns an array of RuntimeAnimation
  77953. */
  77954. getAnimations(): RuntimeAnimation[];
  77955. /**
  77956. * Adds more animations to the current animatable
  77957. * @param target defines the target of the animations
  77958. * @param animations defines the new animations to add
  77959. */
  77960. appendAnimations(target: any, animations: Animation[]): void;
  77961. /**
  77962. * Gets the source animation for a specific property
  77963. * @param property defines the propertyu to look for
  77964. * @returns null or the source animation for the given property
  77965. */
  77966. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77967. /**
  77968. * Gets the runtime animation for a specific property
  77969. * @param property defines the propertyu to look for
  77970. * @returns null or the runtime animation for the given property
  77971. */
  77972. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77973. /**
  77974. * Resets the animatable to its original state
  77975. */
  77976. reset(): void;
  77977. /**
  77978. * Allows the animatable to blend with current running animations
  77979. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77980. * @param blendingSpeed defines the blending speed to use
  77981. */
  77982. enableBlending(blendingSpeed: number): void;
  77983. /**
  77984. * Disable animation blending
  77985. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77986. */
  77987. disableBlending(): void;
  77988. /**
  77989. * Jump directly to a given frame
  77990. * @param frame defines the frame to jump to
  77991. */
  77992. goToFrame(frame: number): void;
  77993. /**
  77994. * Pause the animation
  77995. */
  77996. pause(): void;
  77997. /**
  77998. * Restart the animation
  77999. */
  78000. restart(): void;
  78001. private _raiseOnAnimationEnd;
  78002. /**
  78003. * Stop and delete the current animation
  78004. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78005. * @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)
  78006. */
  78007. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78008. /**
  78009. * Wait asynchronously for the animation to end
  78010. * @returns a promise which will be fullfilled when the animation ends
  78011. */
  78012. waitAsync(): Promise<Animatable>;
  78013. /** @hidden */
  78014. _animate(delay: number): boolean;
  78015. }
  78016. interface Scene {
  78017. /** @hidden */
  78018. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78019. /** @hidden */
  78020. _processLateAnimationBindingsForMatrices(holder: {
  78021. totalWeight: number;
  78022. animations: RuntimeAnimation[];
  78023. originalValue: Matrix;
  78024. }): any;
  78025. /** @hidden */
  78026. _processLateAnimationBindingsForQuaternions(holder: {
  78027. totalWeight: number;
  78028. animations: RuntimeAnimation[];
  78029. originalValue: Quaternion;
  78030. }, refQuaternion: Quaternion): Quaternion;
  78031. /** @hidden */
  78032. _processLateAnimationBindings(): void;
  78033. /**
  78034. * Will start the animation sequence of a given target
  78035. * @param target defines the target
  78036. * @param from defines from which frame should animation start
  78037. * @param to defines until which frame should animation run.
  78038. * @param weight defines the weight to apply to the animation (1.0 by default)
  78039. * @param loop defines if the animation loops
  78040. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78041. * @param onAnimationEnd defines the function to be executed when the animation ends
  78042. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78043. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78044. * @param onAnimationLoop defines the callback to call when an animation loops
  78045. * @returns the animatable object created for this animation
  78046. */
  78047. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78048. /**
  78049. * Will start the animation sequence of a given target
  78050. * @param target defines the target
  78051. * @param from defines from which frame should animation start
  78052. * @param to defines until which frame should animation run.
  78053. * @param loop defines if the animation loops
  78054. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78055. * @param onAnimationEnd defines the function to be executed when the animation ends
  78056. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78057. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78058. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78059. * @param onAnimationLoop defines the callback to call when an animation loops
  78060. * @returns the animatable object created for this animation
  78061. */
  78062. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78063. /**
  78064. * Will start the animation sequence of a given target and its hierarchy
  78065. * @param target defines the target
  78066. * @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.
  78067. * @param from defines from which frame should animation start
  78068. * @param to defines until which frame should animation run.
  78069. * @param loop defines if the animation loops
  78070. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78071. * @param onAnimationEnd defines the function to be executed when the animation ends
  78072. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78073. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78074. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78075. * @param onAnimationLoop defines the callback to call when an animation loops
  78076. * @returns the list of created animatables
  78077. */
  78078. 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[];
  78079. /**
  78080. * Begin a new animation on a given node
  78081. * @param target defines the target where the animation will take place
  78082. * @param animations defines the list of animations to start
  78083. * @param from defines the initial value
  78084. * @param to defines the final value
  78085. * @param loop defines if you want animation to loop (off by default)
  78086. * @param speedRatio defines the speed ratio to apply to all animations
  78087. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78088. * @param onAnimationLoop defines the callback to call when an animation loops
  78089. * @returns the list of created animatables
  78090. */
  78091. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78092. /**
  78093. * Begin a new animation on a given node and its hierarchy
  78094. * @param target defines the root node where the animation will take place
  78095. * @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.
  78096. * @param animations defines the list of animations to start
  78097. * @param from defines the initial value
  78098. * @param to defines the final value
  78099. * @param loop defines if you want animation to loop (off by default)
  78100. * @param speedRatio defines the speed ratio to apply to all animations
  78101. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78102. * @param onAnimationLoop defines the callback to call when an animation loops
  78103. * @returns the list of animatables created for all nodes
  78104. */
  78105. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78106. /**
  78107. * Gets the animatable associated with a specific target
  78108. * @param target defines the target of the animatable
  78109. * @returns the required animatable if found
  78110. */
  78111. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78112. /**
  78113. * Gets all animatables associated with a given target
  78114. * @param target defines the target to look animatables for
  78115. * @returns an array of Animatables
  78116. */
  78117. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78118. /**
  78119. * Will stop the animation of the given target
  78120. * @param target - the target
  78121. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  78122. * @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)
  78123. */
  78124. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  78125. /**
  78126. * Stops and removes all animations that have been applied to the scene
  78127. */
  78128. stopAllAnimations(): void;
  78129. }
  78130. interface Bone {
  78131. /**
  78132. * Copy an animation range from another bone
  78133. * @param source defines the source bone
  78134. * @param rangeName defines the range name to copy
  78135. * @param frameOffset defines the frame offset
  78136. * @param rescaleAsRequired defines if rescaling must be applied if required
  78137. * @param skelDimensionsRatio defines the scaling ratio
  78138. * @returns true if operation was successful
  78139. */
  78140. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78141. }
  78142. }
  78143. declare module BABYLON {
  78144. /**
  78145. * Class used to handle skinning animations
  78146. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78147. */
  78148. export class Skeleton implements IAnimatable {
  78149. /** defines the skeleton name */
  78150. name: string;
  78151. /** defines the skeleton Id */
  78152. id: string;
  78153. /**
  78154. * Defines the list of child bones
  78155. */
  78156. bones: Bone[];
  78157. /**
  78158. * Defines an estimate of the dimension of the skeleton at rest
  78159. */
  78160. dimensionsAtRest: Vector3;
  78161. /**
  78162. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78163. */
  78164. needInitialSkinMatrix: boolean;
  78165. /**
  78166. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78167. */
  78168. overrideMesh: Nullable<AbstractMesh>;
  78169. /**
  78170. * Gets the list of animations attached to this skeleton
  78171. */
  78172. animations: Array<Animation>;
  78173. private _scene;
  78174. private _isDirty;
  78175. private _transformMatrices;
  78176. private _transformMatrixTexture;
  78177. private _meshesWithPoseMatrix;
  78178. private _animatables;
  78179. private _identity;
  78180. private _synchronizedWithMesh;
  78181. private _ranges;
  78182. private _lastAbsoluteTransformsUpdateId;
  78183. private _canUseTextureForBones;
  78184. private _uniqueId;
  78185. /** @hidden */
  78186. _numBonesWithLinkedTransformNode: number;
  78187. /**
  78188. * Specifies if the skeleton should be serialized
  78189. */
  78190. doNotSerialize: boolean;
  78191. private _useTextureToStoreBoneMatrices;
  78192. /**
  78193. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78194. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  78195. */
  78196. useTextureToStoreBoneMatrices: boolean;
  78197. private _animationPropertiesOverride;
  78198. /**
  78199. * Gets or sets the animation properties override
  78200. */
  78201. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78202. /**
  78203. * List of inspectable custom properties (used by the Inspector)
  78204. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78205. */
  78206. inspectableCustomProperties: IInspectable[];
  78207. /**
  78208. * An observable triggered before computing the skeleton's matrices
  78209. */
  78210. onBeforeComputeObservable: Observable<Skeleton>;
  78211. /**
  78212. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78213. */
  78214. readonly isUsingTextureForMatrices: boolean;
  78215. /**
  78216. * Gets the unique ID of this skeleton
  78217. */
  78218. readonly uniqueId: number;
  78219. /**
  78220. * Creates a new skeleton
  78221. * @param name defines the skeleton name
  78222. * @param id defines the skeleton Id
  78223. * @param scene defines the hosting scene
  78224. */
  78225. constructor(
  78226. /** defines the skeleton name */
  78227. name: string,
  78228. /** defines the skeleton Id */
  78229. id: string, scene: Scene);
  78230. /**
  78231. * Gets the current object class name.
  78232. * @return the class name
  78233. */
  78234. getClassName(): string;
  78235. /**
  78236. * Returns an array containing the root bones
  78237. * @returns an array containing the root bones
  78238. */
  78239. getChildren(): Array<Bone>;
  78240. /**
  78241. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78242. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78243. * @returns a Float32Array containing matrices data
  78244. */
  78245. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78246. /**
  78247. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78248. * @returns a raw texture containing the data
  78249. */
  78250. getTransformMatrixTexture(): Nullable<RawTexture>;
  78251. /**
  78252. * Gets the current hosting scene
  78253. * @returns a scene object
  78254. */
  78255. getScene(): Scene;
  78256. /**
  78257. * Gets a string representing the current skeleton data
  78258. * @param fullDetails defines a boolean indicating if we want a verbose version
  78259. * @returns a string representing the current skeleton data
  78260. */
  78261. toString(fullDetails?: boolean): string;
  78262. /**
  78263. * Get bone's index searching by name
  78264. * @param name defines bone's name to search for
  78265. * @return the indice of the bone. Returns -1 if not found
  78266. */
  78267. getBoneIndexByName(name: string): number;
  78268. /**
  78269. * Creater a new animation range
  78270. * @param name defines the name of the range
  78271. * @param from defines the start key
  78272. * @param to defines the end key
  78273. */
  78274. createAnimationRange(name: string, from: number, to: number): void;
  78275. /**
  78276. * Delete a specific animation range
  78277. * @param name defines the name of the range
  78278. * @param deleteFrames defines if frames must be removed as well
  78279. */
  78280. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78281. /**
  78282. * Gets a specific animation range
  78283. * @param name defines the name of the range to look for
  78284. * @returns the requested animation range or null if not found
  78285. */
  78286. getAnimationRange(name: string): Nullable<AnimationRange>;
  78287. /**
  78288. * Gets the list of all animation ranges defined on this skeleton
  78289. * @returns an array
  78290. */
  78291. getAnimationRanges(): Nullable<AnimationRange>[];
  78292. /**
  78293. * Copy animation range from a source skeleton.
  78294. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78295. * @param source defines the source skeleton
  78296. * @param name defines the name of the range to copy
  78297. * @param rescaleAsRequired defines if rescaling must be applied if required
  78298. * @returns true if operation was successful
  78299. */
  78300. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78301. /**
  78302. * Forces the skeleton to go to rest pose
  78303. */
  78304. returnToRest(): void;
  78305. private _getHighestAnimationFrame;
  78306. /**
  78307. * Begin a specific animation range
  78308. * @param name defines the name of the range to start
  78309. * @param loop defines if looping must be turned on (false by default)
  78310. * @param speedRatio defines the speed ratio to apply (1 by default)
  78311. * @param onAnimationEnd defines a callback which will be called when animation will end
  78312. * @returns a new animatable
  78313. */
  78314. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78315. /** @hidden */
  78316. _markAsDirty(): void;
  78317. /** @hidden */
  78318. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78319. /** @hidden */
  78320. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78321. private _computeTransformMatrices;
  78322. /**
  78323. * Build all resources required to render a skeleton
  78324. */
  78325. prepare(): void;
  78326. /**
  78327. * Gets the list of animatables currently running for this skeleton
  78328. * @returns an array of animatables
  78329. */
  78330. getAnimatables(): IAnimatable[];
  78331. /**
  78332. * Clone the current skeleton
  78333. * @param name defines the name of the new skeleton
  78334. * @param id defines the id of the enw skeleton
  78335. * @returns the new skeleton
  78336. */
  78337. clone(name: string, id: string): Skeleton;
  78338. /**
  78339. * Enable animation blending for this skeleton
  78340. * @param blendingSpeed defines the blending speed to apply
  78341. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78342. */
  78343. enableBlending(blendingSpeed?: number): void;
  78344. /**
  78345. * Releases all resources associated with the current skeleton
  78346. */
  78347. dispose(): void;
  78348. /**
  78349. * Serialize the skeleton in a JSON object
  78350. * @returns a JSON object
  78351. */
  78352. serialize(): any;
  78353. /**
  78354. * Creates a new skeleton from serialized data
  78355. * @param parsedSkeleton defines the serialized data
  78356. * @param scene defines the hosting scene
  78357. * @returns a new skeleton
  78358. */
  78359. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78360. /**
  78361. * Compute all node absolute transforms
  78362. * @param forceUpdate defines if computation must be done even if cache is up to date
  78363. */
  78364. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78365. /**
  78366. * Gets the root pose matrix
  78367. * @returns a matrix
  78368. */
  78369. getPoseMatrix(): Nullable<Matrix>;
  78370. /**
  78371. * Sorts bones per internal index
  78372. */
  78373. sortBones(): void;
  78374. private _sortBones;
  78375. }
  78376. }
  78377. declare module BABYLON {
  78378. /**
  78379. * Defines a target to use with MorphTargetManager
  78380. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78381. */
  78382. export class MorphTarget implements IAnimatable {
  78383. /** defines the name of the target */
  78384. name: string;
  78385. /**
  78386. * Gets or sets the list of animations
  78387. */
  78388. animations: Animation[];
  78389. private _scene;
  78390. private _positions;
  78391. private _normals;
  78392. private _tangents;
  78393. private _influence;
  78394. /**
  78395. * Observable raised when the influence changes
  78396. */
  78397. onInfluenceChanged: Observable<boolean>;
  78398. /** @hidden */
  78399. _onDataLayoutChanged: Observable<void>;
  78400. /**
  78401. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  78402. */
  78403. influence: number;
  78404. /**
  78405. * Gets or sets the id of the morph Target
  78406. */
  78407. id: string;
  78408. private _animationPropertiesOverride;
  78409. /**
  78410. * Gets or sets the animation properties override
  78411. */
  78412. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78413. /**
  78414. * Creates a new MorphTarget
  78415. * @param name defines the name of the target
  78416. * @param influence defines the influence to use
  78417. * @param scene defines the scene the morphtarget belongs to
  78418. */
  78419. constructor(
  78420. /** defines the name of the target */
  78421. name: string, influence?: number, scene?: Nullable<Scene>);
  78422. /**
  78423. * Gets a boolean defining if the target contains position data
  78424. */
  78425. readonly hasPositions: boolean;
  78426. /**
  78427. * Gets a boolean defining if the target contains normal data
  78428. */
  78429. readonly hasNormals: boolean;
  78430. /**
  78431. * Gets a boolean defining if the target contains tangent data
  78432. */
  78433. readonly hasTangents: boolean;
  78434. /**
  78435. * Affects position data to this target
  78436. * @param data defines the position data to use
  78437. */
  78438. setPositions(data: Nullable<FloatArray>): void;
  78439. /**
  78440. * Gets the position data stored in this target
  78441. * @returns a FloatArray containing the position data (or null if not present)
  78442. */
  78443. getPositions(): Nullable<FloatArray>;
  78444. /**
  78445. * Affects normal data to this target
  78446. * @param data defines the normal data to use
  78447. */
  78448. setNormals(data: Nullable<FloatArray>): void;
  78449. /**
  78450. * Gets the normal data stored in this target
  78451. * @returns a FloatArray containing the normal data (or null if not present)
  78452. */
  78453. getNormals(): Nullable<FloatArray>;
  78454. /**
  78455. * Affects tangent data to this target
  78456. * @param data defines the tangent data to use
  78457. */
  78458. setTangents(data: Nullable<FloatArray>): void;
  78459. /**
  78460. * Gets the tangent data stored in this target
  78461. * @returns a FloatArray containing the tangent data (or null if not present)
  78462. */
  78463. getTangents(): Nullable<FloatArray>;
  78464. /**
  78465. * Serializes the current target into a Serialization object
  78466. * @returns the serialized object
  78467. */
  78468. serialize(): any;
  78469. /**
  78470. * Returns the string "MorphTarget"
  78471. * @returns "MorphTarget"
  78472. */
  78473. getClassName(): string;
  78474. /**
  78475. * Creates a new target from serialized data
  78476. * @param serializationObject defines the serialized data to use
  78477. * @returns a new MorphTarget
  78478. */
  78479. static Parse(serializationObject: any): MorphTarget;
  78480. /**
  78481. * Creates a MorphTarget from mesh data
  78482. * @param mesh defines the source mesh
  78483. * @param name defines the name to use for the new target
  78484. * @param influence defines the influence to attach to the target
  78485. * @returns a new MorphTarget
  78486. */
  78487. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  78488. }
  78489. }
  78490. declare module BABYLON {
  78491. /**
  78492. * This class is used to deform meshes using morphing between different targets
  78493. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78494. */
  78495. export class MorphTargetManager {
  78496. private _targets;
  78497. private _targetInfluenceChangedObservers;
  78498. private _targetDataLayoutChangedObservers;
  78499. private _activeTargets;
  78500. private _scene;
  78501. private _influences;
  78502. private _supportsNormals;
  78503. private _supportsTangents;
  78504. private _vertexCount;
  78505. private _uniqueId;
  78506. private _tempInfluences;
  78507. /**
  78508. * Creates a new MorphTargetManager
  78509. * @param scene defines the current scene
  78510. */
  78511. constructor(scene?: Nullable<Scene>);
  78512. /**
  78513. * Gets the unique ID of this manager
  78514. */
  78515. readonly uniqueId: number;
  78516. /**
  78517. * Gets the number of vertices handled by this manager
  78518. */
  78519. readonly vertexCount: number;
  78520. /**
  78521. * Gets a boolean indicating if this manager supports morphing of normals
  78522. */
  78523. readonly supportsNormals: boolean;
  78524. /**
  78525. * Gets a boolean indicating if this manager supports morphing of tangents
  78526. */
  78527. readonly supportsTangents: boolean;
  78528. /**
  78529. * Gets the number of targets stored in this manager
  78530. */
  78531. readonly numTargets: number;
  78532. /**
  78533. * Gets the number of influencers (ie. the number of targets with influences > 0)
  78534. */
  78535. readonly numInfluencers: number;
  78536. /**
  78537. * Gets the list of influences (one per target)
  78538. */
  78539. readonly influences: Float32Array;
  78540. /**
  78541. * Gets the active target at specified index. An active target is a target with an influence > 0
  78542. * @param index defines the index to check
  78543. * @returns the requested target
  78544. */
  78545. getActiveTarget(index: number): MorphTarget;
  78546. /**
  78547. * Gets the target at specified index
  78548. * @param index defines the index to check
  78549. * @returns the requested target
  78550. */
  78551. getTarget(index: number): MorphTarget;
  78552. /**
  78553. * Add a new target to this manager
  78554. * @param target defines the target to add
  78555. */
  78556. addTarget(target: MorphTarget): void;
  78557. /**
  78558. * Removes a target from the manager
  78559. * @param target defines the target to remove
  78560. */
  78561. removeTarget(target: MorphTarget): void;
  78562. /**
  78563. * Serializes the current manager into a Serialization object
  78564. * @returns the serialized object
  78565. */
  78566. serialize(): any;
  78567. private _syncActiveTargets;
  78568. /**
  78569. * Syncrhonize the targets with all the meshes using this morph target manager
  78570. */
  78571. synchronize(): void;
  78572. /**
  78573. * Creates a new MorphTargetManager from serialized data
  78574. * @param serializationObject defines the serialized data
  78575. * @param scene defines the hosting scene
  78576. * @returns the new MorphTargetManager
  78577. */
  78578. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  78579. }
  78580. }
  78581. declare module BABYLON {
  78582. /**
  78583. * Mesh representing the gorund
  78584. */
  78585. export class GroundMesh extends Mesh {
  78586. /** If octree should be generated */
  78587. generateOctree: boolean;
  78588. private _heightQuads;
  78589. /** @hidden */
  78590. _subdivisionsX: number;
  78591. /** @hidden */
  78592. _subdivisionsY: number;
  78593. /** @hidden */
  78594. _width: number;
  78595. /** @hidden */
  78596. _height: number;
  78597. /** @hidden */
  78598. _minX: number;
  78599. /** @hidden */
  78600. _maxX: number;
  78601. /** @hidden */
  78602. _minZ: number;
  78603. /** @hidden */
  78604. _maxZ: number;
  78605. constructor(name: string, scene: Scene);
  78606. /**
  78607. * "GroundMesh"
  78608. * @returns "GroundMesh"
  78609. */
  78610. getClassName(): string;
  78611. /**
  78612. * The minimum of x and y subdivisions
  78613. */
  78614. readonly subdivisions: number;
  78615. /**
  78616. * X subdivisions
  78617. */
  78618. readonly subdivisionsX: number;
  78619. /**
  78620. * Y subdivisions
  78621. */
  78622. readonly subdivisionsY: number;
  78623. /**
  78624. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  78625. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  78626. * @param chunksCount the number of subdivisions for x and y
  78627. * @param octreeBlocksSize (Default: 32)
  78628. */
  78629. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  78630. /**
  78631. * Returns a height (y) value in the Worl system :
  78632. * the ground altitude at the coordinates (x, z) expressed in the World system.
  78633. * @param x x coordinate
  78634. * @param z z coordinate
  78635. * @returns the ground y position if (x, z) are outside the ground surface.
  78636. */
  78637. getHeightAtCoordinates(x: number, z: number): number;
  78638. /**
  78639. * Returns a normalized vector (Vector3) orthogonal to the ground
  78640. * at the ground coordinates (x, z) expressed in the World system.
  78641. * @param x x coordinate
  78642. * @param z z coordinate
  78643. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  78644. */
  78645. getNormalAtCoordinates(x: number, z: number): Vector3;
  78646. /**
  78647. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  78648. * at the ground coordinates (x, z) expressed in the World system.
  78649. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  78650. * @param x x coordinate
  78651. * @param z z coordinate
  78652. * @param ref vector to store the result
  78653. * @returns the GroundMesh.
  78654. */
  78655. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  78656. /**
  78657. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  78658. * if the ground has been updated.
  78659. * This can be used in the render loop.
  78660. * @returns the GroundMesh.
  78661. */
  78662. updateCoordinateHeights(): GroundMesh;
  78663. private _getFacetAt;
  78664. private _initHeightQuads;
  78665. private _computeHeightQuads;
  78666. /**
  78667. * Serializes this ground mesh
  78668. * @param serializationObject object to write serialization to
  78669. */
  78670. serialize(serializationObject: any): void;
  78671. /**
  78672. * Parses a serialized ground mesh
  78673. * @param parsedMesh the serialized mesh
  78674. * @param scene the scene to create the ground mesh in
  78675. * @returns the created ground mesh
  78676. */
  78677. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  78678. }
  78679. }
  78680. declare module BABYLON {
  78681. /**
  78682. * Interface for Physics-Joint data
  78683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78684. */
  78685. export interface PhysicsJointData {
  78686. /**
  78687. * The main pivot of the joint
  78688. */
  78689. mainPivot?: Vector3;
  78690. /**
  78691. * The connected pivot of the joint
  78692. */
  78693. connectedPivot?: Vector3;
  78694. /**
  78695. * The main axis of the joint
  78696. */
  78697. mainAxis?: Vector3;
  78698. /**
  78699. * The connected axis of the joint
  78700. */
  78701. connectedAxis?: Vector3;
  78702. /**
  78703. * The collision of the joint
  78704. */
  78705. collision?: boolean;
  78706. /**
  78707. * Native Oimo/Cannon/Energy data
  78708. */
  78709. nativeParams?: any;
  78710. }
  78711. /**
  78712. * This is a holder class for the physics joint created by the physics plugin
  78713. * It holds a set of functions to control the underlying joint
  78714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78715. */
  78716. export class PhysicsJoint {
  78717. /**
  78718. * The type of the physics joint
  78719. */
  78720. type: number;
  78721. /**
  78722. * The data for the physics joint
  78723. */
  78724. jointData: PhysicsJointData;
  78725. private _physicsJoint;
  78726. protected _physicsPlugin: IPhysicsEnginePlugin;
  78727. /**
  78728. * Initializes the physics joint
  78729. * @param type The type of the physics joint
  78730. * @param jointData The data for the physics joint
  78731. */
  78732. constructor(
  78733. /**
  78734. * The type of the physics joint
  78735. */
  78736. type: number,
  78737. /**
  78738. * The data for the physics joint
  78739. */
  78740. jointData: PhysicsJointData);
  78741. /**
  78742. * Gets the physics joint
  78743. */
  78744. /**
  78745. * Sets the physics joint
  78746. */
  78747. physicsJoint: any;
  78748. /**
  78749. * Sets the physics plugin
  78750. */
  78751. physicsPlugin: IPhysicsEnginePlugin;
  78752. /**
  78753. * Execute a function that is physics-plugin specific.
  78754. * @param {Function} func the function that will be executed.
  78755. * It accepts two parameters: the physics world and the physics joint
  78756. */
  78757. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  78758. /**
  78759. * Distance-Joint type
  78760. */
  78761. static DistanceJoint: number;
  78762. /**
  78763. * Hinge-Joint type
  78764. */
  78765. static HingeJoint: number;
  78766. /**
  78767. * Ball-and-Socket joint type
  78768. */
  78769. static BallAndSocketJoint: number;
  78770. /**
  78771. * Wheel-Joint type
  78772. */
  78773. static WheelJoint: number;
  78774. /**
  78775. * Slider-Joint type
  78776. */
  78777. static SliderJoint: number;
  78778. /**
  78779. * Prismatic-Joint type
  78780. */
  78781. static PrismaticJoint: number;
  78782. /**
  78783. * Universal-Joint type
  78784. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  78785. */
  78786. static UniversalJoint: number;
  78787. /**
  78788. * Hinge-Joint 2 type
  78789. */
  78790. static Hinge2Joint: number;
  78791. /**
  78792. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  78793. */
  78794. static PointToPointJoint: number;
  78795. /**
  78796. * Spring-Joint type
  78797. */
  78798. static SpringJoint: number;
  78799. /**
  78800. * Lock-Joint type
  78801. */
  78802. static LockJoint: number;
  78803. }
  78804. /**
  78805. * A class representing a physics distance joint
  78806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78807. */
  78808. export class DistanceJoint extends PhysicsJoint {
  78809. /**
  78810. *
  78811. * @param jointData The data for the Distance-Joint
  78812. */
  78813. constructor(jointData: DistanceJointData);
  78814. /**
  78815. * Update the predefined distance.
  78816. * @param maxDistance The maximum preferred distance
  78817. * @param minDistance The minimum preferred distance
  78818. */
  78819. updateDistance(maxDistance: number, minDistance?: number): void;
  78820. }
  78821. /**
  78822. * Represents a Motor-Enabled Joint
  78823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78824. */
  78825. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  78826. /**
  78827. * Initializes the Motor-Enabled Joint
  78828. * @param type The type of the joint
  78829. * @param jointData The physica joint data for the joint
  78830. */
  78831. constructor(type: number, jointData: PhysicsJointData);
  78832. /**
  78833. * Set the motor values.
  78834. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78835. * @param force the force to apply
  78836. * @param maxForce max force for this motor.
  78837. */
  78838. setMotor(force?: number, maxForce?: number): void;
  78839. /**
  78840. * Set the motor's limits.
  78841. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78842. * @param upperLimit The upper limit of the motor
  78843. * @param lowerLimit The lower limit of the motor
  78844. */
  78845. setLimit(upperLimit: number, lowerLimit?: number): void;
  78846. }
  78847. /**
  78848. * This class represents a single physics Hinge-Joint
  78849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78850. */
  78851. export class HingeJoint extends MotorEnabledJoint {
  78852. /**
  78853. * Initializes the Hinge-Joint
  78854. * @param jointData The joint data for the Hinge-Joint
  78855. */
  78856. constructor(jointData: PhysicsJointData);
  78857. /**
  78858. * Set the motor values.
  78859. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78860. * @param {number} force the force to apply
  78861. * @param {number} maxForce max force for this motor.
  78862. */
  78863. setMotor(force?: number, maxForce?: number): void;
  78864. /**
  78865. * Set the motor's limits.
  78866. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78867. * @param upperLimit The upper limit of the motor
  78868. * @param lowerLimit The lower limit of the motor
  78869. */
  78870. setLimit(upperLimit: number, lowerLimit?: number): void;
  78871. }
  78872. /**
  78873. * This class represents a dual hinge physics joint (same as wheel joint)
  78874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78875. */
  78876. export class Hinge2Joint extends MotorEnabledJoint {
  78877. /**
  78878. * Initializes the Hinge2-Joint
  78879. * @param jointData The joint data for the Hinge2-Joint
  78880. */
  78881. constructor(jointData: PhysicsJointData);
  78882. /**
  78883. * Set the motor values.
  78884. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78885. * @param {number} targetSpeed the speed the motor is to reach
  78886. * @param {number} maxForce max force for this motor.
  78887. * @param {motorIndex} the motor's index, 0 or 1.
  78888. */
  78889. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  78890. /**
  78891. * Set the motor limits.
  78892. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78893. * @param {number} upperLimit the upper limit
  78894. * @param {number} lowerLimit lower limit
  78895. * @param {motorIndex} the motor's index, 0 or 1.
  78896. */
  78897. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78898. }
  78899. /**
  78900. * Interface for a motor enabled joint
  78901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78902. */
  78903. export interface IMotorEnabledJoint {
  78904. /**
  78905. * Physics joint
  78906. */
  78907. physicsJoint: any;
  78908. /**
  78909. * Sets the motor of the motor-enabled joint
  78910. * @param force The force of the motor
  78911. * @param maxForce The maximum force of the motor
  78912. * @param motorIndex The index of the motor
  78913. */
  78914. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  78915. /**
  78916. * Sets the limit of the motor
  78917. * @param upperLimit The upper limit of the motor
  78918. * @param lowerLimit The lower limit of the motor
  78919. * @param motorIndex The index of the motor
  78920. */
  78921. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78922. }
  78923. /**
  78924. * Joint data for a Distance-Joint
  78925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78926. */
  78927. export interface DistanceJointData extends PhysicsJointData {
  78928. /**
  78929. * Max distance the 2 joint objects can be apart
  78930. */
  78931. maxDistance: number;
  78932. }
  78933. /**
  78934. * Joint data from a spring joint
  78935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78936. */
  78937. export interface SpringJointData extends PhysicsJointData {
  78938. /**
  78939. * Length of the spring
  78940. */
  78941. length: number;
  78942. /**
  78943. * Stiffness of the spring
  78944. */
  78945. stiffness: number;
  78946. /**
  78947. * Damping of the spring
  78948. */
  78949. damping: number;
  78950. /** this callback will be called when applying the force to the impostors. */
  78951. forceApplicationCallback: () => void;
  78952. }
  78953. }
  78954. declare module BABYLON {
  78955. /**
  78956. * Holds the data for the raycast result
  78957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78958. */
  78959. export class PhysicsRaycastResult {
  78960. private _hasHit;
  78961. private _hitDistance;
  78962. private _hitNormalWorld;
  78963. private _hitPointWorld;
  78964. private _rayFromWorld;
  78965. private _rayToWorld;
  78966. /**
  78967. * Gets if there was a hit
  78968. */
  78969. readonly hasHit: boolean;
  78970. /**
  78971. * Gets the distance from the hit
  78972. */
  78973. readonly hitDistance: number;
  78974. /**
  78975. * Gets the hit normal/direction in the world
  78976. */
  78977. readonly hitNormalWorld: Vector3;
  78978. /**
  78979. * Gets the hit point in the world
  78980. */
  78981. readonly hitPointWorld: Vector3;
  78982. /**
  78983. * Gets the ray "start point" of the ray in the world
  78984. */
  78985. readonly rayFromWorld: Vector3;
  78986. /**
  78987. * Gets the ray "end point" of the ray in the world
  78988. */
  78989. readonly rayToWorld: Vector3;
  78990. /**
  78991. * Sets the hit data (normal & point in world space)
  78992. * @param hitNormalWorld defines the normal in world space
  78993. * @param hitPointWorld defines the point in world space
  78994. */
  78995. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  78996. /**
  78997. * Sets the distance from the start point to the hit point
  78998. * @param distance
  78999. */
  79000. setHitDistance(distance: number): void;
  79001. /**
  79002. * Calculates the distance manually
  79003. */
  79004. calculateHitDistance(): void;
  79005. /**
  79006. * Resets all the values to default
  79007. * @param from The from point on world space
  79008. * @param to The to point on world space
  79009. */
  79010. reset(from?: Vector3, to?: Vector3): void;
  79011. }
  79012. /**
  79013. * Interface for the size containing width and height
  79014. */
  79015. interface IXYZ {
  79016. /**
  79017. * X
  79018. */
  79019. x: number;
  79020. /**
  79021. * Y
  79022. */
  79023. y: number;
  79024. /**
  79025. * Z
  79026. */
  79027. z: number;
  79028. }
  79029. }
  79030. declare module BABYLON {
  79031. /**
  79032. * Interface used to describe a physics joint
  79033. */
  79034. export interface PhysicsImpostorJoint {
  79035. /** Defines the main impostor to which the joint is linked */
  79036. mainImpostor: PhysicsImpostor;
  79037. /** Defines the impostor that is connected to the main impostor using this joint */
  79038. connectedImpostor: PhysicsImpostor;
  79039. /** Defines the joint itself */
  79040. joint: PhysicsJoint;
  79041. }
  79042. /** @hidden */
  79043. export interface IPhysicsEnginePlugin {
  79044. world: any;
  79045. name: string;
  79046. setGravity(gravity: Vector3): void;
  79047. setTimeStep(timeStep: number): void;
  79048. getTimeStep(): number;
  79049. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79050. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79051. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79052. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79053. removePhysicsBody(impostor: PhysicsImpostor): void;
  79054. generateJoint(joint: PhysicsImpostorJoint): void;
  79055. removeJoint(joint: PhysicsImpostorJoint): void;
  79056. isSupported(): boolean;
  79057. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  79058. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  79059. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79060. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79061. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79062. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79063. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  79064. getBodyMass(impostor: PhysicsImpostor): number;
  79065. getBodyFriction(impostor: PhysicsImpostor): number;
  79066. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  79067. getBodyRestitution(impostor: PhysicsImpostor): number;
  79068. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  79069. getBodyPressure?(impostor: PhysicsImpostor): number;
  79070. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  79071. getBodyStiffness?(impostor: PhysicsImpostor): number;
  79072. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  79073. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  79074. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  79075. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  79076. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  79077. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79078. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79079. sleepBody(impostor: PhysicsImpostor): void;
  79080. wakeUpBody(impostor: PhysicsImpostor): void;
  79081. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79082. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  79083. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  79084. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79085. getRadius(impostor: PhysicsImpostor): number;
  79086. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  79087. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  79088. dispose(): void;
  79089. }
  79090. /**
  79091. * Interface used to define a physics engine
  79092. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  79093. */
  79094. export interface IPhysicsEngine {
  79095. /**
  79096. * Gets the gravity vector used by the simulation
  79097. */
  79098. gravity: Vector3;
  79099. /**
  79100. * Sets the gravity vector used by the simulation
  79101. * @param gravity defines the gravity vector to use
  79102. */
  79103. setGravity(gravity: Vector3): void;
  79104. /**
  79105. * Set the time step of the physics engine.
  79106. * Default is 1/60.
  79107. * To slow it down, enter 1/600 for example.
  79108. * To speed it up, 1/30
  79109. * @param newTimeStep the new timestep to apply to this world.
  79110. */
  79111. setTimeStep(newTimeStep: number): void;
  79112. /**
  79113. * Get the time step of the physics engine.
  79114. * @returns the current time step
  79115. */
  79116. getTimeStep(): number;
  79117. /**
  79118. * Release all resources
  79119. */
  79120. dispose(): void;
  79121. /**
  79122. * Gets the name of the current physics plugin
  79123. * @returns the name of the plugin
  79124. */
  79125. getPhysicsPluginName(): string;
  79126. /**
  79127. * Adding a new impostor for the impostor tracking.
  79128. * This will be done by the impostor itself.
  79129. * @param impostor the impostor to add
  79130. */
  79131. addImpostor(impostor: PhysicsImpostor): void;
  79132. /**
  79133. * Remove an impostor from the engine.
  79134. * This impostor and its mesh will not longer be updated by the physics engine.
  79135. * @param impostor the impostor to remove
  79136. */
  79137. removeImpostor(impostor: PhysicsImpostor): void;
  79138. /**
  79139. * Add a joint to the physics engine
  79140. * @param mainImpostor defines the main impostor to which the joint is added.
  79141. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  79142. * @param joint defines the joint that will connect both impostors.
  79143. */
  79144. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79145. /**
  79146. * Removes a joint from the simulation
  79147. * @param mainImpostor defines the impostor used with the joint
  79148. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  79149. * @param joint defines the joint to remove
  79150. */
  79151. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79152. /**
  79153. * Gets the current plugin used to run the simulation
  79154. * @returns current plugin
  79155. */
  79156. getPhysicsPlugin(): IPhysicsEnginePlugin;
  79157. /**
  79158. * Gets the list of physic impostors
  79159. * @returns an array of PhysicsImpostor
  79160. */
  79161. getImpostors(): Array<PhysicsImpostor>;
  79162. /**
  79163. * Gets the impostor for a physics enabled object
  79164. * @param object defines the object impersonated by the impostor
  79165. * @returns the PhysicsImpostor or null if not found
  79166. */
  79167. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79168. /**
  79169. * Gets the impostor for a physics body object
  79170. * @param body defines physics body used by the impostor
  79171. * @returns the PhysicsImpostor or null if not found
  79172. */
  79173. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  79174. /**
  79175. * Does a raycast in the physics world
  79176. * @param from when should the ray start?
  79177. * @param to when should the ray end?
  79178. * @returns PhysicsRaycastResult
  79179. */
  79180. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79181. /**
  79182. * Called by the scene. No need to call it.
  79183. * @param delta defines the timespam between frames
  79184. */
  79185. _step(delta: number): void;
  79186. }
  79187. }
  79188. declare module BABYLON {
  79189. /**
  79190. * The interface for the physics imposter parameters
  79191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79192. */
  79193. export interface PhysicsImpostorParameters {
  79194. /**
  79195. * The mass of the physics imposter
  79196. */
  79197. mass: number;
  79198. /**
  79199. * The friction of the physics imposter
  79200. */
  79201. friction?: number;
  79202. /**
  79203. * The coefficient of restitution of the physics imposter
  79204. */
  79205. restitution?: number;
  79206. /**
  79207. * The native options of the physics imposter
  79208. */
  79209. nativeOptions?: any;
  79210. /**
  79211. * Specifies if the parent should be ignored
  79212. */
  79213. ignoreParent?: boolean;
  79214. /**
  79215. * Specifies if bi-directional transformations should be disabled
  79216. */
  79217. disableBidirectionalTransformation?: boolean;
  79218. /**
  79219. * The pressure inside the physics imposter, soft object only
  79220. */
  79221. pressure?: number;
  79222. /**
  79223. * The stiffness the physics imposter, soft object only
  79224. */
  79225. stiffness?: number;
  79226. /**
  79227. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  79228. */
  79229. velocityIterations?: number;
  79230. /**
  79231. * The number of iterations used in maintaining consistent vertex positions, soft object only
  79232. */
  79233. positionIterations?: number;
  79234. /**
  79235. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  79236. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  79237. * Add to fix multiple points
  79238. */
  79239. fixedPoints?: number;
  79240. /**
  79241. * The collision margin around a soft object
  79242. */
  79243. margin?: number;
  79244. /**
  79245. * The collision margin around a soft object
  79246. */
  79247. damping?: number;
  79248. /**
  79249. * The path for a rope based on an extrusion
  79250. */
  79251. path?: any;
  79252. /**
  79253. * The shape of an extrusion used for a rope based on an extrusion
  79254. */
  79255. shape?: any;
  79256. }
  79257. /**
  79258. * Interface for a physics-enabled object
  79259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79260. */
  79261. export interface IPhysicsEnabledObject {
  79262. /**
  79263. * The position of the physics-enabled object
  79264. */
  79265. position: Vector3;
  79266. /**
  79267. * The rotation of the physics-enabled object
  79268. */
  79269. rotationQuaternion: Nullable<Quaternion>;
  79270. /**
  79271. * The scale of the physics-enabled object
  79272. */
  79273. scaling: Vector3;
  79274. /**
  79275. * The rotation of the physics-enabled object
  79276. */
  79277. rotation?: Vector3;
  79278. /**
  79279. * The parent of the physics-enabled object
  79280. */
  79281. parent?: any;
  79282. /**
  79283. * The bounding info of the physics-enabled object
  79284. * @returns The bounding info of the physics-enabled object
  79285. */
  79286. getBoundingInfo(): BoundingInfo;
  79287. /**
  79288. * Computes the world matrix
  79289. * @param force Specifies if the world matrix should be computed by force
  79290. * @returns A world matrix
  79291. */
  79292. computeWorldMatrix(force: boolean): Matrix;
  79293. /**
  79294. * Gets the world matrix
  79295. * @returns A world matrix
  79296. */
  79297. getWorldMatrix?(): Matrix;
  79298. /**
  79299. * Gets the child meshes
  79300. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  79301. * @returns An array of abstract meshes
  79302. */
  79303. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  79304. /**
  79305. * Gets the vertex data
  79306. * @param kind The type of vertex data
  79307. * @returns A nullable array of numbers, or a float32 array
  79308. */
  79309. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  79310. /**
  79311. * Gets the indices from the mesh
  79312. * @returns A nullable array of index arrays
  79313. */
  79314. getIndices?(): Nullable<IndicesArray>;
  79315. /**
  79316. * Gets the scene from the mesh
  79317. * @returns the indices array or null
  79318. */
  79319. getScene?(): Scene;
  79320. /**
  79321. * Gets the absolute position from the mesh
  79322. * @returns the absolute position
  79323. */
  79324. getAbsolutePosition(): Vector3;
  79325. /**
  79326. * Gets the absolute pivot point from the mesh
  79327. * @returns the absolute pivot point
  79328. */
  79329. getAbsolutePivotPoint(): Vector3;
  79330. /**
  79331. * Rotates the mesh
  79332. * @param axis The axis of rotation
  79333. * @param amount The amount of rotation
  79334. * @param space The space of the rotation
  79335. * @returns The rotation transform node
  79336. */
  79337. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79338. /**
  79339. * Translates the mesh
  79340. * @param axis The axis of translation
  79341. * @param distance The distance of translation
  79342. * @param space The space of the translation
  79343. * @returns The transform node
  79344. */
  79345. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79346. /**
  79347. * Sets the absolute position of the mesh
  79348. * @param absolutePosition The absolute position of the mesh
  79349. * @returns The transform node
  79350. */
  79351. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79352. /**
  79353. * Gets the class name of the mesh
  79354. * @returns The class name
  79355. */
  79356. getClassName(): string;
  79357. }
  79358. /**
  79359. * Represents a physics imposter
  79360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79361. */
  79362. export class PhysicsImpostor {
  79363. /**
  79364. * The physics-enabled object used as the physics imposter
  79365. */
  79366. object: IPhysicsEnabledObject;
  79367. /**
  79368. * The type of the physics imposter
  79369. */
  79370. type: number;
  79371. private _options;
  79372. private _scene?;
  79373. /**
  79374. * The default object size of the imposter
  79375. */
  79376. static DEFAULT_OBJECT_SIZE: Vector3;
  79377. /**
  79378. * The identity quaternion of the imposter
  79379. */
  79380. static IDENTITY_QUATERNION: Quaternion;
  79381. /** @hidden */
  79382. _pluginData: any;
  79383. private _physicsEngine;
  79384. private _physicsBody;
  79385. private _bodyUpdateRequired;
  79386. private _onBeforePhysicsStepCallbacks;
  79387. private _onAfterPhysicsStepCallbacks;
  79388. /** @hidden */
  79389. _onPhysicsCollideCallbacks: Array<{
  79390. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  79391. otherImpostors: Array<PhysicsImpostor>;
  79392. }>;
  79393. private _deltaPosition;
  79394. private _deltaRotation;
  79395. private _deltaRotationConjugated;
  79396. /** hidden */
  79397. _isFromLine: boolean;
  79398. private _parent;
  79399. private _isDisposed;
  79400. private static _tmpVecs;
  79401. private static _tmpQuat;
  79402. /**
  79403. * Specifies if the physics imposter is disposed
  79404. */
  79405. readonly isDisposed: boolean;
  79406. /**
  79407. * Gets the mass of the physics imposter
  79408. */
  79409. mass: number;
  79410. /**
  79411. * Gets the coefficient of friction
  79412. */
  79413. /**
  79414. * Sets the coefficient of friction
  79415. */
  79416. friction: number;
  79417. /**
  79418. * Gets the coefficient of restitution
  79419. */
  79420. /**
  79421. * Sets the coefficient of restitution
  79422. */
  79423. restitution: number;
  79424. /**
  79425. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  79426. */
  79427. /**
  79428. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  79429. */
  79430. pressure: number;
  79431. /**
  79432. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79433. */
  79434. /**
  79435. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79436. */
  79437. stiffness: number;
  79438. /**
  79439. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79440. */
  79441. /**
  79442. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79443. */
  79444. velocityIterations: number;
  79445. /**
  79446. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79447. */
  79448. /**
  79449. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79450. */
  79451. positionIterations: number;
  79452. /**
  79453. * The unique id of the physics imposter
  79454. * set by the physics engine when adding this impostor to the array
  79455. */
  79456. uniqueId: number;
  79457. /**
  79458. * @hidden
  79459. */
  79460. soft: boolean;
  79461. /**
  79462. * @hidden
  79463. */
  79464. segments: number;
  79465. private _joints;
  79466. /**
  79467. * Initializes the physics imposter
  79468. * @param object The physics-enabled object used as the physics imposter
  79469. * @param type The type of the physics imposter
  79470. * @param _options The options for the physics imposter
  79471. * @param _scene The Babylon scene
  79472. */
  79473. constructor(
  79474. /**
  79475. * The physics-enabled object used as the physics imposter
  79476. */
  79477. object: IPhysicsEnabledObject,
  79478. /**
  79479. * The type of the physics imposter
  79480. */
  79481. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  79482. /**
  79483. * This function will completly initialize this impostor.
  79484. * It will create a new body - but only if this mesh has no parent.
  79485. * If it has, this impostor will not be used other than to define the impostor
  79486. * of the child mesh.
  79487. * @hidden
  79488. */
  79489. _init(): void;
  79490. private _getPhysicsParent;
  79491. /**
  79492. * Should a new body be generated.
  79493. * @returns boolean specifying if body initialization is required
  79494. */
  79495. isBodyInitRequired(): boolean;
  79496. /**
  79497. * Sets the updated scaling
  79498. * @param updated Specifies if the scaling is updated
  79499. */
  79500. setScalingUpdated(): void;
  79501. /**
  79502. * Force a regeneration of this or the parent's impostor's body.
  79503. * Use under cautious - This will remove all joints already implemented.
  79504. */
  79505. forceUpdate(): void;
  79506. /**
  79507. * Gets the body that holds this impostor. Either its own, or its parent.
  79508. */
  79509. /**
  79510. * Set the physics body. Used mainly by the physics engine/plugin
  79511. */
  79512. physicsBody: any;
  79513. /**
  79514. * Get the parent of the physics imposter
  79515. * @returns Physics imposter or null
  79516. */
  79517. /**
  79518. * Sets the parent of the physics imposter
  79519. */
  79520. parent: Nullable<PhysicsImpostor>;
  79521. /**
  79522. * Resets the update flags
  79523. */
  79524. resetUpdateFlags(): void;
  79525. /**
  79526. * Gets the object extend size
  79527. * @returns the object extend size
  79528. */
  79529. getObjectExtendSize(): Vector3;
  79530. /**
  79531. * Gets the object center
  79532. * @returns The object center
  79533. */
  79534. getObjectCenter(): Vector3;
  79535. /**
  79536. * Get a specific parametes from the options parameter
  79537. * @param paramName The object parameter name
  79538. * @returns The object parameter
  79539. */
  79540. getParam(paramName: string): any;
  79541. /**
  79542. * Sets a specific parameter in the options given to the physics plugin
  79543. * @param paramName The parameter name
  79544. * @param value The value of the parameter
  79545. */
  79546. setParam(paramName: string, value: number): void;
  79547. /**
  79548. * Specifically change the body's mass option. Won't recreate the physics body object
  79549. * @param mass The mass of the physics imposter
  79550. */
  79551. setMass(mass: number): void;
  79552. /**
  79553. * Gets the linear velocity
  79554. * @returns linear velocity or null
  79555. */
  79556. getLinearVelocity(): Nullable<Vector3>;
  79557. /**
  79558. * Sets the linear velocity
  79559. * @param velocity linear velocity or null
  79560. */
  79561. setLinearVelocity(velocity: Nullable<Vector3>): void;
  79562. /**
  79563. * Gets the angular velocity
  79564. * @returns angular velocity or null
  79565. */
  79566. getAngularVelocity(): Nullable<Vector3>;
  79567. /**
  79568. * Sets the angular velocity
  79569. * @param velocity The velocity or null
  79570. */
  79571. setAngularVelocity(velocity: Nullable<Vector3>): void;
  79572. /**
  79573. * Execute a function with the physics plugin native code
  79574. * Provide a function the will have two variables - the world object and the physics body object
  79575. * @param func The function to execute with the physics plugin native code
  79576. */
  79577. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  79578. /**
  79579. * Register a function that will be executed before the physics world is stepping forward
  79580. * @param func The function to execute before the physics world is stepped forward
  79581. */
  79582. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79583. /**
  79584. * Unregister a function that will be executed before the physics world is stepping forward
  79585. * @param func The function to execute before the physics world is stepped forward
  79586. */
  79587. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79588. /**
  79589. * Register a function that will be executed after the physics step
  79590. * @param func The function to execute after physics step
  79591. */
  79592. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79593. /**
  79594. * Unregisters a function that will be executed after the physics step
  79595. * @param func The function to execute after physics step
  79596. */
  79597. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79598. /**
  79599. * register a function that will be executed when this impostor collides against a different body
  79600. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  79601. * @param func Callback that is executed on collision
  79602. */
  79603. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  79604. /**
  79605. * Unregisters the physics imposter on contact
  79606. * @param collideAgainst The physics object to collide against
  79607. * @param func Callback to execute on collision
  79608. */
  79609. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  79610. private _tmpQuat;
  79611. private _tmpQuat2;
  79612. /**
  79613. * Get the parent rotation
  79614. * @returns The parent rotation
  79615. */
  79616. getParentsRotation(): Quaternion;
  79617. /**
  79618. * this function is executed by the physics engine.
  79619. */
  79620. beforeStep: () => void;
  79621. /**
  79622. * this function is executed by the physics engine
  79623. */
  79624. afterStep: () => void;
  79625. /**
  79626. * Legacy collision detection event support
  79627. */
  79628. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  79629. /**
  79630. * event and body object due to cannon's event-based architecture.
  79631. */
  79632. onCollide: (e: {
  79633. body: any;
  79634. }) => void;
  79635. /**
  79636. * Apply a force
  79637. * @param force The force to apply
  79638. * @param contactPoint The contact point for the force
  79639. * @returns The physics imposter
  79640. */
  79641. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79642. /**
  79643. * Apply an impulse
  79644. * @param force The impulse force
  79645. * @param contactPoint The contact point for the impulse force
  79646. * @returns The physics imposter
  79647. */
  79648. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79649. /**
  79650. * A help function to create a joint
  79651. * @param otherImpostor A physics imposter used to create a joint
  79652. * @param jointType The type of joint
  79653. * @param jointData The data for the joint
  79654. * @returns The physics imposter
  79655. */
  79656. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  79657. /**
  79658. * Add a joint to this impostor with a different impostor
  79659. * @param otherImpostor A physics imposter used to add a joint
  79660. * @param joint The joint to add
  79661. * @returns The physics imposter
  79662. */
  79663. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  79664. /**
  79665. * Add an anchor to a cloth impostor
  79666. * @param otherImpostor rigid impostor to anchor to
  79667. * @param width ratio across width from 0 to 1
  79668. * @param height ratio up height from 0 to 1
  79669. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  79670. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  79671. * @returns impostor the soft imposter
  79672. */
  79673. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79674. /**
  79675. * Add a hook to a rope impostor
  79676. * @param otherImpostor rigid impostor to anchor to
  79677. * @param length ratio across rope from 0 to 1
  79678. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  79679. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  79680. * @returns impostor the rope imposter
  79681. */
  79682. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79683. /**
  79684. * Will keep this body still, in a sleep mode.
  79685. * @returns the physics imposter
  79686. */
  79687. sleep(): PhysicsImpostor;
  79688. /**
  79689. * Wake the body up.
  79690. * @returns The physics imposter
  79691. */
  79692. wakeUp(): PhysicsImpostor;
  79693. /**
  79694. * Clones the physics imposter
  79695. * @param newObject The physics imposter clones to this physics-enabled object
  79696. * @returns A nullable physics imposter
  79697. */
  79698. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79699. /**
  79700. * Disposes the physics imposter
  79701. */
  79702. dispose(): void;
  79703. /**
  79704. * Sets the delta position
  79705. * @param position The delta position amount
  79706. */
  79707. setDeltaPosition(position: Vector3): void;
  79708. /**
  79709. * Sets the delta rotation
  79710. * @param rotation The delta rotation amount
  79711. */
  79712. setDeltaRotation(rotation: Quaternion): void;
  79713. /**
  79714. * Gets the box size of the physics imposter and stores the result in the input parameter
  79715. * @param result Stores the box size
  79716. * @returns The physics imposter
  79717. */
  79718. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  79719. /**
  79720. * Gets the radius of the physics imposter
  79721. * @returns Radius of the physics imposter
  79722. */
  79723. getRadius(): number;
  79724. /**
  79725. * Sync a bone with this impostor
  79726. * @param bone The bone to sync to the impostor.
  79727. * @param boneMesh The mesh that the bone is influencing.
  79728. * @param jointPivot The pivot of the joint / bone in local space.
  79729. * @param distToJoint Optional distance from the impostor to the joint.
  79730. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79731. */
  79732. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  79733. /**
  79734. * Sync impostor to a bone
  79735. * @param bone The bone that the impostor will be synced to.
  79736. * @param boneMesh The mesh that the bone is influencing.
  79737. * @param jointPivot The pivot of the joint / bone in local space.
  79738. * @param distToJoint Optional distance from the impostor to the joint.
  79739. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79740. * @param boneAxis Optional vector3 axis the bone is aligned with
  79741. */
  79742. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  79743. /**
  79744. * No-Imposter type
  79745. */
  79746. static NoImpostor: number;
  79747. /**
  79748. * Sphere-Imposter type
  79749. */
  79750. static SphereImpostor: number;
  79751. /**
  79752. * Box-Imposter type
  79753. */
  79754. static BoxImpostor: number;
  79755. /**
  79756. * Plane-Imposter type
  79757. */
  79758. static PlaneImpostor: number;
  79759. /**
  79760. * Mesh-imposter type
  79761. */
  79762. static MeshImpostor: number;
  79763. /**
  79764. * Cylinder-Imposter type
  79765. */
  79766. static CylinderImpostor: number;
  79767. /**
  79768. * Particle-Imposter type
  79769. */
  79770. static ParticleImpostor: number;
  79771. /**
  79772. * Heightmap-Imposter type
  79773. */
  79774. static HeightmapImpostor: number;
  79775. /**
  79776. * ConvexHull-Impostor type (Ammo.js plugin only)
  79777. */
  79778. static ConvexHullImpostor: number;
  79779. /**
  79780. * Rope-Imposter type
  79781. */
  79782. static RopeImpostor: number;
  79783. /**
  79784. * Cloth-Imposter type
  79785. */
  79786. static ClothImpostor: number;
  79787. /**
  79788. * Softbody-Imposter type
  79789. */
  79790. static SoftbodyImpostor: number;
  79791. }
  79792. }
  79793. declare module BABYLON {
  79794. /**
  79795. * Class used to represent a specific level of detail of a mesh
  79796. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79797. */
  79798. export class MeshLODLevel {
  79799. /** Defines the distance where this level should star being displayed */
  79800. distance: number;
  79801. /** Defines the mesh to use to render this level */
  79802. mesh: Nullable<Mesh>;
  79803. /**
  79804. * Creates a new LOD level
  79805. * @param distance defines the distance where this level should star being displayed
  79806. * @param mesh defines the mesh to use to render this level
  79807. */
  79808. constructor(
  79809. /** Defines the distance where this level should star being displayed */
  79810. distance: number,
  79811. /** Defines the mesh to use to render this level */
  79812. mesh: Nullable<Mesh>);
  79813. }
  79814. /**
  79815. * @hidden
  79816. **/
  79817. export class _CreationDataStorage {
  79818. closePath?: boolean;
  79819. closeArray?: boolean;
  79820. idx: number[];
  79821. dashSize: number;
  79822. gapSize: number;
  79823. path3D: Path3D;
  79824. pathArray: Vector3[][];
  79825. arc: number;
  79826. radius: number;
  79827. cap: number;
  79828. tessellation: number;
  79829. }
  79830. /**
  79831. * @hidden
  79832. **/
  79833. class _InstanceDataStorage {
  79834. visibleInstances: any;
  79835. batchCache: _InstancesBatch;
  79836. instancesBufferSize: number;
  79837. instancesBuffer: Nullable<Buffer>;
  79838. instancesData: Float32Array;
  79839. overridenInstanceCount: number;
  79840. isFrozen: boolean;
  79841. previousBatch: _InstancesBatch;
  79842. hardwareInstancedRendering: boolean;
  79843. sideOrientation: number;
  79844. }
  79845. /**
  79846. * @hidden
  79847. **/
  79848. export class _InstancesBatch {
  79849. mustReturn: boolean;
  79850. visibleInstances: Nullable<InstancedMesh[]>[];
  79851. renderSelf: boolean[];
  79852. hardwareInstancedRendering: boolean[];
  79853. }
  79854. /**
  79855. * Class used to represent renderable models
  79856. */
  79857. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  79858. /**
  79859. * Mesh side orientation : usually the external or front surface
  79860. */
  79861. static readonly FRONTSIDE: number;
  79862. /**
  79863. * Mesh side orientation : usually the internal or back surface
  79864. */
  79865. static readonly BACKSIDE: number;
  79866. /**
  79867. * Mesh side orientation : both internal and external or front and back surfaces
  79868. */
  79869. static readonly DOUBLESIDE: number;
  79870. /**
  79871. * Mesh side orientation : by default, `FRONTSIDE`
  79872. */
  79873. static readonly DEFAULTSIDE: number;
  79874. /**
  79875. * Mesh cap setting : no cap
  79876. */
  79877. static readonly NO_CAP: number;
  79878. /**
  79879. * Mesh cap setting : one cap at the beginning of the mesh
  79880. */
  79881. static readonly CAP_START: number;
  79882. /**
  79883. * Mesh cap setting : one cap at the end of the mesh
  79884. */
  79885. static readonly CAP_END: number;
  79886. /**
  79887. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  79888. */
  79889. static readonly CAP_ALL: number;
  79890. /**
  79891. * Gets the default side orientation.
  79892. * @param orientation the orientation to value to attempt to get
  79893. * @returns the default orientation
  79894. * @hidden
  79895. */
  79896. static _GetDefaultSideOrientation(orientation?: number): number;
  79897. private _onBeforeRenderObservable;
  79898. private _onBeforeBindObservable;
  79899. private _onAfterRenderObservable;
  79900. private _onBeforeDrawObservable;
  79901. /**
  79902. * An event triggered before rendering the mesh
  79903. */
  79904. readonly onBeforeRenderObservable: Observable<Mesh>;
  79905. /**
  79906. * An event triggered before binding the mesh
  79907. */
  79908. readonly onBeforeBindObservable: Observable<Mesh>;
  79909. /**
  79910. * An event triggered after rendering the mesh
  79911. */
  79912. readonly onAfterRenderObservable: Observable<Mesh>;
  79913. /**
  79914. * An event triggered before drawing the mesh
  79915. */
  79916. readonly onBeforeDrawObservable: Observable<Mesh>;
  79917. private _onBeforeDrawObserver;
  79918. /**
  79919. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  79920. */
  79921. onBeforeDraw: () => void;
  79922. /**
  79923. * Gets the delay loading state of the mesh (when delay loading is turned on)
  79924. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  79925. */
  79926. delayLoadState: number;
  79927. /**
  79928. * Gets the list of instances created from this mesh
  79929. * it is not supposed to be modified manually.
  79930. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  79931. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79932. */
  79933. instances: InstancedMesh[];
  79934. /**
  79935. * Gets the file containing delay loading data for this mesh
  79936. */
  79937. delayLoadingFile: string;
  79938. /** @hidden */
  79939. _binaryInfo: any;
  79940. private _LODLevels;
  79941. /**
  79942. * User defined function used to change how LOD level selection is done
  79943. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79944. */
  79945. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  79946. private _morphTargetManager;
  79947. /**
  79948. * Gets or sets the morph target manager
  79949. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79950. */
  79951. morphTargetManager: Nullable<MorphTargetManager>;
  79952. /** @hidden */
  79953. _creationDataStorage: Nullable<_CreationDataStorage>;
  79954. /** @hidden */
  79955. _geometry: Nullable<Geometry>;
  79956. /** @hidden */
  79957. _delayInfo: Array<string>;
  79958. /** @hidden */
  79959. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  79960. /** @hidden */
  79961. _instanceDataStorage: _InstanceDataStorage;
  79962. private _effectiveMaterial;
  79963. /** @hidden */
  79964. _shouldGenerateFlatShading: boolean;
  79965. private _preActivateId;
  79966. /** @hidden */
  79967. _originalBuilderSideOrientation: number;
  79968. /**
  79969. * Use this property to change the original side orientation defined at construction time
  79970. */
  79971. overrideMaterialSideOrientation: Nullable<number>;
  79972. private _areNormalsFrozen;
  79973. private _sourcePositions;
  79974. private _sourceNormals;
  79975. private _source;
  79976. private meshMap;
  79977. /**
  79978. * Gets the source mesh (the one used to clone this one from)
  79979. */
  79980. readonly source: Nullable<Mesh>;
  79981. /**
  79982. * Gets or sets a boolean indicating that this mesh does not use index buffer
  79983. */
  79984. isUnIndexed: boolean;
  79985. /**
  79986. * @constructor
  79987. * @param name The value used by scene.getMeshByName() to do a lookup.
  79988. * @param scene The scene to add this mesh to.
  79989. * @param parent The parent of this mesh, if it has one
  79990. * @param source An optional Mesh from which geometry is shared, cloned.
  79991. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79992. * When false, achieved by calling a clone(), also passing False.
  79993. * This will make creation of children, recursive.
  79994. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  79995. */
  79996. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  79997. /**
  79998. * Gets the class name
  79999. * @returns the string "Mesh".
  80000. */
  80001. getClassName(): string;
  80002. /** @hidden */
  80003. readonly _isMesh: boolean;
  80004. /**
  80005. * Returns a description of this mesh
  80006. * @param fullDetails define if full details about this mesh must be used
  80007. * @returns a descriptive string representing this mesh
  80008. */
  80009. toString(fullDetails?: boolean): string;
  80010. /** @hidden */
  80011. _unBindEffect(): void;
  80012. /**
  80013. * Gets a boolean indicating if this mesh has LOD
  80014. */
  80015. readonly hasLODLevels: boolean;
  80016. /**
  80017. * Gets the list of MeshLODLevel associated with the current mesh
  80018. * @returns an array of MeshLODLevel
  80019. */
  80020. getLODLevels(): MeshLODLevel[];
  80021. private _sortLODLevels;
  80022. /**
  80023. * Add a mesh as LOD level triggered at the given distance.
  80024. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80025. * @param distance The distance from the center of the object to show this level
  80026. * @param mesh The mesh to be added as LOD level (can be null)
  80027. * @return This mesh (for chaining)
  80028. */
  80029. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80030. /**
  80031. * Returns the LOD level mesh at the passed distance or null if not found.
  80032. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80033. * @param distance The distance from the center of the object to show this level
  80034. * @returns a Mesh or `null`
  80035. */
  80036. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80037. /**
  80038. * Remove a mesh from the LOD array
  80039. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80040. * @param mesh defines the mesh to be removed
  80041. * @return This mesh (for chaining)
  80042. */
  80043. removeLODLevel(mesh: Mesh): Mesh;
  80044. /**
  80045. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80046. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80047. * @param camera defines the camera to use to compute distance
  80048. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80049. * @return This mesh (for chaining)
  80050. */
  80051. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80052. /**
  80053. * Gets the mesh internal Geometry object
  80054. */
  80055. readonly geometry: Nullable<Geometry>;
  80056. /**
  80057. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80058. * @returns the total number of vertices
  80059. */
  80060. getTotalVertices(): number;
  80061. /**
  80062. * Returns the content of an associated vertex buffer
  80063. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80064. * - VertexBuffer.PositionKind
  80065. * - VertexBuffer.UVKind
  80066. * - VertexBuffer.UV2Kind
  80067. * - VertexBuffer.UV3Kind
  80068. * - VertexBuffer.UV4Kind
  80069. * - VertexBuffer.UV5Kind
  80070. * - VertexBuffer.UV6Kind
  80071. * - VertexBuffer.ColorKind
  80072. * - VertexBuffer.MatricesIndicesKind
  80073. * - VertexBuffer.MatricesIndicesExtraKind
  80074. * - VertexBuffer.MatricesWeightsKind
  80075. * - VertexBuffer.MatricesWeightsExtraKind
  80076. * @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
  80077. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80078. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80079. */
  80080. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80081. /**
  80082. * Returns the mesh VertexBuffer object from the requested `kind`
  80083. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80084. * - VertexBuffer.PositionKind
  80085. * - VertexBuffer.UVKind
  80086. * - VertexBuffer.UV2Kind
  80087. * - VertexBuffer.UV3Kind
  80088. * - VertexBuffer.UV4Kind
  80089. * - VertexBuffer.UV5Kind
  80090. * - VertexBuffer.UV6Kind
  80091. * - VertexBuffer.ColorKind
  80092. * - VertexBuffer.MatricesIndicesKind
  80093. * - VertexBuffer.MatricesIndicesExtraKind
  80094. * - VertexBuffer.MatricesWeightsKind
  80095. * - VertexBuffer.MatricesWeightsExtraKind
  80096. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80097. */
  80098. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80099. /**
  80100. * Tests if a specific vertex buffer is associated with this mesh
  80101. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80102. * - VertexBuffer.PositionKind
  80103. * - VertexBuffer.UVKind
  80104. * - VertexBuffer.UV2Kind
  80105. * - VertexBuffer.UV3Kind
  80106. * - VertexBuffer.UV4Kind
  80107. * - VertexBuffer.UV5Kind
  80108. * - VertexBuffer.UV6Kind
  80109. * - VertexBuffer.ColorKind
  80110. * - VertexBuffer.MatricesIndicesKind
  80111. * - VertexBuffer.MatricesIndicesExtraKind
  80112. * - VertexBuffer.MatricesWeightsKind
  80113. * - VertexBuffer.MatricesWeightsExtraKind
  80114. * @returns a boolean
  80115. */
  80116. isVerticesDataPresent(kind: string): boolean;
  80117. /**
  80118. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80119. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80120. * - VertexBuffer.PositionKind
  80121. * - VertexBuffer.UVKind
  80122. * - VertexBuffer.UV2Kind
  80123. * - VertexBuffer.UV3Kind
  80124. * - VertexBuffer.UV4Kind
  80125. * - VertexBuffer.UV5Kind
  80126. * - VertexBuffer.UV6Kind
  80127. * - VertexBuffer.ColorKind
  80128. * - VertexBuffer.MatricesIndicesKind
  80129. * - VertexBuffer.MatricesIndicesExtraKind
  80130. * - VertexBuffer.MatricesWeightsKind
  80131. * - VertexBuffer.MatricesWeightsExtraKind
  80132. * @returns a boolean
  80133. */
  80134. isVertexBufferUpdatable(kind: string): boolean;
  80135. /**
  80136. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80137. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80138. * - VertexBuffer.PositionKind
  80139. * - VertexBuffer.UVKind
  80140. * - VertexBuffer.UV2Kind
  80141. * - VertexBuffer.UV3Kind
  80142. * - VertexBuffer.UV4Kind
  80143. * - VertexBuffer.UV5Kind
  80144. * - VertexBuffer.UV6Kind
  80145. * - VertexBuffer.ColorKind
  80146. * - VertexBuffer.MatricesIndicesKind
  80147. * - VertexBuffer.MatricesIndicesExtraKind
  80148. * - VertexBuffer.MatricesWeightsKind
  80149. * - VertexBuffer.MatricesWeightsExtraKind
  80150. * @returns an array of strings
  80151. */
  80152. getVerticesDataKinds(): string[];
  80153. /**
  80154. * Returns a positive integer : the total number of indices in this mesh geometry.
  80155. * @returns the numner of indices or zero if the mesh has no geometry.
  80156. */
  80157. getTotalIndices(): number;
  80158. /**
  80159. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80160. * @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.
  80161. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80162. * @returns the indices array or an empty array if the mesh has no geometry
  80163. */
  80164. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80165. readonly isBlocked: boolean;
  80166. /**
  80167. * Determine if the current mesh is ready to be rendered
  80168. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80169. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  80170. * @returns true if all associated assets are ready (material, textures, shaders)
  80171. */
  80172. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  80173. /**
  80174. * 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.
  80175. */
  80176. readonly areNormalsFrozen: boolean;
  80177. /**
  80178. * 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.
  80179. * @returns the current mesh
  80180. */
  80181. freezeNormals(): Mesh;
  80182. /**
  80183. * 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
  80184. * @returns the current mesh
  80185. */
  80186. unfreezeNormals(): Mesh;
  80187. /**
  80188. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  80189. */
  80190. overridenInstanceCount: number;
  80191. /** @hidden */
  80192. _preActivate(): Mesh;
  80193. /** @hidden */
  80194. _preActivateForIntermediateRendering(renderId: number): Mesh;
  80195. /** @hidden */
  80196. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  80197. /**
  80198. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80199. * This means the mesh underlying bounding box and sphere are recomputed.
  80200. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80201. * @returns the current mesh
  80202. */
  80203. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  80204. /** @hidden */
  80205. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  80206. /**
  80207. * This function will subdivide the mesh into multiple submeshes
  80208. * @param count defines the expected number of submeshes
  80209. */
  80210. subdivide(count: number): void;
  80211. /**
  80212. * Copy a FloatArray into a specific associated vertex buffer
  80213. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80214. * - VertexBuffer.PositionKind
  80215. * - VertexBuffer.UVKind
  80216. * - VertexBuffer.UV2Kind
  80217. * - VertexBuffer.UV3Kind
  80218. * - VertexBuffer.UV4Kind
  80219. * - VertexBuffer.UV5Kind
  80220. * - VertexBuffer.UV6Kind
  80221. * - VertexBuffer.ColorKind
  80222. * - VertexBuffer.MatricesIndicesKind
  80223. * - VertexBuffer.MatricesIndicesExtraKind
  80224. * - VertexBuffer.MatricesWeightsKind
  80225. * - VertexBuffer.MatricesWeightsExtraKind
  80226. * @param data defines the data source
  80227. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80228. * @param stride defines the data stride size (can be null)
  80229. * @returns the current mesh
  80230. */
  80231. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  80232. /**
  80233. * Flags an associated vertex buffer as updatable
  80234. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  80235. * - VertexBuffer.PositionKind
  80236. * - VertexBuffer.UVKind
  80237. * - VertexBuffer.UV2Kind
  80238. * - VertexBuffer.UV3Kind
  80239. * - VertexBuffer.UV4Kind
  80240. * - VertexBuffer.UV5Kind
  80241. * - VertexBuffer.UV6Kind
  80242. * - VertexBuffer.ColorKind
  80243. * - VertexBuffer.MatricesIndicesKind
  80244. * - VertexBuffer.MatricesIndicesExtraKind
  80245. * - VertexBuffer.MatricesWeightsKind
  80246. * - VertexBuffer.MatricesWeightsExtraKind
  80247. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80248. */
  80249. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  80250. /**
  80251. * Sets the mesh global Vertex Buffer
  80252. * @param buffer defines the buffer to use
  80253. * @returns the current mesh
  80254. */
  80255. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  80256. /**
  80257. * Update a specific associated vertex buffer
  80258. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80259. * - VertexBuffer.PositionKind
  80260. * - VertexBuffer.UVKind
  80261. * - VertexBuffer.UV2Kind
  80262. * - VertexBuffer.UV3Kind
  80263. * - VertexBuffer.UV4Kind
  80264. * - VertexBuffer.UV5Kind
  80265. * - VertexBuffer.UV6Kind
  80266. * - VertexBuffer.ColorKind
  80267. * - VertexBuffer.MatricesIndicesKind
  80268. * - VertexBuffer.MatricesIndicesExtraKind
  80269. * - VertexBuffer.MatricesWeightsKind
  80270. * - VertexBuffer.MatricesWeightsExtraKind
  80271. * @param data defines the data source
  80272. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80273. * @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)
  80274. * @returns the current mesh
  80275. */
  80276. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  80277. /**
  80278. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  80279. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  80280. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  80281. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  80282. * @returns the current mesh
  80283. */
  80284. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  80285. /**
  80286. * Creates a un-shared specific occurence of the geometry for the mesh.
  80287. * @returns the current mesh
  80288. */
  80289. makeGeometryUnique(): Mesh;
  80290. /**
  80291. * Set the index buffer of this mesh
  80292. * @param indices defines the source data
  80293. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  80294. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  80295. * @returns the current mesh
  80296. */
  80297. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  80298. /**
  80299. * Update the current index buffer
  80300. * @param indices defines the source data
  80301. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  80302. * @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)
  80303. * @returns the current mesh
  80304. */
  80305. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  80306. /**
  80307. * Invert the geometry to move from a right handed system to a left handed one.
  80308. * @returns the current mesh
  80309. */
  80310. toLeftHanded(): Mesh;
  80311. /** @hidden */
  80312. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  80313. /** @hidden */
  80314. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  80315. /**
  80316. * Registers for this mesh a javascript function called just before the rendering process
  80317. * @param func defines the function to call before rendering this mesh
  80318. * @returns the current mesh
  80319. */
  80320. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80321. /**
  80322. * Disposes a previously registered javascript function called before the rendering
  80323. * @param func defines the function to remove
  80324. * @returns the current mesh
  80325. */
  80326. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80327. /**
  80328. * Registers for this mesh a javascript function called just after the rendering is complete
  80329. * @param func defines the function to call after rendering this mesh
  80330. * @returns the current mesh
  80331. */
  80332. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80333. /**
  80334. * Disposes a previously registered javascript function called after the rendering.
  80335. * @param func defines the function to remove
  80336. * @returns the current mesh
  80337. */
  80338. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80339. /** @hidden */
  80340. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80341. /** @hidden */
  80342. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80343. /** @hidden */
  80344. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80345. /** @hidden */
  80346. _freeze(): void;
  80347. /** @hidden */
  80348. _unFreeze(): void;
  80349. /**
  80350. * 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
  80351. * @param subMesh defines the subMesh to render
  80352. * @param enableAlphaMode defines if alpha mode can be changed
  80353. * @returns the current mesh
  80354. */
  80355. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80356. private _onBeforeDraw;
  80357. /**
  80358. * Renormalize the mesh and patch it up if there are no weights
  80359. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80360. * However in the case of zero weights then we set just a single influence to 1.
  80361. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80362. */
  80363. cleanMatrixWeights(): void;
  80364. private normalizeSkinFourWeights;
  80365. private normalizeSkinWeightsAndExtra;
  80366. /**
  80367. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80368. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80369. * the user know there was an issue with importing the mesh
  80370. * @returns a validation object with skinned, valid and report string
  80371. */
  80372. validateSkinning(): {
  80373. skinned: boolean;
  80374. valid: boolean;
  80375. report: string;
  80376. };
  80377. /** @hidden */
  80378. _checkDelayState(): Mesh;
  80379. private _queueLoad;
  80380. /**
  80381. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80382. * A mesh is in the frustum if its bounding box intersects the frustum
  80383. * @param frustumPlanes defines the frustum to test
  80384. * @returns true if the mesh is in the frustum planes
  80385. */
  80386. isInFrustum(frustumPlanes: Plane[]): boolean;
  80387. /**
  80388. * Sets the mesh material by the material or multiMaterial `id` property
  80389. * @param id is a string identifying the material or the multiMaterial
  80390. * @returns the current mesh
  80391. */
  80392. setMaterialByID(id: string): Mesh;
  80393. /**
  80394. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  80395. * @returns an array of IAnimatable
  80396. */
  80397. getAnimatables(): IAnimatable[];
  80398. /**
  80399. * Modifies the mesh geometry according to the passed transformation matrix.
  80400. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  80401. * The mesh normals are modified using the same transformation.
  80402. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80403. * @param transform defines the transform matrix to use
  80404. * @see http://doc.babylonjs.com/resources/baking_transformations
  80405. * @returns the current mesh
  80406. */
  80407. bakeTransformIntoVertices(transform: Matrix): Mesh;
  80408. /**
  80409. * Modifies the mesh geometry according to its own current World Matrix.
  80410. * The mesh World Matrix is then reset.
  80411. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  80412. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80413. * @see http://doc.babylonjs.com/resources/baking_transformations
  80414. * @returns the current mesh
  80415. */
  80416. bakeCurrentTransformIntoVertices(): Mesh;
  80417. /** @hidden */
  80418. readonly _positions: Nullable<Vector3[]>;
  80419. /** @hidden */
  80420. _resetPointsArrayCache(): Mesh;
  80421. /** @hidden */
  80422. _generatePointsArray(): boolean;
  80423. /**
  80424. * Returns a new Mesh object generated from the current mesh properties.
  80425. * This method must not get confused with createInstance()
  80426. * @param name is a string, the name given to the new mesh
  80427. * @param newParent can be any Node object (default `null`)
  80428. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  80429. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  80430. * @returns a new mesh
  80431. */
  80432. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  80433. /**
  80434. * Releases resources associated with this mesh.
  80435. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80436. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80437. */
  80438. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80439. /**
  80440. * Modifies the mesh geometry according to a displacement map.
  80441. * 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.
  80442. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80443. * @param url is a string, the URL from the image file is to be downloaded.
  80444. * @param minHeight is the lower limit of the displacement.
  80445. * @param maxHeight is the upper limit of the displacement.
  80446. * @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.
  80447. * @param uvOffset is an optional vector2 used to offset UV.
  80448. * @param uvScale is an optional vector2 used to scale UV.
  80449. * @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.
  80450. * @returns the Mesh.
  80451. */
  80452. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80453. /**
  80454. * Modifies the mesh geometry according to a displacementMap buffer.
  80455. * 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.
  80456. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80457. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  80458. * @param heightMapWidth is the width of the buffer image.
  80459. * @param heightMapHeight is the height of the buffer image.
  80460. * @param minHeight is the lower limit of the displacement.
  80461. * @param maxHeight is the upper limit of the displacement.
  80462. * @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.
  80463. * @param uvOffset is an optional vector2 used to offset UV.
  80464. * @param uvScale is an optional vector2 used to scale UV.
  80465. * @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.
  80466. * @returns the Mesh.
  80467. */
  80468. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80469. /**
  80470. * Modify the mesh to get a flat shading rendering.
  80471. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  80472. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  80473. * @returns current mesh
  80474. */
  80475. convertToFlatShadedMesh(): Mesh;
  80476. /**
  80477. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  80478. * In other words, more vertices, no more indices and a single bigger VBO.
  80479. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  80480. * @returns current mesh
  80481. */
  80482. convertToUnIndexedMesh(): Mesh;
  80483. /**
  80484. * Inverses facet orientations.
  80485. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80486. * @param flipNormals will also inverts the normals
  80487. * @returns current mesh
  80488. */
  80489. flipFaces(flipNormals?: boolean): Mesh;
  80490. /**
  80491. * Increase the number of facets and hence vertices in a mesh
  80492. * Vertex normals are interpolated from existing vertex normals
  80493. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80494. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  80495. */
  80496. increaseVertices(numberPerEdge: number): void;
  80497. /**
  80498. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  80499. * This will undo any application of covertToFlatShadedMesh
  80500. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80501. */
  80502. forceSharedVertices(): void;
  80503. /** @hidden */
  80504. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  80505. /** @hidden */
  80506. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  80507. /**
  80508. * Creates a new InstancedMesh object from the mesh model.
  80509. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80510. * @param name defines the name of the new instance
  80511. * @returns a new InstancedMesh
  80512. */
  80513. createInstance(name: string): InstancedMesh;
  80514. /**
  80515. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  80516. * After this call, all the mesh instances have the same submeshes than the current mesh.
  80517. * @returns the current mesh
  80518. */
  80519. synchronizeInstances(): Mesh;
  80520. /**
  80521. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  80522. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  80523. * This should be used together with the simplification to avoid disappearing triangles.
  80524. * @param successCallback an optional success callback to be called after the optimization finished.
  80525. * @returns the current mesh
  80526. */
  80527. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  80528. /**
  80529. * Serialize current mesh
  80530. * @param serializationObject defines the object which will receive the serialization data
  80531. */
  80532. serialize(serializationObject: any): void;
  80533. /** @hidden */
  80534. _syncGeometryWithMorphTargetManager(): void;
  80535. /** @hidden */
  80536. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  80537. /**
  80538. * Returns a new Mesh object parsed from the source provided.
  80539. * @param parsedMesh is the source
  80540. * @param scene defines the hosting scene
  80541. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  80542. * @returns a new Mesh
  80543. */
  80544. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  80545. /**
  80546. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  80547. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80548. * @param name defines the name of the mesh to create
  80549. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  80550. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  80551. * @param closePath creates a seam between the first and the last points of each path of the path array
  80552. * @param offset is taken in account only if the `pathArray` is containing a single path
  80553. * @param scene defines the hosting scene
  80554. * @param updatable defines if the mesh must be flagged as updatable
  80555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80556. * @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)
  80557. * @returns a new Mesh
  80558. */
  80559. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80560. /**
  80561. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  80562. * @param name defines the name of the mesh to create
  80563. * @param radius sets the radius size (float) of the polygon (default 0.5)
  80564. * @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
  80565. * @param scene defines the hosting scene
  80566. * @param updatable defines if the mesh must be flagged as updatable
  80567. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80568. * @returns a new Mesh
  80569. */
  80570. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80571. /**
  80572. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  80573. * @param name defines the name of the mesh to create
  80574. * @param size sets the size (float) of each box side (default 1)
  80575. * @param scene defines the hosting scene
  80576. * @param updatable defines if the mesh must be flagged as updatable
  80577. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80578. * @returns a new Mesh
  80579. */
  80580. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80581. /**
  80582. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  80583. * @param name defines the name of the mesh to create
  80584. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80585. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80586. * @param scene defines the hosting scene
  80587. * @param updatable defines if the mesh must be flagged as updatable
  80588. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80589. * @returns a new Mesh
  80590. */
  80591. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80592. /**
  80593. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  80594. * @param name defines the name of the mesh to create
  80595. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80596. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80597. * @param scene defines the hosting scene
  80598. * @returns a new Mesh
  80599. */
  80600. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  80601. /**
  80602. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  80603. * @param name defines the name of the mesh to create
  80604. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  80605. * @param diameterTop set the top cap diameter (floats, default 1)
  80606. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  80607. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  80608. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  80609. * @param scene defines the hosting scene
  80610. * @param updatable defines if the mesh must be flagged as updatable
  80611. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80612. * @returns a new Mesh
  80613. */
  80614. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  80615. /**
  80616. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  80617. * @param name defines the name of the mesh to create
  80618. * @param diameter sets the diameter size (float) of the torus (default 1)
  80619. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  80620. * @param tessellation sets the number of torus sides (postive integer, default 16)
  80621. * @param scene defines the hosting scene
  80622. * @param updatable defines if the mesh must be flagged as updatable
  80623. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80624. * @returns a new Mesh
  80625. */
  80626. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80627. /**
  80628. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  80629. * @param name defines the name of the mesh to create
  80630. * @param radius sets the global radius size (float) of the torus knot (default 2)
  80631. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  80632. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  80633. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  80634. * @param p the number of windings on X axis (positive integers, default 2)
  80635. * @param q the number of windings on Y axis (positive integers, default 3)
  80636. * @param scene defines the hosting scene
  80637. * @param updatable defines if the mesh must be flagged as updatable
  80638. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80639. * @returns a new Mesh
  80640. */
  80641. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80642. /**
  80643. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  80644. * @param name defines the name of the mesh to create
  80645. * @param points is an array successive Vector3
  80646. * @param scene defines the hosting scene
  80647. * @param updatable defines if the mesh must be flagged as updatable
  80648. * @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).
  80649. * @returns a new Mesh
  80650. */
  80651. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  80652. /**
  80653. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  80654. * @param name defines the name of the mesh to create
  80655. * @param points is an array successive Vector3
  80656. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  80657. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  80658. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  80659. * @param scene defines the hosting scene
  80660. * @param updatable defines if the mesh must be flagged as updatable
  80661. * @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)
  80662. * @returns a new Mesh
  80663. */
  80664. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  80665. /**
  80666. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  80667. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  80668. * 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.
  80669. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80670. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80671. * Remember you can only change the shape positions, not their number when updating a polygon.
  80672. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  80673. * @param name defines the name of the mesh to create
  80674. * @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
  80675. * @param scene defines the hosting scene
  80676. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80677. * @param updatable defines if the mesh must be flagged as updatable
  80678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80679. * @param earcutInjection can be used to inject your own earcut reference
  80680. * @returns a new Mesh
  80681. */
  80682. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80683. /**
  80684. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  80685. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  80686. * @param name defines the name of the mesh to create
  80687. * @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
  80688. * @param depth defines the height of extrusion
  80689. * @param scene defines the hosting scene
  80690. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80691. * @param updatable defines if the mesh must be flagged as updatable
  80692. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80693. * @param earcutInjection can be used to inject your own earcut reference
  80694. * @returns a new Mesh
  80695. */
  80696. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80697. /**
  80698. * Creates an extruded shape mesh.
  80699. * 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
  80700. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80701. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80702. * @param name defines the name of the mesh to create
  80703. * @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
  80704. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80705. * @param scale is the value to scale the shape
  80706. * @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
  80707. * @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
  80708. * @param scene defines the hosting scene
  80709. * @param updatable defines if the mesh must be flagged as updatable
  80710. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80711. * @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)
  80712. * @returns a new Mesh
  80713. */
  80714. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80715. /**
  80716. * Creates an custom extruded shape mesh.
  80717. * The custom extrusion is a parametric shape.
  80718. * It has no predefined shape. Its final shape will depend on the input parameters.
  80719. * Please consider using the same method from the MeshBuilder class instead
  80720. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80721. * @param name defines the name of the mesh to create
  80722. * @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
  80723. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80724. * @param scaleFunction is a custom Javascript function called on each path point
  80725. * @param rotationFunction is a custom Javascript function called on each path point
  80726. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80727. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  80728. * @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
  80729. * @param scene defines the hosting scene
  80730. * @param updatable defines if the mesh must be flagged as updatable
  80731. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80732. * @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)
  80733. * @returns a new Mesh
  80734. */
  80735. 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;
  80736. /**
  80737. * Creates lathe mesh.
  80738. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  80739. * Please consider using the same method from the MeshBuilder class instead
  80740. * @param name defines the name of the mesh to create
  80741. * @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
  80742. * @param radius is the radius value of the lathe
  80743. * @param tessellation is the side number of the lathe.
  80744. * @param scene defines the hosting scene
  80745. * @param updatable defines if the mesh must be flagged as updatable
  80746. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80747. * @returns a new Mesh
  80748. */
  80749. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80750. /**
  80751. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  80752. * @param name defines the name of the mesh to create
  80753. * @param size sets the size (float) of both sides of the plane at once (default 1)
  80754. * @param scene defines the hosting scene
  80755. * @param updatable defines if the mesh must be flagged as updatable
  80756. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80757. * @returns a new Mesh
  80758. */
  80759. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80760. /**
  80761. * Creates a ground mesh.
  80762. * Please consider using the same method from the MeshBuilder class instead
  80763. * @param name defines the name of the mesh to create
  80764. * @param width set the width of the ground
  80765. * @param height set the height of the ground
  80766. * @param subdivisions sets the number of subdivisions per side
  80767. * @param scene defines the hosting scene
  80768. * @param updatable defines if the mesh must be flagged as updatable
  80769. * @returns a new Mesh
  80770. */
  80771. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  80772. /**
  80773. * Creates a tiled ground mesh.
  80774. * Please consider using the same method from the MeshBuilder class instead
  80775. * @param name defines the name of the mesh to create
  80776. * @param xmin set the ground minimum X coordinate
  80777. * @param zmin set the ground minimum Y coordinate
  80778. * @param xmax set the ground maximum X coordinate
  80779. * @param zmax set the ground maximum Z coordinate
  80780. * @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
  80781. * @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
  80782. * @param scene defines the hosting scene
  80783. * @param updatable defines if the mesh must be flagged as updatable
  80784. * @returns a new Mesh
  80785. */
  80786. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  80787. w: number;
  80788. h: number;
  80789. }, precision: {
  80790. w: number;
  80791. h: number;
  80792. }, scene: Scene, updatable?: boolean): Mesh;
  80793. /**
  80794. * Creates a ground mesh from a height map.
  80795. * Please consider using the same method from the MeshBuilder class instead
  80796. * @see http://doc.babylonjs.com/babylon101/height_map
  80797. * @param name defines the name of the mesh to create
  80798. * @param url sets the URL of the height map image resource
  80799. * @param width set the ground width size
  80800. * @param height set the ground height size
  80801. * @param subdivisions sets the number of subdivision per side
  80802. * @param minHeight is the minimum altitude on the ground
  80803. * @param maxHeight is the maximum altitude on the ground
  80804. * @param scene defines the hosting scene
  80805. * @param updatable defines if the mesh must be flagged as updatable
  80806. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  80807. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80808. * @returns a new Mesh
  80809. */
  80810. 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;
  80811. /**
  80812. * Creates a tube mesh.
  80813. * The tube is a parametric shape.
  80814. * It has no predefined shape. Its final shape will depend on the input parameters.
  80815. * Please consider using the same method from the MeshBuilder class instead
  80816. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80817. * @param name defines the name of the mesh to create
  80818. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  80819. * @param radius sets the tube radius size
  80820. * @param tessellation is the number of sides on the tubular surface
  80821. * @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
  80822. * @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
  80823. * @param scene defines the hosting scene
  80824. * @param updatable defines if the mesh must be flagged as updatable
  80825. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80826. * @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)
  80827. * @returns a new Mesh
  80828. */
  80829. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  80830. (i: number, distance: number): number;
  80831. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80832. /**
  80833. * Creates a polyhedron mesh.
  80834. * Please consider using the same method from the MeshBuilder class instead.
  80835. * * 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
  80836. * * The parameter `size` (positive float, default 1) sets the polygon size
  80837. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80838. * * 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`
  80839. * * 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
  80840. * * 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)`)
  80841. * * 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
  80842. * * 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
  80843. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80844. * * If you create a double-sided mesh, you can choose what parts of 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
  80845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80846. * @param name defines the name of the mesh to create
  80847. * @param options defines the options used to create the mesh
  80848. * @param scene defines the hosting scene
  80849. * @returns a new Mesh
  80850. */
  80851. static CreatePolyhedron(name: string, options: {
  80852. type?: number;
  80853. size?: number;
  80854. sizeX?: number;
  80855. sizeY?: number;
  80856. sizeZ?: number;
  80857. custom?: any;
  80858. faceUV?: Vector4[];
  80859. faceColors?: Color4[];
  80860. updatable?: boolean;
  80861. sideOrientation?: number;
  80862. }, scene: Scene): Mesh;
  80863. /**
  80864. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  80865. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  80866. * * 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`)
  80867. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  80868. * * 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
  80869. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80870. * * If you create a double-sided mesh, you can choose what parts of 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
  80871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80872. * @param name defines the name of the mesh
  80873. * @param options defines the options used to create the mesh
  80874. * @param scene defines the hosting scene
  80875. * @returns a new Mesh
  80876. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  80877. */
  80878. static CreateIcoSphere(name: string, options: {
  80879. radius?: number;
  80880. flat?: boolean;
  80881. subdivisions?: number;
  80882. sideOrientation?: number;
  80883. updatable?: boolean;
  80884. }, scene: Scene): Mesh;
  80885. /**
  80886. * Creates a decal mesh.
  80887. * Please consider using the same method from the MeshBuilder class instead.
  80888. * A decal is a mesh usually applied as a model onto the surface of another mesh
  80889. * @param name defines the name of the mesh
  80890. * @param sourceMesh defines the mesh receiving the decal
  80891. * @param position sets the position of the decal in world coordinates
  80892. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  80893. * @param size sets the decal scaling
  80894. * @param angle sets the angle to rotate the decal
  80895. * @returns a new Mesh
  80896. */
  80897. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  80898. /**
  80899. * Prepare internal position array for software CPU skinning
  80900. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  80901. */
  80902. setPositionsForCPUSkinning(): Float32Array;
  80903. /**
  80904. * Prepare internal normal array for software CPU skinning
  80905. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  80906. */
  80907. setNormalsForCPUSkinning(): Float32Array;
  80908. /**
  80909. * Updates the vertex buffer by applying transformation from the bones
  80910. * @param skeleton defines the skeleton to apply to current mesh
  80911. * @returns the current mesh
  80912. */
  80913. applySkeleton(skeleton: Skeleton): Mesh;
  80914. /**
  80915. * 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
  80916. * @param meshes defines the list of meshes to scan
  80917. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  80918. */
  80919. static MinMax(meshes: AbstractMesh[]): {
  80920. min: Vector3;
  80921. max: Vector3;
  80922. };
  80923. /**
  80924. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  80925. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  80926. * @returns a vector3
  80927. */
  80928. static Center(meshesOrMinMaxVector: {
  80929. min: Vector3;
  80930. max: Vector3;
  80931. } | AbstractMesh[]): Vector3;
  80932. /**
  80933. * Merge the array of meshes into a single mesh for performance reasons.
  80934. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  80935. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  80936. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  80937. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  80938. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  80939. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  80940. * @returns a new mesh
  80941. */
  80942. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  80943. /** @hidden */
  80944. addInstance(instance: InstancedMesh): void;
  80945. /** @hidden */
  80946. removeInstance(instance: InstancedMesh): void;
  80947. }
  80948. }
  80949. declare module BABYLON {
  80950. /**
  80951. * Base class for the main features of a material in Babylon.js
  80952. */
  80953. export class Material implements IAnimatable {
  80954. /**
  80955. * Returns the triangle fill mode
  80956. */
  80957. static readonly TriangleFillMode: number;
  80958. /**
  80959. * Returns the wireframe mode
  80960. */
  80961. static readonly WireFrameFillMode: number;
  80962. /**
  80963. * Returns the point fill mode
  80964. */
  80965. static readonly PointFillMode: number;
  80966. /**
  80967. * Returns the point list draw mode
  80968. */
  80969. static readonly PointListDrawMode: number;
  80970. /**
  80971. * Returns the line list draw mode
  80972. */
  80973. static readonly LineListDrawMode: number;
  80974. /**
  80975. * Returns the line loop draw mode
  80976. */
  80977. static readonly LineLoopDrawMode: number;
  80978. /**
  80979. * Returns the line strip draw mode
  80980. */
  80981. static readonly LineStripDrawMode: number;
  80982. /**
  80983. * Returns the triangle strip draw mode
  80984. */
  80985. static readonly TriangleStripDrawMode: number;
  80986. /**
  80987. * Returns the triangle fan draw mode
  80988. */
  80989. static readonly TriangleFanDrawMode: number;
  80990. /**
  80991. * Stores the clock-wise side orientation
  80992. */
  80993. static readonly ClockWiseSideOrientation: number;
  80994. /**
  80995. * Stores the counter clock-wise side orientation
  80996. */
  80997. static readonly CounterClockWiseSideOrientation: number;
  80998. /**
  80999. * The dirty texture flag value
  81000. */
  81001. static readonly TextureDirtyFlag: number;
  81002. /**
  81003. * The dirty light flag value
  81004. */
  81005. static readonly LightDirtyFlag: number;
  81006. /**
  81007. * The dirty fresnel flag value
  81008. */
  81009. static readonly FresnelDirtyFlag: number;
  81010. /**
  81011. * The dirty attribute flag value
  81012. */
  81013. static readonly AttributesDirtyFlag: number;
  81014. /**
  81015. * The dirty misc flag value
  81016. */
  81017. static readonly MiscDirtyFlag: number;
  81018. /**
  81019. * The all dirty flag value
  81020. */
  81021. static readonly AllDirtyFlag: number;
  81022. /**
  81023. * The ID of the material
  81024. */
  81025. id: string;
  81026. /**
  81027. * Gets or sets the unique id of the material
  81028. */
  81029. uniqueId: number;
  81030. /**
  81031. * The name of the material
  81032. */
  81033. name: string;
  81034. /**
  81035. * Gets or sets user defined metadata
  81036. */
  81037. metadata: any;
  81038. /**
  81039. * For internal use only. Please do not use.
  81040. */
  81041. reservedDataStore: any;
  81042. /**
  81043. * Specifies if the ready state should be checked on each call
  81044. */
  81045. checkReadyOnEveryCall: boolean;
  81046. /**
  81047. * Specifies if the ready state should be checked once
  81048. */
  81049. checkReadyOnlyOnce: boolean;
  81050. /**
  81051. * The state of the material
  81052. */
  81053. state: string;
  81054. /**
  81055. * The alpha value of the material
  81056. */
  81057. protected _alpha: number;
  81058. /**
  81059. * List of inspectable custom properties (used by the Inspector)
  81060. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81061. */
  81062. inspectableCustomProperties: IInspectable[];
  81063. /**
  81064. * Sets the alpha value of the material
  81065. */
  81066. /**
  81067. * Gets the alpha value of the material
  81068. */
  81069. alpha: number;
  81070. /**
  81071. * Specifies if back face culling is enabled
  81072. */
  81073. protected _backFaceCulling: boolean;
  81074. /**
  81075. * Sets the back-face culling state
  81076. */
  81077. /**
  81078. * Gets the back-face culling state
  81079. */
  81080. backFaceCulling: boolean;
  81081. /**
  81082. * Stores the value for side orientation
  81083. */
  81084. sideOrientation: number;
  81085. /**
  81086. * Callback triggered when the material is compiled
  81087. */
  81088. onCompiled: (effect: Effect) => void;
  81089. /**
  81090. * Callback triggered when an error occurs
  81091. */
  81092. onError: (effect: Effect, errors: string) => void;
  81093. /**
  81094. * Callback triggered to get the render target textures
  81095. */
  81096. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  81097. /**
  81098. * Gets a boolean indicating that current material needs to register RTT
  81099. */
  81100. readonly hasRenderTargetTextures: boolean;
  81101. /**
  81102. * Specifies if the material should be serialized
  81103. */
  81104. doNotSerialize: boolean;
  81105. /**
  81106. * @hidden
  81107. */
  81108. _storeEffectOnSubMeshes: boolean;
  81109. /**
  81110. * Stores the animations for the material
  81111. */
  81112. animations: Array<Animation>;
  81113. /**
  81114. * An event triggered when the material is disposed
  81115. */
  81116. onDisposeObservable: Observable<Material>;
  81117. /**
  81118. * An observer which watches for dispose events
  81119. */
  81120. private _onDisposeObserver;
  81121. private _onUnBindObservable;
  81122. /**
  81123. * Called during a dispose event
  81124. */
  81125. onDispose: () => void;
  81126. private _onBindObservable;
  81127. /**
  81128. * An event triggered when the material is bound
  81129. */
  81130. readonly onBindObservable: Observable<AbstractMesh>;
  81131. /**
  81132. * An observer which watches for bind events
  81133. */
  81134. private _onBindObserver;
  81135. /**
  81136. * Called during a bind event
  81137. */
  81138. onBind: (Mesh: AbstractMesh) => void;
  81139. /**
  81140. * An event triggered when the material is unbound
  81141. */
  81142. readonly onUnBindObservable: Observable<Material>;
  81143. /**
  81144. * Stores the value of the alpha mode
  81145. */
  81146. private _alphaMode;
  81147. /**
  81148. * Sets the value of the alpha mode.
  81149. *
  81150. * | Value | Type | Description |
  81151. * | --- | --- | --- |
  81152. * | 0 | ALPHA_DISABLE | |
  81153. * | 1 | ALPHA_ADD | |
  81154. * | 2 | ALPHA_COMBINE | |
  81155. * | 3 | ALPHA_SUBTRACT | |
  81156. * | 4 | ALPHA_MULTIPLY | |
  81157. * | 5 | ALPHA_MAXIMIZED | |
  81158. * | 6 | ALPHA_ONEONE | |
  81159. * | 7 | ALPHA_PREMULTIPLIED | |
  81160. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  81161. * | 9 | ALPHA_INTERPOLATE | |
  81162. * | 10 | ALPHA_SCREENMODE | |
  81163. *
  81164. */
  81165. /**
  81166. * Gets the value of the alpha mode
  81167. */
  81168. alphaMode: number;
  81169. /**
  81170. * Stores the state of the need depth pre-pass value
  81171. */
  81172. private _needDepthPrePass;
  81173. /**
  81174. * Sets the need depth pre-pass value
  81175. */
  81176. /**
  81177. * Gets the depth pre-pass value
  81178. */
  81179. needDepthPrePass: boolean;
  81180. /**
  81181. * Specifies if depth writing should be disabled
  81182. */
  81183. disableDepthWrite: boolean;
  81184. /**
  81185. * Specifies if depth writing should be forced
  81186. */
  81187. forceDepthWrite: boolean;
  81188. /**
  81189. * Specifies if there should be a separate pass for culling
  81190. */
  81191. separateCullingPass: boolean;
  81192. /**
  81193. * Stores the state specifing if fog should be enabled
  81194. */
  81195. private _fogEnabled;
  81196. /**
  81197. * Sets the state for enabling fog
  81198. */
  81199. /**
  81200. * Gets the value of the fog enabled state
  81201. */
  81202. fogEnabled: boolean;
  81203. /**
  81204. * Stores the size of points
  81205. */
  81206. pointSize: number;
  81207. /**
  81208. * Stores the z offset value
  81209. */
  81210. zOffset: number;
  81211. /**
  81212. * Gets a value specifying if wireframe mode is enabled
  81213. */
  81214. /**
  81215. * Sets the state of wireframe mode
  81216. */
  81217. wireframe: boolean;
  81218. /**
  81219. * Gets the value specifying if point clouds are enabled
  81220. */
  81221. /**
  81222. * Sets the state of point cloud mode
  81223. */
  81224. pointsCloud: boolean;
  81225. /**
  81226. * Gets the material fill mode
  81227. */
  81228. /**
  81229. * Sets the material fill mode
  81230. */
  81231. fillMode: number;
  81232. /**
  81233. * @hidden
  81234. * Stores the effects for the material
  81235. */
  81236. _effect: Nullable<Effect>;
  81237. /**
  81238. * @hidden
  81239. * Specifies if the material was previously ready
  81240. */
  81241. _wasPreviouslyReady: boolean;
  81242. /**
  81243. * Specifies if uniform buffers should be used
  81244. */
  81245. private _useUBO;
  81246. /**
  81247. * Stores a reference to the scene
  81248. */
  81249. private _scene;
  81250. /**
  81251. * Stores the fill mode state
  81252. */
  81253. private _fillMode;
  81254. /**
  81255. * Specifies if the depth write state should be cached
  81256. */
  81257. private _cachedDepthWriteState;
  81258. /**
  81259. * Stores the uniform buffer
  81260. */
  81261. protected _uniformBuffer: UniformBuffer;
  81262. /** @hidden */
  81263. _indexInSceneMaterialArray: number;
  81264. /** @hidden */
  81265. meshMap: Nullable<{
  81266. [id: string]: AbstractMesh | undefined;
  81267. }>;
  81268. /**
  81269. * Creates a material instance
  81270. * @param name defines the name of the material
  81271. * @param scene defines the scene to reference
  81272. * @param doNotAdd specifies if the material should be added to the scene
  81273. */
  81274. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  81275. /**
  81276. * Returns a string representation of the current material
  81277. * @param fullDetails defines a boolean indicating which levels of logging is desired
  81278. * @returns a string with material information
  81279. */
  81280. toString(fullDetails?: boolean): string;
  81281. /**
  81282. * Gets the class name of the material
  81283. * @returns a string with the class name of the material
  81284. */
  81285. getClassName(): string;
  81286. /**
  81287. * Specifies if updates for the material been locked
  81288. */
  81289. readonly isFrozen: boolean;
  81290. /**
  81291. * Locks updates for the material
  81292. */
  81293. freeze(): void;
  81294. /**
  81295. * Unlocks updates for the material
  81296. */
  81297. unfreeze(): void;
  81298. /**
  81299. * Specifies if the material is ready to be used
  81300. * @param mesh defines the mesh to check
  81301. * @param useInstances specifies if instances should be used
  81302. * @returns a boolean indicating if the material is ready to be used
  81303. */
  81304. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  81305. /**
  81306. * Specifies that the submesh is ready to be used
  81307. * @param mesh defines the mesh to check
  81308. * @param subMesh defines which submesh to check
  81309. * @param useInstances specifies that instances should be used
  81310. * @returns a boolean indicating that the submesh is ready or not
  81311. */
  81312. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  81313. /**
  81314. * Returns the material effect
  81315. * @returns the effect associated with the material
  81316. */
  81317. getEffect(): Nullable<Effect>;
  81318. /**
  81319. * Returns the current scene
  81320. * @returns a Scene
  81321. */
  81322. getScene(): Scene;
  81323. /**
  81324. * Specifies if the material will require alpha blending
  81325. * @returns a boolean specifying if alpha blending is needed
  81326. */
  81327. needAlphaBlending(): boolean;
  81328. /**
  81329. * Specifies if the mesh will require alpha blending
  81330. * @param mesh defines the mesh to check
  81331. * @returns a boolean specifying if alpha blending is needed for the mesh
  81332. */
  81333. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  81334. /**
  81335. * Specifies if this material should be rendered in alpha test mode
  81336. * @returns a boolean specifying if an alpha test is needed.
  81337. */
  81338. needAlphaTesting(): boolean;
  81339. /**
  81340. * Gets the texture used for the alpha test
  81341. * @returns the texture to use for alpha testing
  81342. */
  81343. getAlphaTestTexture(): Nullable<BaseTexture>;
  81344. /**
  81345. * Marks the material to indicate that it needs to be re-calculated
  81346. */
  81347. markDirty(): void;
  81348. /** @hidden */
  81349. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81350. /**
  81351. * Binds the material to the mesh
  81352. * @param world defines the world transformation matrix
  81353. * @param mesh defines the mesh to bind the material to
  81354. */
  81355. bind(world: Matrix, mesh?: Mesh): void;
  81356. /**
  81357. * Binds the submesh to the material
  81358. * @param world defines the world transformation matrix
  81359. * @param mesh defines the mesh containing the submesh
  81360. * @param subMesh defines the submesh to bind the material to
  81361. */
  81362. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81363. /**
  81364. * Binds the world matrix to the material
  81365. * @param world defines the world transformation matrix
  81366. */
  81367. bindOnlyWorldMatrix(world: Matrix): void;
  81368. /**
  81369. * Binds the scene's uniform buffer to the effect.
  81370. * @param effect defines the effect to bind to the scene uniform buffer
  81371. * @param sceneUbo defines the uniform buffer storing scene data
  81372. */
  81373. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81374. /**
  81375. * Binds the view matrix to the effect
  81376. * @param effect defines the effect to bind the view matrix to
  81377. */
  81378. bindView(effect: Effect): void;
  81379. /**
  81380. * Binds the view projection matrix to the effect
  81381. * @param effect defines the effect to bind the view projection matrix to
  81382. */
  81383. bindViewProjection(effect: Effect): void;
  81384. /**
  81385. * Specifies if material alpha testing should be turned on for the mesh
  81386. * @param mesh defines the mesh to check
  81387. */
  81388. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  81389. /**
  81390. * Processes to execute after binding the material to a mesh
  81391. * @param mesh defines the rendered mesh
  81392. */
  81393. protected _afterBind(mesh?: Mesh): void;
  81394. /**
  81395. * Unbinds the material from the mesh
  81396. */
  81397. unbind(): void;
  81398. /**
  81399. * Gets the active textures from the material
  81400. * @returns an array of textures
  81401. */
  81402. getActiveTextures(): BaseTexture[];
  81403. /**
  81404. * Specifies if the material uses a texture
  81405. * @param texture defines the texture to check against the material
  81406. * @returns a boolean specifying if the material uses the texture
  81407. */
  81408. hasTexture(texture: BaseTexture): boolean;
  81409. /**
  81410. * Makes a duplicate of the material, and gives it a new name
  81411. * @param name defines the new name for the duplicated material
  81412. * @returns the cloned material
  81413. */
  81414. clone(name: string): Nullable<Material>;
  81415. /**
  81416. * Gets the meshes bound to the material
  81417. * @returns an array of meshes bound to the material
  81418. */
  81419. getBindedMeshes(): AbstractMesh[];
  81420. /**
  81421. * Force shader compilation
  81422. * @param mesh defines the mesh associated with this material
  81423. * @param onCompiled defines a function to execute once the material is compiled
  81424. * @param options defines the options to configure the compilation
  81425. */
  81426. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  81427. clipPlane: boolean;
  81428. }>): void;
  81429. /**
  81430. * Force shader compilation
  81431. * @param mesh defines the mesh that will use this material
  81432. * @param options defines additional options for compiling the shaders
  81433. * @returns a promise that resolves when the compilation completes
  81434. */
  81435. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  81436. clipPlane: boolean;
  81437. }>): Promise<void>;
  81438. private static readonly _ImageProcessingDirtyCallBack;
  81439. private static readonly _TextureDirtyCallBack;
  81440. private static readonly _FresnelDirtyCallBack;
  81441. private static readonly _MiscDirtyCallBack;
  81442. private static readonly _LightsDirtyCallBack;
  81443. private static readonly _AttributeDirtyCallBack;
  81444. private static _FresnelAndMiscDirtyCallBack;
  81445. private static _TextureAndMiscDirtyCallBack;
  81446. private static readonly _DirtyCallbackArray;
  81447. private static readonly _RunDirtyCallBacks;
  81448. /**
  81449. * Marks a define in the material to indicate that it needs to be re-computed
  81450. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  81451. */
  81452. markAsDirty(flag: number): void;
  81453. /**
  81454. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  81455. * @param func defines a function which checks material defines against the submeshes
  81456. */
  81457. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  81458. /**
  81459. * Indicates that image processing needs to be re-calculated for all submeshes
  81460. */
  81461. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  81462. /**
  81463. * Indicates that textures need to be re-calculated for all submeshes
  81464. */
  81465. protected _markAllSubMeshesAsTexturesDirty(): void;
  81466. /**
  81467. * Indicates that fresnel needs to be re-calculated for all submeshes
  81468. */
  81469. protected _markAllSubMeshesAsFresnelDirty(): void;
  81470. /**
  81471. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  81472. */
  81473. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  81474. /**
  81475. * Indicates that lights need to be re-calculated for all submeshes
  81476. */
  81477. protected _markAllSubMeshesAsLightsDirty(): void;
  81478. /**
  81479. * Indicates that attributes need to be re-calculated for all submeshes
  81480. */
  81481. protected _markAllSubMeshesAsAttributesDirty(): void;
  81482. /**
  81483. * Indicates that misc needs to be re-calculated for all submeshes
  81484. */
  81485. protected _markAllSubMeshesAsMiscDirty(): void;
  81486. /**
  81487. * Indicates that textures and misc need to be re-calculated for all submeshes
  81488. */
  81489. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  81490. /**
  81491. * Disposes the material
  81492. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81493. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  81494. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  81495. */
  81496. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  81497. /** @hidden */
  81498. private releaseVertexArrayObject;
  81499. /**
  81500. * Serializes this material
  81501. * @returns the serialized material object
  81502. */
  81503. serialize(): any;
  81504. /**
  81505. * Creates a material from parsed material data
  81506. * @param parsedMaterial defines parsed material data
  81507. * @param scene defines the hosting scene
  81508. * @param rootUrl defines the root URL to use to load textures
  81509. * @returns a new material
  81510. */
  81511. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  81512. }
  81513. }
  81514. declare module BABYLON {
  81515. /**
  81516. * Base class for submeshes
  81517. */
  81518. export class BaseSubMesh {
  81519. /** @hidden */
  81520. _materialDefines: Nullable<MaterialDefines>;
  81521. /** @hidden */
  81522. _materialEffect: Nullable<Effect>;
  81523. /**
  81524. * Gets associated effect
  81525. */
  81526. readonly effect: Nullable<Effect>;
  81527. /**
  81528. * Sets associated effect (effect used to render this submesh)
  81529. * @param effect defines the effect to associate with
  81530. * @param defines defines the set of defines used to compile this effect
  81531. */
  81532. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  81533. }
  81534. /**
  81535. * Defines a subdivision inside a mesh
  81536. */
  81537. export class SubMesh extends BaseSubMesh implements ICullable {
  81538. /** the material index to use */
  81539. materialIndex: number;
  81540. /** vertex index start */
  81541. verticesStart: number;
  81542. /** vertices count */
  81543. verticesCount: number;
  81544. /** index start */
  81545. indexStart: number;
  81546. /** indices count */
  81547. indexCount: number;
  81548. /** @hidden */
  81549. _linesIndexCount: number;
  81550. private _mesh;
  81551. private _renderingMesh;
  81552. private _boundingInfo;
  81553. private _linesIndexBuffer;
  81554. /** @hidden */
  81555. _lastColliderWorldVertices: Nullable<Vector3[]>;
  81556. /** @hidden */
  81557. _trianglePlanes: Plane[];
  81558. /** @hidden */
  81559. _lastColliderTransformMatrix: Matrix;
  81560. /** @hidden */
  81561. _renderId: number;
  81562. /** @hidden */
  81563. _alphaIndex: number;
  81564. /** @hidden */
  81565. _distanceToCamera: number;
  81566. /** @hidden */
  81567. _id: number;
  81568. private _currentMaterial;
  81569. /**
  81570. * Add a new submesh to a mesh
  81571. * @param materialIndex defines the material index to use
  81572. * @param verticesStart defines vertex index start
  81573. * @param verticesCount defines vertices count
  81574. * @param indexStart defines index start
  81575. * @param indexCount defines indices count
  81576. * @param mesh defines the parent mesh
  81577. * @param renderingMesh defines an optional rendering mesh
  81578. * @param createBoundingBox defines if bounding box should be created for this submesh
  81579. * @returns the new submesh
  81580. */
  81581. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  81582. /**
  81583. * Creates a new submesh
  81584. * @param materialIndex defines the material index to use
  81585. * @param verticesStart defines vertex index start
  81586. * @param verticesCount defines vertices count
  81587. * @param indexStart defines index start
  81588. * @param indexCount defines indices count
  81589. * @param mesh defines the parent mesh
  81590. * @param renderingMesh defines an optional rendering mesh
  81591. * @param createBoundingBox defines if bounding box should be created for this submesh
  81592. */
  81593. constructor(
  81594. /** the material index to use */
  81595. materialIndex: number,
  81596. /** vertex index start */
  81597. verticesStart: number,
  81598. /** vertices count */
  81599. verticesCount: number,
  81600. /** index start */
  81601. indexStart: number,
  81602. /** indices count */
  81603. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  81604. /**
  81605. * Returns true if this submesh covers the entire parent mesh
  81606. * @ignorenaming
  81607. */
  81608. readonly IsGlobal: boolean;
  81609. /**
  81610. * Returns the submesh BoudingInfo object
  81611. * @returns current bounding info (or mesh's one if the submesh is global)
  81612. */
  81613. getBoundingInfo(): BoundingInfo;
  81614. /**
  81615. * Sets the submesh BoundingInfo
  81616. * @param boundingInfo defines the new bounding info to use
  81617. * @returns the SubMesh
  81618. */
  81619. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  81620. /**
  81621. * Returns the mesh of the current submesh
  81622. * @return the parent mesh
  81623. */
  81624. getMesh(): AbstractMesh;
  81625. /**
  81626. * Returns the rendering mesh of the submesh
  81627. * @returns the rendering mesh (could be different from parent mesh)
  81628. */
  81629. getRenderingMesh(): Mesh;
  81630. /**
  81631. * Returns the submesh material
  81632. * @returns null or the current material
  81633. */
  81634. getMaterial(): Nullable<Material>;
  81635. /**
  81636. * Sets a new updated BoundingInfo object to the submesh
  81637. * @returns the SubMesh
  81638. */
  81639. refreshBoundingInfo(): SubMesh;
  81640. /** @hidden */
  81641. _checkCollision(collider: Collider): boolean;
  81642. /**
  81643. * Updates the submesh BoundingInfo
  81644. * @param world defines the world matrix to use to update the bounding info
  81645. * @returns the submesh
  81646. */
  81647. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  81648. /**
  81649. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  81650. * @param frustumPlanes defines the frustum planes
  81651. * @returns true if the submesh is intersecting with the frustum
  81652. */
  81653. isInFrustum(frustumPlanes: Plane[]): boolean;
  81654. /**
  81655. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  81656. * @param frustumPlanes defines the frustum planes
  81657. * @returns true if the submesh is inside the frustum
  81658. */
  81659. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81660. /**
  81661. * Renders the submesh
  81662. * @param enableAlphaMode defines if alpha needs to be used
  81663. * @returns the submesh
  81664. */
  81665. render(enableAlphaMode: boolean): SubMesh;
  81666. /**
  81667. * @hidden
  81668. */
  81669. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  81670. /**
  81671. * Checks if the submesh intersects with a ray
  81672. * @param ray defines the ray to test
  81673. * @returns true is the passed ray intersects the submesh bounding box
  81674. */
  81675. canIntersects(ray: Ray): boolean;
  81676. /**
  81677. * Intersects current submesh with a ray
  81678. * @param ray defines the ray to test
  81679. * @param positions defines mesh's positions array
  81680. * @param indices defines mesh's indices array
  81681. * @param fastCheck defines if only bounding info should be used
  81682. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81683. * @returns intersection info or null if no intersection
  81684. */
  81685. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  81686. /** @hidden */
  81687. private _intersectLines;
  81688. /** @hidden */
  81689. private _intersectTriangles;
  81690. /** @hidden */
  81691. _rebuild(): void;
  81692. /**
  81693. * Creates a new submesh from the passed mesh
  81694. * @param newMesh defines the new hosting mesh
  81695. * @param newRenderingMesh defines an optional rendering mesh
  81696. * @returns the new submesh
  81697. */
  81698. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  81699. /**
  81700. * Release associated resources
  81701. */
  81702. dispose(): void;
  81703. /**
  81704. * Gets the class name
  81705. * @returns the string "SubMesh".
  81706. */
  81707. getClassName(): string;
  81708. /**
  81709. * Creates a new submesh from indices data
  81710. * @param materialIndex the index of the main mesh material
  81711. * @param startIndex the index where to start the copy in the mesh indices array
  81712. * @param indexCount the number of indices to copy then from the startIndex
  81713. * @param mesh the main mesh to create the submesh from
  81714. * @param renderingMesh the optional rendering mesh
  81715. * @returns a new submesh
  81716. */
  81717. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  81718. }
  81719. }
  81720. declare module BABYLON {
  81721. /**
  81722. * Class used to store geometry data (vertex buffers + index buffer)
  81723. */
  81724. export class Geometry implements IGetSetVerticesData {
  81725. /**
  81726. * Gets or sets the ID of the geometry
  81727. */
  81728. id: string;
  81729. /**
  81730. * Gets or sets the unique ID of the geometry
  81731. */
  81732. uniqueId: number;
  81733. /**
  81734. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81735. */
  81736. delayLoadState: number;
  81737. /**
  81738. * Gets the file containing the data to load when running in delay load state
  81739. */
  81740. delayLoadingFile: Nullable<string>;
  81741. /**
  81742. * Callback called when the geometry is updated
  81743. */
  81744. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  81745. private _scene;
  81746. private _engine;
  81747. private _meshes;
  81748. private _totalVertices;
  81749. /** @hidden */
  81750. _indices: IndicesArray;
  81751. /** @hidden */
  81752. _vertexBuffers: {
  81753. [key: string]: VertexBuffer;
  81754. };
  81755. private _isDisposed;
  81756. private _extend;
  81757. private _boundingBias;
  81758. /** @hidden */
  81759. _delayInfo: Array<string>;
  81760. private _indexBuffer;
  81761. private _indexBufferIsUpdatable;
  81762. /** @hidden */
  81763. _boundingInfo: Nullable<BoundingInfo>;
  81764. /** @hidden */
  81765. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  81766. /** @hidden */
  81767. _softwareSkinningFrameId: number;
  81768. private _vertexArrayObjects;
  81769. private _updatable;
  81770. /** @hidden */
  81771. _positions: Nullable<Vector3[]>;
  81772. /**
  81773. * 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
  81774. */
  81775. /**
  81776. * 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
  81777. */
  81778. boundingBias: Vector2;
  81779. /**
  81780. * Static function used to attach a new empty geometry to a mesh
  81781. * @param mesh defines the mesh to attach the geometry to
  81782. * @returns the new Geometry
  81783. */
  81784. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  81785. /**
  81786. * Creates a new geometry
  81787. * @param id defines the unique ID
  81788. * @param scene defines the hosting scene
  81789. * @param vertexData defines the VertexData used to get geometry data
  81790. * @param updatable defines if geometry must be updatable (false by default)
  81791. * @param mesh defines the mesh that will be associated with the geometry
  81792. */
  81793. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  81794. /**
  81795. * Gets the current extend of the geometry
  81796. */
  81797. readonly extend: {
  81798. minimum: Vector3;
  81799. maximum: Vector3;
  81800. };
  81801. /**
  81802. * Gets the hosting scene
  81803. * @returns the hosting Scene
  81804. */
  81805. getScene(): Scene;
  81806. /**
  81807. * Gets the hosting engine
  81808. * @returns the hosting Engine
  81809. */
  81810. getEngine(): Engine;
  81811. /**
  81812. * Defines if the geometry is ready to use
  81813. * @returns true if the geometry is ready to be used
  81814. */
  81815. isReady(): boolean;
  81816. /**
  81817. * Gets a value indicating that the geometry should not be serialized
  81818. */
  81819. readonly doNotSerialize: boolean;
  81820. /** @hidden */
  81821. _rebuild(): void;
  81822. /**
  81823. * Affects all geometry data in one call
  81824. * @param vertexData defines the geometry data
  81825. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81826. */
  81827. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  81828. /**
  81829. * Set specific vertex data
  81830. * @param kind defines the data kind (Position, normal, etc...)
  81831. * @param data defines the vertex data to use
  81832. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81833. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81834. */
  81835. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  81836. /**
  81837. * Removes a specific vertex data
  81838. * @param kind defines the data kind (Position, normal, etc...)
  81839. */
  81840. removeVerticesData(kind: string): void;
  81841. /**
  81842. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81843. * @param buffer defines the vertex buffer to use
  81844. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81845. */
  81846. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  81847. /**
  81848. * Update a specific vertex buffer
  81849. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81850. * It will do nothing if the buffer is not updatable
  81851. * @param kind defines the data kind (Position, normal, etc...)
  81852. * @param data defines the data to use
  81853. * @param offset defines the offset in the target buffer where to store the data
  81854. * @param useBytes set to true if the offset is in bytes
  81855. */
  81856. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  81857. /**
  81858. * Update a specific vertex buffer
  81859. * This function will create a new buffer if the current one is not updatable
  81860. * @param kind defines the data kind (Position, normal, etc...)
  81861. * @param data defines the data to use
  81862. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81863. */
  81864. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  81865. private _updateBoundingInfo;
  81866. /** @hidden */
  81867. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  81868. /**
  81869. * Gets total number of vertices
  81870. * @returns the total number of vertices
  81871. */
  81872. getTotalVertices(): number;
  81873. /**
  81874. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81875. * @param kind defines the data kind (Position, normal, etc...)
  81876. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81877. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81878. * @returns a float array containing vertex data
  81879. */
  81880. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81881. /**
  81882. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81883. * @param kind defines the data kind (Position, normal, etc...)
  81884. * @returns true if the vertex buffer with the specified kind is updatable
  81885. */
  81886. isVertexBufferUpdatable(kind: string): boolean;
  81887. /**
  81888. * Gets a specific vertex buffer
  81889. * @param kind defines the data kind (Position, normal, etc...)
  81890. * @returns a VertexBuffer
  81891. */
  81892. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81893. /**
  81894. * Returns all vertex buffers
  81895. * @return an object holding all vertex buffers indexed by kind
  81896. */
  81897. getVertexBuffers(): Nullable<{
  81898. [key: string]: VertexBuffer;
  81899. }>;
  81900. /**
  81901. * Gets a boolean indicating if specific vertex buffer is present
  81902. * @param kind defines the data kind (Position, normal, etc...)
  81903. * @returns true if data is present
  81904. */
  81905. isVerticesDataPresent(kind: string): boolean;
  81906. /**
  81907. * Gets a list of all attached data kinds (Position, normal, etc...)
  81908. * @returns a list of string containing all kinds
  81909. */
  81910. getVerticesDataKinds(): string[];
  81911. /**
  81912. * Update index buffer
  81913. * @param indices defines the indices to store in the index buffer
  81914. * @param offset defines the offset in the target buffer where to store the data
  81915. * @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)
  81916. */
  81917. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  81918. /**
  81919. * Creates a new index buffer
  81920. * @param indices defines the indices to store in the index buffer
  81921. * @param totalVertices defines the total number of vertices (could be null)
  81922. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81923. */
  81924. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  81925. /**
  81926. * Return the total number of indices
  81927. * @returns the total number of indices
  81928. */
  81929. getTotalIndices(): number;
  81930. /**
  81931. * Gets the index buffer array
  81932. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81933. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81934. * @returns the index buffer array
  81935. */
  81936. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81937. /**
  81938. * Gets the index buffer
  81939. * @return the index buffer
  81940. */
  81941. getIndexBuffer(): Nullable<WebGLBuffer>;
  81942. /** @hidden */
  81943. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  81944. /**
  81945. * Release the associated resources for a specific mesh
  81946. * @param mesh defines the source mesh
  81947. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81948. */
  81949. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  81950. /**
  81951. * Apply current geometry to a given mesh
  81952. * @param mesh defines the mesh to apply geometry to
  81953. */
  81954. applyToMesh(mesh: Mesh): void;
  81955. private _updateExtend;
  81956. private _applyToMesh;
  81957. private notifyUpdate;
  81958. /**
  81959. * Load the geometry if it was flagged as delay loaded
  81960. * @param scene defines the hosting scene
  81961. * @param onLoaded defines a callback called when the geometry is loaded
  81962. */
  81963. load(scene: Scene, onLoaded?: () => void): void;
  81964. private _queueLoad;
  81965. /**
  81966. * Invert the geometry to move from a right handed system to a left handed one.
  81967. */
  81968. toLeftHanded(): void;
  81969. /** @hidden */
  81970. _resetPointsArrayCache(): void;
  81971. /** @hidden */
  81972. _generatePointsArray(): boolean;
  81973. /**
  81974. * Gets a value indicating if the geometry is disposed
  81975. * @returns true if the geometry was disposed
  81976. */
  81977. isDisposed(): boolean;
  81978. private _disposeVertexArrayObjects;
  81979. /**
  81980. * Free all associated resources
  81981. */
  81982. dispose(): void;
  81983. /**
  81984. * Clone the current geometry into a new geometry
  81985. * @param id defines the unique ID of the new geometry
  81986. * @returns a new geometry object
  81987. */
  81988. copy(id: string): Geometry;
  81989. /**
  81990. * Serialize the current geometry info (and not the vertices data) into a JSON object
  81991. * @return a JSON representation of the current geometry data (without the vertices data)
  81992. */
  81993. serialize(): any;
  81994. private toNumberArray;
  81995. /**
  81996. * Serialize all vertices data into a JSON oject
  81997. * @returns a JSON representation of the current geometry data
  81998. */
  81999. serializeVerticeData(): any;
  82000. /**
  82001. * Extracts a clone of a mesh geometry
  82002. * @param mesh defines the source mesh
  82003. * @param id defines the unique ID of the new geometry object
  82004. * @returns the new geometry object
  82005. */
  82006. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82007. /**
  82008. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82009. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82010. * Be aware Math.random() could cause collisions, but:
  82011. * "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"
  82012. * @returns a string containing a new GUID
  82013. */
  82014. static RandomId(): string;
  82015. /** @hidden */
  82016. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82017. private static _CleanMatricesWeights;
  82018. /**
  82019. * Create a new geometry from persisted data (Using .babylon file format)
  82020. * @param parsedVertexData defines the persisted data
  82021. * @param scene defines the hosting scene
  82022. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82023. * @returns the new geometry object
  82024. */
  82025. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82026. }
  82027. }
  82028. declare module BABYLON {
  82029. /**
  82030. * Define an interface for all classes that will get and set the data on vertices
  82031. */
  82032. export interface IGetSetVerticesData {
  82033. /**
  82034. * Gets a boolean indicating if specific vertex data is present
  82035. * @param kind defines the vertex data kind to use
  82036. * @returns true is data kind is present
  82037. */
  82038. isVerticesDataPresent(kind: string): boolean;
  82039. /**
  82040. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82041. * @param kind defines the data kind (Position, normal, etc...)
  82042. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82043. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82044. * @returns a float array containing vertex data
  82045. */
  82046. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82047. /**
  82048. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82049. * @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.
  82050. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82051. * @returns the indices array or an empty array if the mesh has no geometry
  82052. */
  82053. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82054. /**
  82055. * Set specific vertex data
  82056. * @param kind defines the data kind (Position, normal, etc...)
  82057. * @param data defines the vertex data to use
  82058. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82059. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82060. */
  82061. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82062. /**
  82063. * Update a specific associated vertex buffer
  82064. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82065. * - VertexBuffer.PositionKind
  82066. * - VertexBuffer.UVKind
  82067. * - VertexBuffer.UV2Kind
  82068. * - VertexBuffer.UV3Kind
  82069. * - VertexBuffer.UV4Kind
  82070. * - VertexBuffer.UV5Kind
  82071. * - VertexBuffer.UV6Kind
  82072. * - VertexBuffer.ColorKind
  82073. * - VertexBuffer.MatricesIndicesKind
  82074. * - VertexBuffer.MatricesIndicesExtraKind
  82075. * - VertexBuffer.MatricesWeightsKind
  82076. * - VertexBuffer.MatricesWeightsExtraKind
  82077. * @param data defines the data source
  82078. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82079. * @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)
  82080. */
  82081. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  82082. /**
  82083. * Creates a new index buffer
  82084. * @param indices defines the indices to store in the index buffer
  82085. * @param totalVertices defines the total number of vertices (could be null)
  82086. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82087. */
  82088. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  82089. }
  82090. /**
  82091. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  82092. */
  82093. export class VertexData {
  82094. /**
  82095. * Mesh side orientation : usually the external or front surface
  82096. */
  82097. static readonly FRONTSIDE: number;
  82098. /**
  82099. * Mesh side orientation : usually the internal or back surface
  82100. */
  82101. static readonly BACKSIDE: number;
  82102. /**
  82103. * Mesh side orientation : both internal and external or front and back surfaces
  82104. */
  82105. static readonly DOUBLESIDE: number;
  82106. /**
  82107. * Mesh side orientation : by default, `FRONTSIDE`
  82108. */
  82109. static readonly DEFAULTSIDE: number;
  82110. /**
  82111. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  82112. */
  82113. positions: Nullable<FloatArray>;
  82114. /**
  82115. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  82116. */
  82117. normals: Nullable<FloatArray>;
  82118. /**
  82119. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  82120. */
  82121. tangents: Nullable<FloatArray>;
  82122. /**
  82123. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82124. */
  82125. uvs: Nullable<FloatArray>;
  82126. /**
  82127. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82128. */
  82129. uvs2: Nullable<FloatArray>;
  82130. /**
  82131. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82132. */
  82133. uvs3: Nullable<FloatArray>;
  82134. /**
  82135. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82136. */
  82137. uvs4: Nullable<FloatArray>;
  82138. /**
  82139. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82140. */
  82141. uvs5: Nullable<FloatArray>;
  82142. /**
  82143. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82144. */
  82145. uvs6: Nullable<FloatArray>;
  82146. /**
  82147. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  82148. */
  82149. colors: Nullable<FloatArray>;
  82150. /**
  82151. * 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).
  82152. */
  82153. matricesIndices: Nullable<FloatArray>;
  82154. /**
  82155. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  82156. */
  82157. matricesWeights: Nullable<FloatArray>;
  82158. /**
  82159. * An array extending the number of possible indices
  82160. */
  82161. matricesIndicesExtra: Nullable<FloatArray>;
  82162. /**
  82163. * An array extending the number of possible weights when the number of indices is extended
  82164. */
  82165. matricesWeightsExtra: Nullable<FloatArray>;
  82166. /**
  82167. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  82168. */
  82169. indices: Nullable<IndicesArray>;
  82170. /**
  82171. * Uses the passed data array to set the set the values for the specified kind of data
  82172. * @param data a linear array of floating numbers
  82173. * @param kind the type of data that is being set, eg positions, colors etc
  82174. */
  82175. set(data: FloatArray, kind: string): void;
  82176. /**
  82177. * Associates the vertexData to the passed Mesh.
  82178. * Sets it as updatable or not (default `false`)
  82179. * @param mesh the mesh the vertexData is applied to
  82180. * @param updatable when used and having the value true allows new data to update the vertexData
  82181. * @returns the VertexData
  82182. */
  82183. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  82184. /**
  82185. * Associates the vertexData to the passed Geometry.
  82186. * Sets it as updatable or not (default `false`)
  82187. * @param geometry the geometry the vertexData is applied to
  82188. * @param updatable when used and having the value true allows new data to update the vertexData
  82189. * @returns VertexData
  82190. */
  82191. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  82192. /**
  82193. * Updates the associated mesh
  82194. * @param mesh the mesh to be updated
  82195. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82196. * @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
  82197. * @returns VertexData
  82198. */
  82199. updateMesh(mesh: Mesh): VertexData;
  82200. /**
  82201. * Updates the associated geometry
  82202. * @param geometry the geometry to be updated
  82203. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82204. * @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
  82205. * @returns VertexData.
  82206. */
  82207. updateGeometry(geometry: Geometry): VertexData;
  82208. private _applyTo;
  82209. private _update;
  82210. /**
  82211. * Transforms each position and each normal of the vertexData according to the passed Matrix
  82212. * @param matrix the transforming matrix
  82213. * @returns the VertexData
  82214. */
  82215. transform(matrix: Matrix): VertexData;
  82216. /**
  82217. * Merges the passed VertexData into the current one
  82218. * @param other the VertexData to be merged into the current one
  82219. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  82220. * @returns the modified VertexData
  82221. */
  82222. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  82223. private _mergeElement;
  82224. private _validate;
  82225. /**
  82226. * Serializes the VertexData
  82227. * @returns a serialized object
  82228. */
  82229. serialize(): any;
  82230. /**
  82231. * Extracts the vertexData from a mesh
  82232. * @param mesh the mesh from which to extract the VertexData
  82233. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  82234. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82235. * @returns the object VertexData associated to the passed mesh
  82236. */
  82237. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82238. /**
  82239. * Extracts the vertexData from the geometry
  82240. * @param geometry the geometry from which to extract the VertexData
  82241. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  82242. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82243. * @returns the object VertexData associated to the passed mesh
  82244. */
  82245. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82246. private static _ExtractFrom;
  82247. /**
  82248. * Creates the VertexData for a Ribbon
  82249. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  82250. * * pathArray array of paths, each of which an array of successive Vector3
  82251. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  82252. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  82253. * * 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
  82254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82255. * * 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)
  82256. * * 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)
  82257. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  82258. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  82259. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  82260. * @returns the VertexData of the ribbon
  82261. */
  82262. static CreateRibbon(options: {
  82263. pathArray: Vector3[][];
  82264. closeArray?: boolean;
  82265. closePath?: boolean;
  82266. offset?: number;
  82267. sideOrientation?: number;
  82268. frontUVs?: Vector4;
  82269. backUVs?: Vector4;
  82270. invertUV?: boolean;
  82271. uvs?: Vector2[];
  82272. colors?: Color4[];
  82273. }): VertexData;
  82274. /**
  82275. * Creates the VertexData for a box
  82276. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82277. * * size sets the width, height and depth of the box to the value of size, optional default 1
  82278. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  82279. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  82280. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  82281. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  82282. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  82283. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82284. * * 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)
  82285. * * 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)
  82286. * @returns the VertexData of the box
  82287. */
  82288. static CreateBox(options: {
  82289. size?: number;
  82290. width?: number;
  82291. height?: number;
  82292. depth?: number;
  82293. faceUV?: Vector4[];
  82294. faceColors?: Color4[];
  82295. sideOrientation?: number;
  82296. frontUVs?: Vector4;
  82297. backUVs?: Vector4;
  82298. }): VertexData;
  82299. /**
  82300. * Creates the VertexData for an ellipsoid, defaults to a sphere
  82301. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82302. * * segments sets the number of horizontal strips optional, default 32
  82303. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  82304. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  82305. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  82306. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  82307. * * 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
  82308. * * 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
  82309. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82310. * * 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)
  82311. * * 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)
  82312. * @returns the VertexData of the ellipsoid
  82313. */
  82314. static CreateSphere(options: {
  82315. segments?: number;
  82316. diameter?: number;
  82317. diameterX?: number;
  82318. diameterY?: number;
  82319. diameterZ?: number;
  82320. arc?: number;
  82321. slice?: number;
  82322. sideOrientation?: number;
  82323. frontUVs?: Vector4;
  82324. backUVs?: Vector4;
  82325. }): VertexData;
  82326. /**
  82327. * Creates the VertexData for a cylinder, cone or prism
  82328. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82329. * * height sets the height (y direction) of the cylinder, optional, default 2
  82330. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  82331. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  82332. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  82333. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82334. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  82335. * * 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
  82336. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82337. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82338. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82339. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82341. * * 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)
  82342. * * 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)
  82343. * @returns the VertexData of the cylinder, cone or prism
  82344. */
  82345. static CreateCylinder(options: {
  82346. height?: number;
  82347. diameterTop?: number;
  82348. diameterBottom?: number;
  82349. diameter?: number;
  82350. tessellation?: number;
  82351. subdivisions?: number;
  82352. arc?: number;
  82353. faceColors?: Color4[];
  82354. faceUV?: Vector4[];
  82355. hasRings?: boolean;
  82356. enclose?: boolean;
  82357. sideOrientation?: number;
  82358. frontUVs?: Vector4;
  82359. backUVs?: Vector4;
  82360. }): VertexData;
  82361. /**
  82362. * Creates the VertexData for a torus
  82363. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82364. * * diameter the diameter of the torus, optional default 1
  82365. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82366. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82367. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82368. * * 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)
  82369. * * 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)
  82370. * @returns the VertexData of the torus
  82371. */
  82372. static CreateTorus(options: {
  82373. diameter?: number;
  82374. thickness?: number;
  82375. tessellation?: number;
  82376. sideOrientation?: number;
  82377. frontUVs?: Vector4;
  82378. backUVs?: Vector4;
  82379. }): VertexData;
  82380. /**
  82381. * Creates the VertexData of the LineSystem
  82382. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  82383. * - lines an array of lines, each line being an array of successive Vector3
  82384. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  82385. * @returns the VertexData of the LineSystem
  82386. */
  82387. static CreateLineSystem(options: {
  82388. lines: Vector3[][];
  82389. colors?: Nullable<Color4[][]>;
  82390. }): VertexData;
  82391. /**
  82392. * Create the VertexData for a DashedLines
  82393. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  82394. * - points an array successive Vector3
  82395. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  82396. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  82397. * - dashNb the intended total number of dashes, optional, default 200
  82398. * @returns the VertexData for the DashedLines
  82399. */
  82400. static CreateDashedLines(options: {
  82401. points: Vector3[];
  82402. dashSize?: number;
  82403. gapSize?: number;
  82404. dashNb?: number;
  82405. }): VertexData;
  82406. /**
  82407. * Creates the VertexData for a Ground
  82408. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82409. * - width the width (x direction) of the ground, optional, default 1
  82410. * - height the height (z direction) of the ground, optional, default 1
  82411. * - subdivisions the number of subdivisions per side, optional, default 1
  82412. * @returns the VertexData of the Ground
  82413. */
  82414. static CreateGround(options: {
  82415. width?: number;
  82416. height?: number;
  82417. subdivisions?: number;
  82418. subdivisionsX?: number;
  82419. subdivisionsY?: number;
  82420. }): VertexData;
  82421. /**
  82422. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  82423. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82424. * * xmin the ground minimum X coordinate, optional, default -1
  82425. * * zmin the ground minimum Z coordinate, optional, default -1
  82426. * * xmax the ground maximum X coordinate, optional, default 1
  82427. * * zmax the ground maximum Z coordinate, optional, default 1
  82428. * * 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}
  82429. * * 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}
  82430. * @returns the VertexData of the TiledGround
  82431. */
  82432. static CreateTiledGround(options: {
  82433. xmin: number;
  82434. zmin: number;
  82435. xmax: number;
  82436. zmax: number;
  82437. subdivisions?: {
  82438. w: number;
  82439. h: number;
  82440. };
  82441. precision?: {
  82442. w: number;
  82443. h: number;
  82444. };
  82445. }): VertexData;
  82446. /**
  82447. * Creates the VertexData of the Ground designed from a heightmap
  82448. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  82449. * * width the width (x direction) of the ground
  82450. * * height the height (z direction) of the ground
  82451. * * subdivisions the number of subdivisions per side
  82452. * * minHeight the minimum altitude on the ground, optional, default 0
  82453. * * maxHeight the maximum altitude on the ground, optional default 1
  82454. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  82455. * * buffer the array holding the image color data
  82456. * * bufferWidth the width of image
  82457. * * bufferHeight the height of image
  82458. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  82459. * @returns the VertexData of the Ground designed from a heightmap
  82460. */
  82461. static CreateGroundFromHeightMap(options: {
  82462. width: number;
  82463. height: number;
  82464. subdivisions: number;
  82465. minHeight: number;
  82466. maxHeight: number;
  82467. colorFilter: Color3;
  82468. buffer: Uint8Array;
  82469. bufferWidth: number;
  82470. bufferHeight: number;
  82471. alphaFilter: number;
  82472. }): VertexData;
  82473. /**
  82474. * Creates the VertexData for a Plane
  82475. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  82476. * * size sets the width and height of the plane to the value of size, optional default 1
  82477. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  82478. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  82479. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82480. * * 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)
  82481. * * 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)
  82482. * @returns the VertexData of the box
  82483. */
  82484. static CreatePlane(options: {
  82485. size?: number;
  82486. width?: number;
  82487. height?: number;
  82488. sideOrientation?: number;
  82489. frontUVs?: Vector4;
  82490. backUVs?: Vector4;
  82491. }): VertexData;
  82492. /**
  82493. * Creates the VertexData of the Disc or regular Polygon
  82494. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  82495. * * radius the radius of the disc, optional default 0.5
  82496. * * tessellation the number of polygon sides, optional, default 64
  82497. * * 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
  82498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82499. * * 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)
  82500. * * 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)
  82501. * @returns the VertexData of the box
  82502. */
  82503. static CreateDisc(options: {
  82504. radius?: number;
  82505. tessellation?: number;
  82506. arc?: number;
  82507. sideOrientation?: number;
  82508. frontUVs?: Vector4;
  82509. backUVs?: Vector4;
  82510. }): VertexData;
  82511. /**
  82512. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  82513. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  82514. * @param polygon a mesh built from polygonTriangulation.build()
  82515. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82516. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82517. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82518. * @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)
  82519. * @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)
  82520. * @returns the VertexData of the Polygon
  82521. */
  82522. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  82523. /**
  82524. * Creates the VertexData of the IcoSphere
  82525. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  82526. * * radius the radius of the IcoSphere, optional default 1
  82527. * * radiusX allows stretching in the x direction, optional, default radius
  82528. * * radiusY allows stretching in the y direction, optional, default radius
  82529. * * radiusZ allows stretching in the z direction, optional, default radius
  82530. * * flat when true creates a flat shaded mesh, optional, default true
  82531. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82532. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82533. * * 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)
  82534. * * 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)
  82535. * @returns the VertexData of the IcoSphere
  82536. */
  82537. static CreateIcoSphere(options: {
  82538. radius?: number;
  82539. radiusX?: number;
  82540. radiusY?: number;
  82541. radiusZ?: number;
  82542. flat?: boolean;
  82543. subdivisions?: number;
  82544. sideOrientation?: number;
  82545. frontUVs?: Vector4;
  82546. backUVs?: Vector4;
  82547. }): VertexData;
  82548. /**
  82549. * Creates the VertexData for a Polyhedron
  82550. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  82551. * * type provided types are:
  82552. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  82553. * * 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)
  82554. * * size the size of the IcoSphere, optional default 1
  82555. * * sizeX allows stretching in the x direction, optional, default size
  82556. * * sizeY allows stretching in the y direction, optional, default size
  82557. * * sizeZ allows stretching in the z direction, optional, default size
  82558. * * 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
  82559. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82560. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82561. * * flat when true creates a flat shaded mesh, optional, default true
  82562. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82563. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82564. * * 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)
  82565. * * 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)
  82566. * @returns the VertexData of the Polyhedron
  82567. */
  82568. static CreatePolyhedron(options: {
  82569. type?: number;
  82570. size?: number;
  82571. sizeX?: number;
  82572. sizeY?: number;
  82573. sizeZ?: number;
  82574. custom?: any;
  82575. faceUV?: Vector4[];
  82576. faceColors?: Color4[];
  82577. flat?: boolean;
  82578. sideOrientation?: number;
  82579. frontUVs?: Vector4;
  82580. backUVs?: Vector4;
  82581. }): VertexData;
  82582. /**
  82583. * Creates the VertexData for a TorusKnot
  82584. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  82585. * * radius the radius of the torus knot, optional, default 2
  82586. * * tube the thickness of the tube, optional, default 0.5
  82587. * * radialSegments the number of sides on each tube segments, optional, default 32
  82588. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  82589. * * p the number of windings around the z axis, optional, default 2
  82590. * * q the number of windings around the x axis, optional, default 3
  82591. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82592. * * 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)
  82593. * * 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)
  82594. * @returns the VertexData of the Torus Knot
  82595. */
  82596. static CreateTorusKnot(options: {
  82597. radius?: number;
  82598. tube?: number;
  82599. radialSegments?: number;
  82600. tubularSegments?: number;
  82601. p?: number;
  82602. q?: number;
  82603. sideOrientation?: number;
  82604. frontUVs?: Vector4;
  82605. backUVs?: Vector4;
  82606. }): VertexData;
  82607. /**
  82608. * Compute normals for given positions and indices
  82609. * @param positions an array of vertex positions, [...., x, y, z, ......]
  82610. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  82611. * @param normals an array of vertex normals, [...., x, y, z, ......]
  82612. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  82613. * * facetNormals : optional array of facet normals (vector3)
  82614. * * facetPositions : optional array of facet positions (vector3)
  82615. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  82616. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  82617. * * bInfo : optional bounding info, required for facetPartitioning computation
  82618. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  82619. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  82620. * * useRightHandedSystem: optional boolean to for right handed system computation
  82621. * * depthSort : optional boolean to enable the facet depth sort computation
  82622. * * distanceTo : optional Vector3 to compute the facet depth from this location
  82623. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  82624. */
  82625. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  82626. facetNormals?: any;
  82627. facetPositions?: any;
  82628. facetPartitioning?: any;
  82629. ratio?: number;
  82630. bInfo?: any;
  82631. bbSize?: Vector3;
  82632. subDiv?: any;
  82633. useRightHandedSystem?: boolean;
  82634. depthSort?: boolean;
  82635. distanceTo?: Vector3;
  82636. depthSortedFacets?: any;
  82637. }): void;
  82638. /** @hidden */
  82639. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  82640. /**
  82641. * Applies VertexData created from the imported parameters to the geometry
  82642. * @param parsedVertexData the parsed data from an imported file
  82643. * @param geometry the geometry to apply the VertexData to
  82644. */
  82645. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  82646. }
  82647. }
  82648. declare module BABYLON {
  82649. /**
  82650. * Class containing static functions to help procedurally build meshes
  82651. */
  82652. export class DiscBuilder {
  82653. /**
  82654. * Creates a plane polygonal mesh. By default, this is a disc
  82655. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  82656. * * 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
  82657. * * 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
  82658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  82660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82661. * @param name defines the name of the mesh
  82662. * @param options defines the options used to create the mesh
  82663. * @param scene defines the hosting scene
  82664. * @returns the plane polygonal mesh
  82665. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  82666. */
  82667. static CreateDisc(name: string, options: {
  82668. radius?: number;
  82669. tessellation?: number;
  82670. arc?: number;
  82671. updatable?: boolean;
  82672. sideOrientation?: number;
  82673. frontUVs?: Vector4;
  82674. backUVs?: Vector4;
  82675. }, scene?: Nullable<Scene>): Mesh;
  82676. }
  82677. }
  82678. declare module BABYLON {
  82679. /**
  82680. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  82681. *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.
  82682. * The SPS is also a particle system. It provides some methods to manage the particles.
  82683. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  82684. *
  82685. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  82686. */
  82687. export class SolidParticleSystem implements IDisposable {
  82688. /**
  82689. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  82690. * Example : var p = SPS.particles[i];
  82691. */
  82692. particles: SolidParticle[];
  82693. /**
  82694. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  82695. */
  82696. nbParticles: number;
  82697. /**
  82698. * If the particles must ever face the camera (default false). Useful for planar particles.
  82699. */
  82700. billboard: boolean;
  82701. /**
  82702. * Recompute normals when adding a shape
  82703. */
  82704. recomputeNormals: boolean;
  82705. /**
  82706. * This a counter ofr your own usage. It's not set by any SPS functions.
  82707. */
  82708. counter: number;
  82709. /**
  82710. * The SPS name. This name is also given to the underlying mesh.
  82711. */
  82712. name: string;
  82713. /**
  82714. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  82715. */
  82716. mesh: Mesh;
  82717. /**
  82718. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  82719. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  82720. */
  82721. vars: any;
  82722. /**
  82723. * This array is populated when the SPS is set as 'pickable'.
  82724. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  82725. * Each element of this array is an object `{idx: int, faceId: int}`.
  82726. * `idx` is the picked particle index in the `SPS.particles` array
  82727. * `faceId` is the picked face index counted within this particle.
  82728. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  82729. */
  82730. pickedParticles: {
  82731. idx: number;
  82732. faceId: number;
  82733. }[];
  82734. /**
  82735. * This array is populated when `enableDepthSort` is set to true.
  82736. * Each element of this array is an instance of the class DepthSortedParticle.
  82737. */
  82738. depthSortedParticles: DepthSortedParticle[];
  82739. /**
  82740. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  82741. * @hidden
  82742. */
  82743. _bSphereOnly: boolean;
  82744. /**
  82745. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  82746. * @hidden
  82747. */
  82748. _bSphereRadiusFactor: number;
  82749. private _scene;
  82750. private _positions;
  82751. private _indices;
  82752. private _normals;
  82753. private _colors;
  82754. private _uvs;
  82755. private _indices32;
  82756. private _positions32;
  82757. private _normals32;
  82758. private _fixedNormal32;
  82759. private _colors32;
  82760. private _uvs32;
  82761. private _index;
  82762. private _updatable;
  82763. private _pickable;
  82764. private _isVisibilityBoxLocked;
  82765. private _alwaysVisible;
  82766. private _depthSort;
  82767. private _shapeCounter;
  82768. private _copy;
  82769. private _color;
  82770. private _computeParticleColor;
  82771. private _computeParticleTexture;
  82772. private _computeParticleRotation;
  82773. private _computeParticleVertex;
  82774. private _computeBoundingBox;
  82775. private _depthSortParticles;
  82776. private _camera;
  82777. private _mustUnrotateFixedNormals;
  82778. private _particlesIntersect;
  82779. private _needs32Bits;
  82780. /**
  82781. * Creates a SPS (Solid Particle System) object.
  82782. * @param name (String) is the SPS name, this will be the underlying mesh name.
  82783. * @param scene (Scene) is the scene in which the SPS is added.
  82784. * @param options defines the options of the sps e.g.
  82785. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  82786. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  82787. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  82788. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  82789. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  82790. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  82791. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  82792. */
  82793. constructor(name: string, scene: Scene, options?: {
  82794. updatable?: boolean;
  82795. isPickable?: boolean;
  82796. enableDepthSort?: boolean;
  82797. particleIntersection?: boolean;
  82798. boundingSphereOnly?: boolean;
  82799. bSphereRadiusFactor?: number;
  82800. });
  82801. /**
  82802. * Builds the SPS underlying mesh. Returns a standard Mesh.
  82803. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  82804. * @returns the created mesh
  82805. */
  82806. buildMesh(): Mesh;
  82807. /**
  82808. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  82809. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  82810. * Thus the particles generated from `digest()` have their property `position` set yet.
  82811. * @param mesh ( Mesh ) is the mesh to be digested
  82812. * @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
  82813. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  82814. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  82815. * @returns the current SPS
  82816. */
  82817. digest(mesh: Mesh, options?: {
  82818. facetNb?: number;
  82819. number?: number;
  82820. delta?: number;
  82821. }): SolidParticleSystem;
  82822. private _unrotateFixedNormals;
  82823. private _resetCopy;
  82824. private _meshBuilder;
  82825. private _posToShape;
  82826. private _uvsToShapeUV;
  82827. private _addParticle;
  82828. /**
  82829. * Adds some particles to the SPS from the model shape. Returns the shape id.
  82830. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  82831. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  82832. * @param nb (positive integer) the number of particles to be created from this model
  82833. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  82834. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  82835. * @returns the number of shapes in the system
  82836. */
  82837. addShape(mesh: Mesh, nb: number, options?: {
  82838. positionFunction?: any;
  82839. vertexFunction?: any;
  82840. }): number;
  82841. private _rebuildParticle;
  82842. /**
  82843. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  82844. * @returns the SPS.
  82845. */
  82846. rebuildMesh(): SolidParticleSystem;
  82847. /**
  82848. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  82849. * This method calls `updateParticle()` for each particle of the SPS.
  82850. * For an animated SPS, it is usually called within the render loop.
  82851. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  82852. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  82853. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  82854. * @returns the SPS.
  82855. */
  82856. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  82857. /**
  82858. * Disposes the SPS.
  82859. */
  82860. dispose(): void;
  82861. /**
  82862. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  82863. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82864. * @returns the SPS.
  82865. */
  82866. refreshVisibleSize(): SolidParticleSystem;
  82867. /**
  82868. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  82869. * @param size the size (float) of the visibility box
  82870. * note : this doesn't lock the SPS mesh bounding box.
  82871. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82872. */
  82873. setVisibilityBox(size: number): void;
  82874. /**
  82875. * Gets whether the SPS as always visible or not
  82876. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82877. */
  82878. /**
  82879. * Sets the SPS as always visible or not
  82880. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82881. */
  82882. isAlwaysVisible: boolean;
  82883. /**
  82884. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82885. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82886. */
  82887. /**
  82888. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82889. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82890. */
  82891. isVisibilityBoxLocked: boolean;
  82892. /**
  82893. * Tells to `setParticles()` to compute the particle rotations or not.
  82894. * Default value : true. The SPS is faster when it's set to false.
  82895. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82896. */
  82897. /**
  82898. * Gets if `setParticles()` computes the particle rotations or not.
  82899. * Default value : true. The SPS is faster when it's set to false.
  82900. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82901. */
  82902. computeParticleRotation: boolean;
  82903. /**
  82904. * Tells to `setParticles()` to compute the particle colors or not.
  82905. * Default value : true. The SPS is faster when it's set to false.
  82906. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82907. */
  82908. /**
  82909. * Gets if `setParticles()` computes the particle colors or not.
  82910. * Default value : true. The SPS is faster when it's set to false.
  82911. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82912. */
  82913. computeParticleColor: boolean;
  82914. /**
  82915. * Gets if `setParticles()` computes the particle textures or not.
  82916. * Default value : true. The SPS is faster when it's set to false.
  82917. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  82918. */
  82919. computeParticleTexture: boolean;
  82920. /**
  82921. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  82922. * Default value : false. The SPS is faster when it's set to false.
  82923. * Note : the particle custom vertex positions aren't stored values.
  82924. */
  82925. /**
  82926. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  82927. * Default value : false. The SPS is faster when it's set to false.
  82928. * Note : the particle custom vertex positions aren't stored values.
  82929. */
  82930. computeParticleVertex: boolean;
  82931. /**
  82932. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  82933. */
  82934. /**
  82935. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  82936. */
  82937. computeBoundingBox: boolean;
  82938. /**
  82939. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  82940. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82941. * Default : `true`
  82942. */
  82943. /**
  82944. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  82945. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82946. * Default : `true`
  82947. */
  82948. depthSortParticles: boolean;
  82949. /**
  82950. * This function does nothing. It may be overwritten to set all the particle first values.
  82951. * The SPS doesn't call this function, you may have to call it by your own.
  82952. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82953. */
  82954. initParticles(): void;
  82955. /**
  82956. * This function does nothing. It may be overwritten to recycle a particle.
  82957. * The SPS doesn't call this function, you may have to call it by your own.
  82958. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82959. * @param particle The particle to recycle
  82960. * @returns the recycled particle
  82961. */
  82962. recycleParticle(particle: SolidParticle): SolidParticle;
  82963. /**
  82964. * Updates a particle : this function should be overwritten by the user.
  82965. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  82966. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82967. * @example : just set a particle position or velocity and recycle conditions
  82968. * @param particle The particle to update
  82969. * @returns the updated particle
  82970. */
  82971. updateParticle(particle: SolidParticle): SolidParticle;
  82972. /**
  82973. * Updates a vertex of a particle : it can be overwritten by the user.
  82974. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  82975. * @param particle the current particle
  82976. * @param vertex the current index of the current particle
  82977. * @param pt the index of the current vertex in the particle shape
  82978. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  82979. * @example : just set a vertex particle position
  82980. * @returns the updated vertex
  82981. */
  82982. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  82983. /**
  82984. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  82985. * This does nothing and may be overwritten by the user.
  82986. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82987. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82988. * @param update the boolean update value actually passed to setParticles()
  82989. */
  82990. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82991. /**
  82992. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  82993. * This will be passed three parameters.
  82994. * This does nothing and may be overwritten by the user.
  82995. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82996. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82997. * @param update the boolean update value actually passed to setParticles()
  82998. */
  82999. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83000. }
  83001. }
  83002. declare module BABYLON {
  83003. /**
  83004. * Represents one particle of a solid particle system.
  83005. */
  83006. export class SolidParticle {
  83007. /**
  83008. * particle global index
  83009. */
  83010. idx: number;
  83011. /**
  83012. * The color of the particle
  83013. */
  83014. color: Nullable<Color4>;
  83015. /**
  83016. * The world space position of the particle.
  83017. */
  83018. position: Vector3;
  83019. /**
  83020. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83021. */
  83022. rotation: Vector3;
  83023. /**
  83024. * The world space rotation quaternion of the particle.
  83025. */
  83026. rotationQuaternion: Nullable<Quaternion>;
  83027. /**
  83028. * The scaling of the particle.
  83029. */
  83030. scaling: Vector3;
  83031. /**
  83032. * The uvs of the particle.
  83033. */
  83034. uvs: Vector4;
  83035. /**
  83036. * The current speed of the particle.
  83037. */
  83038. velocity: Vector3;
  83039. /**
  83040. * The pivot point in the particle local space.
  83041. */
  83042. pivot: Vector3;
  83043. /**
  83044. * Must the particle be translated from its pivot point in its local space ?
  83045. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83046. * Default : false
  83047. */
  83048. translateFromPivot: boolean;
  83049. /**
  83050. * Is the particle active or not ?
  83051. */
  83052. alive: boolean;
  83053. /**
  83054. * Is the particle visible or not ?
  83055. */
  83056. isVisible: boolean;
  83057. /**
  83058. * Index of this particle in the global "positions" array (Internal use)
  83059. * @hidden
  83060. */
  83061. _pos: number;
  83062. /**
  83063. * @hidden Index of this particle in the global "indices" array (Internal use)
  83064. */
  83065. _ind: number;
  83066. /**
  83067. * @hidden ModelShape of this particle (Internal use)
  83068. */
  83069. _model: ModelShape;
  83070. /**
  83071. * ModelShape id of this particle
  83072. */
  83073. shapeId: number;
  83074. /**
  83075. * Index of the particle in its shape id (Internal use)
  83076. */
  83077. idxInShape: number;
  83078. /**
  83079. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83080. */
  83081. _modelBoundingInfo: BoundingInfo;
  83082. /**
  83083. * @hidden Particle BoundingInfo object (Internal use)
  83084. */
  83085. _boundingInfo: BoundingInfo;
  83086. /**
  83087. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  83088. */
  83089. _sps: SolidParticleSystem;
  83090. /**
  83091. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  83092. */
  83093. _stillInvisible: boolean;
  83094. /**
  83095. * @hidden Last computed particle rotation matrix
  83096. */
  83097. _rotationMatrix: number[];
  83098. /**
  83099. * Parent particle Id, if any.
  83100. * Default null.
  83101. */
  83102. parentId: Nullable<number>;
  83103. /**
  83104. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  83105. * The possible values are :
  83106. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83107. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83108. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83109. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83110. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83111. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  83112. * */
  83113. cullingStrategy: number;
  83114. /**
  83115. * @hidden Internal global position in the SPS.
  83116. */
  83117. _globalPosition: Vector3;
  83118. /**
  83119. * Creates a Solid Particle object.
  83120. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  83121. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  83122. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  83123. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  83124. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  83125. * @param shapeId (integer) is the model shape identifier in the SPS.
  83126. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  83127. * @param sps defines the sps it is associated to
  83128. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  83129. */
  83130. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  83131. /**
  83132. * Legacy support, changed scale to scaling
  83133. */
  83134. /**
  83135. * Legacy support, changed scale to scaling
  83136. */
  83137. scale: Vector3;
  83138. /**
  83139. * Legacy support, changed quaternion to rotationQuaternion
  83140. */
  83141. /**
  83142. * Legacy support, changed quaternion to rotationQuaternion
  83143. */
  83144. quaternion: Nullable<Quaternion>;
  83145. /**
  83146. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  83147. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  83148. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  83149. * @returns true if it intersects
  83150. */
  83151. intersectsMesh(target: Mesh | SolidParticle): boolean;
  83152. /**
  83153. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  83154. * A particle is in the frustum if its bounding box intersects the frustum
  83155. * @param frustumPlanes defines the frustum to test
  83156. * @returns true if the particle is in the frustum planes
  83157. */
  83158. isInFrustum(frustumPlanes: Plane[]): boolean;
  83159. /**
  83160. * get the rotation matrix of the particle
  83161. * @hidden
  83162. */
  83163. getRotationMatrix(m: Matrix): void;
  83164. }
  83165. /**
  83166. * Represents the shape of the model used by one particle of a solid particle system.
  83167. * SPS internal tool, don't use it manually.
  83168. */
  83169. export class ModelShape {
  83170. /**
  83171. * The shape id
  83172. * @hidden
  83173. */
  83174. shapeID: number;
  83175. /**
  83176. * flat array of model positions (internal use)
  83177. * @hidden
  83178. */
  83179. _shape: Vector3[];
  83180. /**
  83181. * flat array of model UVs (internal use)
  83182. * @hidden
  83183. */
  83184. _shapeUV: number[];
  83185. /**
  83186. * length of the shape in the model indices array (internal use)
  83187. * @hidden
  83188. */
  83189. _indicesLength: number;
  83190. /**
  83191. * Custom position function (internal use)
  83192. * @hidden
  83193. */
  83194. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  83195. /**
  83196. * Custom vertex function (internal use)
  83197. * @hidden
  83198. */
  83199. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  83200. /**
  83201. * 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.
  83202. * SPS internal tool, don't use it manually.
  83203. * @hidden
  83204. */
  83205. 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>);
  83206. }
  83207. /**
  83208. * Represents a Depth Sorted Particle in the solid particle system.
  83209. */
  83210. export class DepthSortedParticle {
  83211. /**
  83212. * Index of the particle in the "indices" array
  83213. */
  83214. ind: number;
  83215. /**
  83216. * Length of the particle shape in the "indices" array
  83217. */
  83218. indicesLength: number;
  83219. /**
  83220. * Squared distance from the particle to the camera
  83221. */
  83222. sqDistance: number;
  83223. }
  83224. }
  83225. declare module BABYLON {
  83226. /**
  83227. * Class used to store all common mesh properties
  83228. */
  83229. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  83230. /** No occlusion */
  83231. static OCCLUSION_TYPE_NONE: number;
  83232. /** Occlusion set to optimisitic */
  83233. static OCCLUSION_TYPE_OPTIMISTIC: number;
  83234. /** Occlusion set to strict */
  83235. static OCCLUSION_TYPE_STRICT: number;
  83236. /** Use an accurante occlusion algorithm */
  83237. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  83238. /** Use a conservative occlusion algorithm */
  83239. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  83240. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83241. * Test order :
  83242. * Is the bounding sphere outside the frustum ?
  83243. * If not, are the bounding box vertices outside the frustum ?
  83244. * It not, then the cullable object is in the frustum.
  83245. */
  83246. static readonly CULLINGSTRATEGY_STANDARD: number;
  83247. /** Culling strategy : Bounding Sphere Only.
  83248. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83249. * It's also less accurate than the standard because some not visible objects can still be selected.
  83250. * Test : is the bounding sphere outside the frustum ?
  83251. * If not, then the cullable object is in the frustum.
  83252. */
  83253. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  83254. /** Culling strategy : Optimistic Inclusion.
  83255. * This in an inclusion test first, then the standard exclusion test.
  83256. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83257. * 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.
  83258. * Anyway, it's as accurate as the standard strategy.
  83259. * Test :
  83260. * Is the cullable object bounding sphere center in the frustum ?
  83261. * If not, apply the default culling strategy.
  83262. */
  83263. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  83264. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83265. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83266. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83267. * 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.
  83268. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83269. * Test :
  83270. * Is the cullable object bounding sphere center in the frustum ?
  83271. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83272. */
  83273. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  83274. /**
  83275. * No billboard
  83276. */
  83277. static readonly BILLBOARDMODE_NONE: number;
  83278. /** Billboard on X axis */
  83279. static readonly BILLBOARDMODE_X: number;
  83280. /** Billboard on Y axis */
  83281. static readonly BILLBOARDMODE_Y: number;
  83282. /** Billboard on Z axis */
  83283. static readonly BILLBOARDMODE_Z: number;
  83284. /** Billboard on all axes */
  83285. static readonly BILLBOARDMODE_ALL: number;
  83286. private _facetData;
  83287. /**
  83288. * The culling strategy to use to check whether the mesh must be rendered or not.
  83289. * This value can be changed at any time and will be used on the next render mesh selection.
  83290. * The possible values are :
  83291. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83292. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83293. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83294. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83295. * Please read each static variable documentation to get details about the culling process.
  83296. * */
  83297. cullingStrategy: number;
  83298. /**
  83299. * Gets the number of facets in the mesh
  83300. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83301. */
  83302. readonly facetNb: number;
  83303. /**
  83304. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  83305. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83306. */
  83307. partitioningSubdivisions: number;
  83308. /**
  83309. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  83310. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  83311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83312. */
  83313. partitioningBBoxRatio: number;
  83314. /**
  83315. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  83316. * Works only for updatable meshes.
  83317. * Doesn't work with multi-materials
  83318. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83319. */
  83320. mustDepthSortFacets: boolean;
  83321. /**
  83322. * The location (Vector3) where the facet depth sort must be computed from.
  83323. * By default, the active camera position.
  83324. * Used only when facet depth sort is enabled
  83325. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83326. */
  83327. facetDepthSortFrom: Vector3;
  83328. /**
  83329. * gets a boolean indicating if facetData is enabled
  83330. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83331. */
  83332. readonly isFacetDataEnabled: boolean;
  83333. /** @hidden */
  83334. _updateNonUniformScalingState(value: boolean): boolean;
  83335. /**
  83336. * An event triggered when this mesh collides with another one
  83337. */
  83338. onCollideObservable: Observable<AbstractMesh>;
  83339. private _onCollideObserver;
  83340. /** Set a function to call when this mesh collides with another one */
  83341. onCollide: () => void;
  83342. /**
  83343. * An event triggered when the collision's position changes
  83344. */
  83345. onCollisionPositionChangeObservable: Observable<Vector3>;
  83346. private _onCollisionPositionChangeObserver;
  83347. /** Set a function to call when the collision's position changes */
  83348. onCollisionPositionChange: () => void;
  83349. /**
  83350. * An event triggered when material is changed
  83351. */
  83352. onMaterialChangedObservable: Observable<AbstractMesh>;
  83353. /**
  83354. * Gets or sets the orientation for POV movement & rotation
  83355. */
  83356. definedFacingForward: boolean;
  83357. /** @hidden */
  83358. _occlusionQuery: Nullable<WebGLQuery>;
  83359. private _visibility;
  83360. /** @hidden */
  83361. _isActive: boolean;
  83362. /** @hidden */
  83363. _renderingGroup: RenderingGroup;
  83364. /**
  83365. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83366. */
  83367. /**
  83368. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83369. */
  83370. visibility: number;
  83371. /** Gets or sets the alpha index used to sort transparent meshes
  83372. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83373. */
  83374. alphaIndex: number;
  83375. /**
  83376. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83377. */
  83378. isVisible: boolean;
  83379. /**
  83380. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83381. */
  83382. isPickable: boolean;
  83383. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83384. showSubMeshesBoundingBox: boolean;
  83385. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83386. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83387. */
  83388. isBlocker: boolean;
  83389. /**
  83390. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83391. */
  83392. enablePointerMoveEvents: boolean;
  83393. /**
  83394. * Specifies the rendering group id for this mesh (0 by default)
  83395. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83396. */
  83397. renderingGroupId: number;
  83398. private _material;
  83399. /** Gets or sets current material */
  83400. material: Nullable<Material>;
  83401. private _receiveShadows;
  83402. /**
  83403. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  83404. * @see http://doc.babylonjs.com/babylon101/shadows
  83405. */
  83406. receiveShadows: boolean;
  83407. /** Defines color to use when rendering outline */
  83408. outlineColor: Color3;
  83409. /** Define width to use when rendering outline */
  83410. outlineWidth: number;
  83411. /** Defines color to use when rendering overlay */
  83412. overlayColor: Color3;
  83413. /** Defines alpha to use when rendering overlay */
  83414. overlayAlpha: number;
  83415. private _hasVertexAlpha;
  83416. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  83417. hasVertexAlpha: boolean;
  83418. private _useVertexColors;
  83419. /** 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) */
  83420. useVertexColors: boolean;
  83421. private _computeBonesUsingShaders;
  83422. /**
  83423. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  83424. */
  83425. computeBonesUsingShaders: boolean;
  83426. private _numBoneInfluencers;
  83427. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  83428. numBoneInfluencers: number;
  83429. private _applyFog;
  83430. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  83431. applyFog: boolean;
  83432. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83433. useOctreeForRenderingSelection: boolean;
  83434. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83435. useOctreeForPicking: boolean;
  83436. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83437. useOctreeForCollisions: boolean;
  83438. private _layerMask;
  83439. /**
  83440. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  83441. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  83442. */
  83443. layerMask: number;
  83444. /**
  83445. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83446. */
  83447. alwaysSelectAsActiveMesh: boolean;
  83448. /**
  83449. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  83450. */
  83451. doNotSyncBoundingInfo: boolean;
  83452. /**
  83453. * Gets or sets the current action manager
  83454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83455. */
  83456. actionManager: Nullable<AbstractActionManager>;
  83457. private _checkCollisions;
  83458. private _collisionMask;
  83459. private _collisionGroup;
  83460. /**
  83461. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83462. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83463. */
  83464. ellipsoid: Vector3;
  83465. /**
  83466. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83467. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83468. */
  83469. ellipsoidOffset: Vector3;
  83470. private _collider;
  83471. private _oldPositionForCollisions;
  83472. private _diffPositionForCollisions;
  83473. /**
  83474. * Gets or sets a collision mask used to mask collisions (default is -1).
  83475. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83476. */
  83477. collisionMask: number;
  83478. /**
  83479. * Gets or sets the current collision group mask (-1 by default).
  83480. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83481. */
  83482. collisionGroup: number;
  83483. /**
  83484. * Defines edge width used when edgesRenderer is enabled
  83485. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83486. */
  83487. edgesWidth: number;
  83488. /**
  83489. * Defines edge color used when edgesRenderer is enabled
  83490. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83491. */
  83492. edgesColor: Color4;
  83493. /** @hidden */
  83494. _edgesRenderer: Nullable<IEdgesRenderer>;
  83495. /** @hidden */
  83496. _masterMesh: Nullable<AbstractMesh>;
  83497. /** @hidden */
  83498. _boundingInfo: Nullable<BoundingInfo>;
  83499. /** @hidden */
  83500. _renderId: number;
  83501. /**
  83502. * Gets or sets the list of subMeshes
  83503. * @see http://doc.babylonjs.com/how_to/multi_materials
  83504. */
  83505. subMeshes: SubMesh[];
  83506. /** @hidden */
  83507. _intersectionsInProgress: AbstractMesh[];
  83508. /** @hidden */
  83509. _unIndexed: boolean;
  83510. /** @hidden */
  83511. _lightSources: Light[];
  83512. /** @hidden */
  83513. readonly _positions: Nullable<Vector3[]>;
  83514. /** @hidden */
  83515. _waitingActions: any;
  83516. /** @hidden */
  83517. _waitingFreezeWorldMatrix: Nullable<boolean>;
  83518. private _skeleton;
  83519. /** @hidden */
  83520. _bonesTransformMatrices: Nullable<Float32Array>;
  83521. /**
  83522. * Gets or sets a skeleton to apply skining transformations
  83523. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83524. */
  83525. skeleton: Nullable<Skeleton>;
  83526. /**
  83527. * An event triggered when the mesh is rebuilt.
  83528. */
  83529. onRebuildObservable: Observable<AbstractMesh>;
  83530. /**
  83531. * Creates a new AbstractMesh
  83532. * @param name defines the name of the mesh
  83533. * @param scene defines the hosting scene
  83534. */
  83535. constructor(name: string, scene?: Nullable<Scene>);
  83536. /**
  83537. * Returns the string "AbstractMesh"
  83538. * @returns "AbstractMesh"
  83539. */
  83540. getClassName(): string;
  83541. /**
  83542. * Gets a string representation of the current mesh
  83543. * @param fullDetails defines a boolean indicating if full details must be included
  83544. * @returns a string representation of the current mesh
  83545. */
  83546. toString(fullDetails?: boolean): string;
  83547. /**
  83548. * @hidden
  83549. */
  83550. protected _getEffectiveParent(): Nullable<Node>;
  83551. /** @hidden */
  83552. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83553. /** @hidden */
  83554. _rebuild(): void;
  83555. /** @hidden */
  83556. _resyncLightSources(): void;
  83557. /** @hidden */
  83558. _resyncLighSource(light: Light): void;
  83559. /** @hidden */
  83560. _unBindEffect(): void;
  83561. /** @hidden */
  83562. _removeLightSource(light: Light): void;
  83563. private _markSubMeshesAsDirty;
  83564. /** @hidden */
  83565. _markSubMeshesAsLightDirty(): void;
  83566. /** @hidden */
  83567. _markSubMeshesAsAttributesDirty(): void;
  83568. /** @hidden */
  83569. _markSubMeshesAsMiscDirty(): void;
  83570. /**
  83571. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  83572. */
  83573. scaling: Vector3;
  83574. /**
  83575. * Returns true if the mesh is blocked. Implemented by child classes
  83576. */
  83577. readonly isBlocked: boolean;
  83578. /**
  83579. * Returns the mesh itself by default. Implemented by child classes
  83580. * @param camera defines the camera to use to pick the right LOD level
  83581. * @returns the currentAbstractMesh
  83582. */
  83583. getLOD(camera: Camera): Nullable<AbstractMesh>;
  83584. /**
  83585. * Returns 0 by default. Implemented by child classes
  83586. * @returns an integer
  83587. */
  83588. getTotalVertices(): number;
  83589. /**
  83590. * Returns a positive integer : the total number of indices in this mesh geometry.
  83591. * @returns the numner of indices or zero if the mesh has no geometry.
  83592. */
  83593. getTotalIndices(): number;
  83594. /**
  83595. * Returns null by default. Implemented by child classes
  83596. * @returns null
  83597. */
  83598. getIndices(): Nullable<IndicesArray>;
  83599. /**
  83600. * Returns the array of the requested vertex data kind. Implemented by child classes
  83601. * @param kind defines the vertex data kind to use
  83602. * @returns null
  83603. */
  83604. getVerticesData(kind: string): Nullable<FloatArray>;
  83605. /**
  83606. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83607. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83608. * Note that a new underlying VertexBuffer object is created each call.
  83609. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83610. * @param kind defines vertex data kind:
  83611. * * VertexBuffer.PositionKind
  83612. * * VertexBuffer.UVKind
  83613. * * VertexBuffer.UV2Kind
  83614. * * VertexBuffer.UV3Kind
  83615. * * VertexBuffer.UV4Kind
  83616. * * VertexBuffer.UV5Kind
  83617. * * VertexBuffer.UV6Kind
  83618. * * VertexBuffer.ColorKind
  83619. * * VertexBuffer.MatricesIndicesKind
  83620. * * VertexBuffer.MatricesIndicesExtraKind
  83621. * * VertexBuffer.MatricesWeightsKind
  83622. * * VertexBuffer.MatricesWeightsExtraKind
  83623. * @param data defines the data source
  83624. * @param updatable defines if the data must be flagged as updatable (or static)
  83625. * @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
  83626. * @returns the current mesh
  83627. */
  83628. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83629. /**
  83630. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83631. * If the mesh has no geometry, it is simply returned as it is.
  83632. * @param kind defines vertex data kind:
  83633. * * VertexBuffer.PositionKind
  83634. * * VertexBuffer.UVKind
  83635. * * VertexBuffer.UV2Kind
  83636. * * VertexBuffer.UV3Kind
  83637. * * VertexBuffer.UV4Kind
  83638. * * VertexBuffer.UV5Kind
  83639. * * VertexBuffer.UV6Kind
  83640. * * VertexBuffer.ColorKind
  83641. * * VertexBuffer.MatricesIndicesKind
  83642. * * VertexBuffer.MatricesIndicesExtraKind
  83643. * * VertexBuffer.MatricesWeightsKind
  83644. * * VertexBuffer.MatricesWeightsExtraKind
  83645. * @param data defines the data source
  83646. * @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
  83647. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  83648. * @returns the current mesh
  83649. */
  83650. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  83651. /**
  83652. * Sets the mesh indices,
  83653. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83654. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  83655. * @param totalVertices Defines the total number of vertices
  83656. * @returns the current mesh
  83657. */
  83658. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  83659. /**
  83660. * Gets a boolean indicating if specific vertex data is present
  83661. * @param kind defines the vertex data kind to use
  83662. * @returns true is data kind is present
  83663. */
  83664. isVerticesDataPresent(kind: string): boolean;
  83665. /**
  83666. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  83667. * @returns a BoundingInfo
  83668. */
  83669. getBoundingInfo(): BoundingInfo;
  83670. /**
  83671. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83672. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83673. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83674. * @returns the current mesh
  83675. */
  83676. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  83677. /**
  83678. * Overwrite the current bounding info
  83679. * @param boundingInfo defines the new bounding info
  83680. * @returns the current mesh
  83681. */
  83682. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  83683. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  83684. readonly useBones: boolean;
  83685. /** @hidden */
  83686. _preActivate(): void;
  83687. /** @hidden */
  83688. _preActivateForIntermediateRendering(renderId: number): void;
  83689. /** @hidden */
  83690. _activate(renderId: number): boolean;
  83691. /** @hidden */
  83692. _freeze(): void;
  83693. /** @hidden */
  83694. _unFreeze(): void;
  83695. /**
  83696. * Gets the current world matrix
  83697. * @returns a Matrix
  83698. */
  83699. getWorldMatrix(): Matrix;
  83700. /** @hidden */
  83701. _getWorldMatrixDeterminant(): number;
  83702. /**
  83703. * Perform relative position change from the point of view of behind the front of the mesh.
  83704. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83705. * Supports definition of mesh facing forward or backward
  83706. * @param amountRight defines the distance on the right axis
  83707. * @param amountUp defines the distance on the up axis
  83708. * @param amountForward defines the distance on the forward axis
  83709. * @returns the current mesh
  83710. */
  83711. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  83712. /**
  83713. * Calculate relative position change from the point of view of behind the front of the mesh.
  83714. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83715. * Supports definition of mesh facing forward or backward
  83716. * @param amountRight defines the distance on the right axis
  83717. * @param amountUp defines the distance on the up axis
  83718. * @param amountForward defines the distance on the forward axis
  83719. * @returns the new displacement vector
  83720. */
  83721. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  83722. /**
  83723. * Perform relative rotation change from the point of view of behind the front of the mesh.
  83724. * Supports definition of mesh facing forward or backward
  83725. * @param flipBack defines the flip
  83726. * @param twirlClockwise defines the twirl
  83727. * @param tiltRight defines the tilt
  83728. * @returns the current mesh
  83729. */
  83730. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  83731. /**
  83732. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  83733. * Supports definition of mesh facing forward or backward.
  83734. * @param flipBack defines the flip
  83735. * @param twirlClockwise defines the twirl
  83736. * @param tiltRight defines the tilt
  83737. * @returns the new rotation vector
  83738. */
  83739. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  83740. /**
  83741. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  83742. * @param includeDescendants Include bounding info from descendants as well (true by default)
  83743. * @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
  83744. * @returns the new bounding vectors
  83745. */
  83746. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  83747. min: Vector3;
  83748. max: Vector3;
  83749. };
  83750. /**
  83751. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83752. * This means the mesh underlying bounding box and sphere are recomputed.
  83753. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83754. * @returns the current mesh
  83755. */
  83756. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  83757. /** @hidden */
  83758. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  83759. /** @hidden */
  83760. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  83761. /** @hidden */
  83762. _updateBoundingInfo(): AbstractMesh;
  83763. /** @hidden */
  83764. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  83765. /** @hidden */
  83766. protected _afterComputeWorldMatrix(): void;
  83767. /** @hidden */
  83768. readonly _effectiveMesh: AbstractMesh;
  83769. /**
  83770. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83771. * A mesh is in the frustum if its bounding box intersects the frustum
  83772. * @param frustumPlanes defines the frustum to test
  83773. * @returns true if the mesh is in the frustum planes
  83774. */
  83775. isInFrustum(frustumPlanes: Plane[]): boolean;
  83776. /**
  83777. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83778. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83779. * @param frustumPlanes defines the frustum to test
  83780. * @returns true if the mesh is completely in the frustum planes
  83781. */
  83782. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83783. /**
  83784. * True if the mesh intersects another mesh or a SolidParticle object
  83785. * @param mesh defines a target mesh or SolidParticle to test
  83786. * @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)
  83787. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83788. * @returns true if there is an intersection
  83789. */
  83790. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  83791. /**
  83792. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83793. * @param point defines the point to test
  83794. * @returns true if there is an intersection
  83795. */
  83796. intersectsPoint(point: Vector3): boolean;
  83797. /**
  83798. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83799. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83800. */
  83801. checkCollisions: boolean;
  83802. /**
  83803. * Gets Collider object used to compute collisions (not physics)
  83804. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83805. */
  83806. readonly collider: Collider;
  83807. /**
  83808. * Move the mesh using collision engine
  83809. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83810. * @param displacement defines the requested displacement vector
  83811. * @returns the current mesh
  83812. */
  83813. moveWithCollisions(displacement: Vector3): AbstractMesh;
  83814. private _onCollisionPositionChange;
  83815. /** @hidden */
  83816. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  83817. /** @hidden */
  83818. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  83819. /** @hidden */
  83820. _checkCollision(collider: Collider): AbstractMesh;
  83821. /** @hidden */
  83822. _generatePointsArray(): boolean;
  83823. /**
  83824. * Checks if the passed Ray intersects with the mesh
  83825. * @param ray defines the ray to use
  83826. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83827. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83828. * @returns the picking info
  83829. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83830. */
  83831. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  83832. /**
  83833. * Clones the current mesh
  83834. * @param name defines the mesh name
  83835. * @param newParent defines the new mesh parent
  83836. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83837. * @returns the new mesh
  83838. */
  83839. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83840. /**
  83841. * Disposes all the submeshes of the current meshnp
  83842. * @returns the current mesh
  83843. */
  83844. releaseSubMeshes(): AbstractMesh;
  83845. /**
  83846. * Releases resources associated with this abstract mesh.
  83847. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83848. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83849. */
  83850. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83851. /**
  83852. * Adds the passed mesh as a child to the current mesh
  83853. * @param mesh defines the child mesh
  83854. * @returns the current mesh
  83855. */
  83856. addChild(mesh: AbstractMesh): AbstractMesh;
  83857. /**
  83858. * Removes the passed mesh from the current mesh children list
  83859. * @param mesh defines the child mesh
  83860. * @returns the current mesh
  83861. */
  83862. removeChild(mesh: AbstractMesh): AbstractMesh;
  83863. /** @hidden */
  83864. private _initFacetData;
  83865. /**
  83866. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83867. * This method can be called within the render loop.
  83868. * 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
  83869. * @returns the current mesh
  83870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83871. */
  83872. updateFacetData(): AbstractMesh;
  83873. /**
  83874. * Returns the facetLocalNormals array.
  83875. * The normals are expressed in the mesh local spac
  83876. * @returns an array of Vector3
  83877. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83878. */
  83879. getFacetLocalNormals(): Vector3[];
  83880. /**
  83881. * Returns the facetLocalPositions array.
  83882. * The facet positions are expressed in the mesh local space
  83883. * @returns an array of Vector3
  83884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83885. */
  83886. getFacetLocalPositions(): Vector3[];
  83887. /**
  83888. * Returns the facetLocalPartioning array
  83889. * @returns an array of array of numbers
  83890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83891. */
  83892. getFacetLocalPartitioning(): number[][];
  83893. /**
  83894. * Returns the i-th facet position in the world system.
  83895. * This method allocates a new Vector3 per call
  83896. * @param i defines the facet index
  83897. * @returns a new Vector3
  83898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83899. */
  83900. getFacetPosition(i: number): Vector3;
  83901. /**
  83902. * Sets the reference Vector3 with the i-th facet position in the world system
  83903. * @param i defines the facet index
  83904. * @param ref defines the target vector
  83905. * @returns the current mesh
  83906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83907. */
  83908. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  83909. /**
  83910. * Returns the i-th facet normal in the world system.
  83911. * This method allocates a new Vector3 per call
  83912. * @param i defines the facet index
  83913. * @returns a new Vector3
  83914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83915. */
  83916. getFacetNormal(i: number): Vector3;
  83917. /**
  83918. * Sets the reference Vector3 with the i-th facet normal in the world system
  83919. * @param i defines the facet index
  83920. * @param ref defines the target vector
  83921. * @returns the current mesh
  83922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83923. */
  83924. getFacetNormalToRef(i: number, ref: Vector3): this;
  83925. /**
  83926. * 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)
  83927. * @param x defines x coordinate
  83928. * @param y defines y coordinate
  83929. * @param z defines z coordinate
  83930. * @returns the array of facet indexes
  83931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83932. */
  83933. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  83934. /**
  83935. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83936. * @param projected sets as the (x,y,z) world projection on the facet
  83937. * @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
  83938. * @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
  83939. * @param x defines x coordinate
  83940. * @param y defines y coordinate
  83941. * @param z defines z coordinate
  83942. * @returns the face index if found (or null instead)
  83943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83944. */
  83945. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83946. /**
  83947. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83948. * @param projected sets as the (x,y,z) local projection on the facet
  83949. * @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
  83950. * @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
  83951. * @param x defines x coordinate
  83952. * @param y defines y coordinate
  83953. * @param z defines z coordinate
  83954. * @returns the face index if found (or null instead)
  83955. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83956. */
  83957. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83958. /**
  83959. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83960. * @returns the parameters
  83961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83962. */
  83963. getFacetDataParameters(): any;
  83964. /**
  83965. * Disables the feature FacetData and frees the related memory
  83966. * @returns the current mesh
  83967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83968. */
  83969. disableFacetData(): AbstractMesh;
  83970. /**
  83971. * Updates the AbstractMesh indices array
  83972. * @param indices defines the data source
  83973. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83974. * @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)
  83975. * @returns the current mesh
  83976. */
  83977. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  83978. /**
  83979. * Creates new normals data for the mesh
  83980. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83981. * @returns the current mesh
  83982. */
  83983. createNormals(updatable: boolean): AbstractMesh;
  83984. /**
  83985. * Align the mesh with a normal
  83986. * @param normal defines the normal to use
  83987. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83988. * @returns the current mesh
  83989. */
  83990. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  83991. /** @hidden */
  83992. _checkOcclusionQuery(): boolean;
  83993. }
  83994. }
  83995. declare module BABYLON {
  83996. /**
  83997. * Interface used to define ActionEvent
  83998. */
  83999. export interface IActionEvent {
  84000. /** The mesh or sprite that triggered the action */
  84001. source: any;
  84002. /** The X mouse cursor position at the time of the event */
  84003. pointerX: number;
  84004. /** The Y mouse cursor position at the time of the event */
  84005. pointerY: number;
  84006. /** The mesh that is currently pointed at (can be null) */
  84007. meshUnderPointer: Nullable<AbstractMesh>;
  84008. /** the original (browser) event that triggered the ActionEvent */
  84009. sourceEvent?: any;
  84010. /** additional data for the event */
  84011. additionalData?: any;
  84012. }
  84013. /**
  84014. * ActionEvent is the event being sent when an action is triggered.
  84015. */
  84016. export class ActionEvent implements IActionEvent {
  84017. /** The mesh or sprite that triggered the action */
  84018. source: any;
  84019. /** The X mouse cursor position at the time of the event */
  84020. pointerX: number;
  84021. /** The Y mouse cursor position at the time of the event */
  84022. pointerY: number;
  84023. /** The mesh that is currently pointed at (can be null) */
  84024. meshUnderPointer: Nullable<AbstractMesh>;
  84025. /** the original (browser) event that triggered the ActionEvent */
  84026. sourceEvent?: any;
  84027. /** additional data for the event */
  84028. additionalData?: any;
  84029. /**
  84030. * Creates a new ActionEvent
  84031. * @param source The mesh or sprite that triggered the action
  84032. * @param pointerX The X mouse cursor position at the time of the event
  84033. * @param pointerY The Y mouse cursor position at the time of the event
  84034. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84035. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84036. * @param additionalData additional data for the event
  84037. */
  84038. constructor(
  84039. /** The mesh or sprite that triggered the action */
  84040. source: any,
  84041. /** The X mouse cursor position at the time of the event */
  84042. pointerX: number,
  84043. /** The Y mouse cursor position at the time of the event */
  84044. pointerY: number,
  84045. /** The mesh that is currently pointed at (can be null) */
  84046. meshUnderPointer: Nullable<AbstractMesh>,
  84047. /** the original (browser) event that triggered the ActionEvent */
  84048. sourceEvent?: any,
  84049. /** additional data for the event */
  84050. additionalData?: any);
  84051. /**
  84052. * Helper function to auto-create an ActionEvent from a source mesh.
  84053. * @param source The source mesh that triggered the event
  84054. * @param evt The original (browser) event
  84055. * @param additionalData additional data for the event
  84056. * @returns the new ActionEvent
  84057. */
  84058. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84059. /**
  84060. * Helper function to auto-create an ActionEvent from a source sprite
  84061. * @param source The source sprite that triggered the event
  84062. * @param scene Scene associated with the sprite
  84063. * @param evt The original (browser) event
  84064. * @param additionalData additional data for the event
  84065. * @returns the new ActionEvent
  84066. */
  84067. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84068. /**
  84069. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84070. * @param scene the scene where the event occurred
  84071. * @param evt The original (browser) event
  84072. * @returns the new ActionEvent
  84073. */
  84074. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84075. /**
  84076. * Helper function to auto-create an ActionEvent from a primitive
  84077. * @param prim defines the target primitive
  84078. * @param pointerPos defines the pointer position
  84079. * @param evt The original (browser) event
  84080. * @param additionalData additional data for the event
  84081. * @returns the new ActionEvent
  84082. */
  84083. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  84084. }
  84085. }
  84086. declare module BABYLON {
  84087. /**
  84088. * Abstract class used to decouple action Manager from scene and meshes.
  84089. * Do not instantiate.
  84090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84091. */
  84092. export abstract class AbstractActionManager implements IDisposable {
  84093. /** Gets the list of active triggers */
  84094. static Triggers: {
  84095. [key: string]: number;
  84096. };
  84097. /** Gets the cursor to use when hovering items */
  84098. hoverCursor: string;
  84099. /** Gets the list of actions */
  84100. actions: IAction[];
  84101. /**
  84102. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  84103. */
  84104. isRecursive: boolean;
  84105. /**
  84106. * Releases all associated resources
  84107. */
  84108. abstract dispose(): void;
  84109. /**
  84110. * Does this action manager has pointer triggers
  84111. */
  84112. abstract readonly hasPointerTriggers: boolean;
  84113. /**
  84114. * Does this action manager has pick triggers
  84115. */
  84116. abstract readonly hasPickTriggers: boolean;
  84117. /**
  84118. * Process a specific trigger
  84119. * @param trigger defines the trigger to process
  84120. * @param evt defines the event details to be processed
  84121. */
  84122. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  84123. /**
  84124. * Does this action manager handles actions of any of the given triggers
  84125. * @param triggers defines the triggers to be tested
  84126. * @return a boolean indicating whether one (or more) of the triggers is handled
  84127. */
  84128. abstract hasSpecificTriggers(triggers: number[]): boolean;
  84129. /**
  84130. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  84131. * speed.
  84132. * @param triggerA defines the trigger to be tested
  84133. * @param triggerB defines the trigger to be tested
  84134. * @return a boolean indicating whether one (or more) of the triggers is handled
  84135. */
  84136. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84137. /**
  84138. * Does this action manager handles actions of a given trigger
  84139. * @param trigger defines the trigger to be tested
  84140. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84141. * @return whether the trigger is handled
  84142. */
  84143. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84144. /**
  84145. * Serialize this manager to a JSON object
  84146. * @param name defines the property name to store this manager
  84147. * @returns a JSON representation of this manager
  84148. */
  84149. abstract serialize(name: string): any;
  84150. /**
  84151. * Registers an action to this action manager
  84152. * @param action defines the action to be registered
  84153. * @return the action amended (prepared) after registration
  84154. */
  84155. abstract registerAction(action: IAction): Nullable<IAction>;
  84156. /**
  84157. * Unregisters an action to this action manager
  84158. * @param action defines the action to be unregistered
  84159. * @return a boolean indicating whether the action has been unregistered
  84160. */
  84161. abstract unregisterAction(action: IAction): Boolean;
  84162. /**
  84163. * Does exist one action manager with at least one trigger
  84164. **/
  84165. static readonly HasTriggers: boolean;
  84166. /**
  84167. * Does exist one action manager with at least one pick trigger
  84168. **/
  84169. static readonly HasPickTriggers: boolean;
  84170. /**
  84171. * Does exist one action manager that handles actions of a given trigger
  84172. * @param trigger defines the trigger to be tested
  84173. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  84174. **/
  84175. static HasSpecificTrigger(trigger: number): boolean;
  84176. }
  84177. }
  84178. declare module BABYLON {
  84179. /**
  84180. * Defines how a node can be built from a string name.
  84181. */
  84182. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  84183. /**
  84184. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  84185. */
  84186. export class Node implements IBehaviorAware<Node> {
  84187. /** @hidden */
  84188. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  84189. private static _NodeConstructors;
  84190. /**
  84191. * Add a new node constructor
  84192. * @param type defines the type name of the node to construct
  84193. * @param constructorFunc defines the constructor function
  84194. */
  84195. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  84196. /**
  84197. * Returns a node constructor based on type name
  84198. * @param type defines the type name
  84199. * @param name defines the new node name
  84200. * @param scene defines the hosting scene
  84201. * @param options defines optional options to transmit to constructors
  84202. * @returns the new constructor or null
  84203. */
  84204. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  84205. /**
  84206. * Gets or sets the name of the node
  84207. */
  84208. name: string;
  84209. /**
  84210. * Gets or sets the id of the node
  84211. */
  84212. id: string;
  84213. /**
  84214. * Gets or sets the unique id of the node
  84215. */
  84216. uniqueId: number;
  84217. /**
  84218. * Gets or sets a string used to store user defined state for the node
  84219. */
  84220. state: string;
  84221. /**
  84222. * Gets or sets an object used to store user defined information for the node
  84223. */
  84224. metadata: any;
  84225. /**
  84226. * For internal use only. Please do not use.
  84227. */
  84228. reservedDataStore: any;
  84229. /**
  84230. * List of inspectable custom properties (used by the Inspector)
  84231. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84232. */
  84233. inspectableCustomProperties: IInspectable[];
  84234. /**
  84235. * Gets or sets a boolean used to define if the node must be serialized
  84236. */
  84237. doNotSerialize: boolean;
  84238. /** @hidden */
  84239. _isDisposed: boolean;
  84240. /**
  84241. * Gets a list of Animations associated with the node
  84242. */
  84243. animations: Animation[];
  84244. protected _ranges: {
  84245. [name: string]: Nullable<AnimationRange>;
  84246. };
  84247. /**
  84248. * Callback raised when the node is ready to be used
  84249. */
  84250. onReady: (node: Node) => void;
  84251. private _isEnabled;
  84252. private _isParentEnabled;
  84253. private _isReady;
  84254. /** @hidden */
  84255. _currentRenderId: number;
  84256. private _parentUpdateId;
  84257. /** @hidden */
  84258. _childUpdateId: number;
  84259. /** @hidden */
  84260. _waitingParentId: Nullable<string>;
  84261. /** @hidden */
  84262. _scene: Scene;
  84263. /** @hidden */
  84264. _cache: any;
  84265. private _parentNode;
  84266. private _children;
  84267. /** @hidden */
  84268. _worldMatrix: Matrix;
  84269. /** @hidden */
  84270. _worldMatrixDeterminant: number;
  84271. /** @hidden */
  84272. _worldMatrixDeterminantIsDirty: boolean;
  84273. /** @hidden */
  84274. private _sceneRootNodesIndex;
  84275. /**
  84276. * Gets a boolean indicating if the node has been disposed
  84277. * @returns true if the node was disposed
  84278. */
  84279. isDisposed(): boolean;
  84280. /**
  84281. * Gets or sets the parent of the node (without keeping the current position in the scene)
  84282. * @see https://doc.babylonjs.com/how_to/parenting
  84283. */
  84284. parent: Nullable<Node>;
  84285. private addToSceneRootNodes;
  84286. private removeFromSceneRootNodes;
  84287. private _animationPropertiesOverride;
  84288. /**
  84289. * Gets or sets the animation properties override
  84290. */
  84291. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  84292. /**
  84293. * Gets a string idenfifying the name of the class
  84294. * @returns "Node" string
  84295. */
  84296. getClassName(): string;
  84297. /** @hidden */
  84298. readonly _isNode: boolean;
  84299. /**
  84300. * An event triggered when the mesh is disposed
  84301. */
  84302. onDisposeObservable: Observable<Node>;
  84303. private _onDisposeObserver;
  84304. /**
  84305. * Sets a callback that will be raised when the node will be disposed
  84306. */
  84307. onDispose: () => void;
  84308. /**
  84309. * Creates a new Node
  84310. * @param name the name and id to be given to this node
  84311. * @param scene the scene this node will be added to
  84312. * @param addToRootNodes the node will be added to scene.rootNodes
  84313. */
  84314. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  84315. /**
  84316. * Gets the scene of the node
  84317. * @returns a scene
  84318. */
  84319. getScene(): Scene;
  84320. /**
  84321. * Gets the engine of the node
  84322. * @returns a Engine
  84323. */
  84324. getEngine(): Engine;
  84325. private _behaviors;
  84326. /**
  84327. * Attach a behavior to the node
  84328. * @see http://doc.babylonjs.com/features/behaviour
  84329. * @param behavior defines the behavior to attach
  84330. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  84331. * @returns the current Node
  84332. */
  84333. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  84334. /**
  84335. * Remove an attached behavior
  84336. * @see http://doc.babylonjs.com/features/behaviour
  84337. * @param behavior defines the behavior to attach
  84338. * @returns the current Node
  84339. */
  84340. removeBehavior(behavior: Behavior<Node>): Node;
  84341. /**
  84342. * Gets the list of attached behaviors
  84343. * @see http://doc.babylonjs.com/features/behaviour
  84344. */
  84345. readonly behaviors: Behavior<Node>[];
  84346. /**
  84347. * Gets an attached behavior by name
  84348. * @param name defines the name of the behavior to look for
  84349. * @see http://doc.babylonjs.com/features/behaviour
  84350. * @returns null if behavior was not found else the requested behavior
  84351. */
  84352. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  84353. /**
  84354. * Returns the latest update of the World matrix
  84355. * @returns a Matrix
  84356. */
  84357. getWorldMatrix(): Matrix;
  84358. /** @hidden */
  84359. _getWorldMatrixDeterminant(): number;
  84360. /**
  84361. * Returns directly the latest state of the mesh World matrix.
  84362. * A Matrix is returned.
  84363. */
  84364. readonly worldMatrixFromCache: Matrix;
  84365. /** @hidden */
  84366. _initCache(): void;
  84367. /** @hidden */
  84368. updateCache(force?: boolean): void;
  84369. /** @hidden */
  84370. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84371. /** @hidden */
  84372. _updateCache(ignoreParentClass?: boolean): void;
  84373. /** @hidden */
  84374. _isSynchronized(): boolean;
  84375. /** @hidden */
  84376. _markSyncedWithParent(): void;
  84377. /** @hidden */
  84378. isSynchronizedWithParent(): boolean;
  84379. /** @hidden */
  84380. isSynchronized(): boolean;
  84381. /**
  84382. * Is this node ready to be used/rendered
  84383. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84384. * @return true if the node is ready
  84385. */
  84386. isReady(completeCheck?: boolean): boolean;
  84387. /**
  84388. * Is this node enabled?
  84389. * 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
  84390. * @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
  84391. * @return whether this node (and its parent) is enabled
  84392. */
  84393. isEnabled(checkAncestors?: boolean): boolean;
  84394. /** @hidden */
  84395. protected _syncParentEnabledState(): void;
  84396. /**
  84397. * Set the enabled state of this node
  84398. * @param value defines the new enabled state
  84399. */
  84400. setEnabled(value: boolean): void;
  84401. /**
  84402. * Is this node a descendant of the given node?
  84403. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  84404. * @param ancestor defines the parent node to inspect
  84405. * @returns a boolean indicating if this node is a descendant of the given node
  84406. */
  84407. isDescendantOf(ancestor: Node): boolean;
  84408. /** @hidden */
  84409. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  84410. /**
  84411. * Will return all nodes that have this node as ascendant
  84412. * @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
  84413. * @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
  84414. * @return all children nodes of all types
  84415. */
  84416. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  84417. /**
  84418. * Get all child-meshes of this node
  84419. * @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)
  84420. * @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
  84421. * @returns an array of AbstractMesh
  84422. */
  84423. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  84424. /**
  84425. * Get all direct children of this node
  84426. * @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
  84427. * @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)
  84428. * @returns an array of Node
  84429. */
  84430. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  84431. /** @hidden */
  84432. _setReady(state: boolean): void;
  84433. /**
  84434. * Get an animation by name
  84435. * @param name defines the name of the animation to look for
  84436. * @returns null if not found else the requested animation
  84437. */
  84438. getAnimationByName(name: string): Nullable<Animation>;
  84439. /**
  84440. * Creates an animation range for this node
  84441. * @param name defines the name of the range
  84442. * @param from defines the starting key
  84443. * @param to defines the end key
  84444. */
  84445. createAnimationRange(name: string, from: number, to: number): void;
  84446. /**
  84447. * Delete a specific animation range
  84448. * @param name defines the name of the range to delete
  84449. * @param deleteFrames defines if animation frames from the range must be deleted as well
  84450. */
  84451. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84452. /**
  84453. * Get an animation range by name
  84454. * @param name defines the name of the animation range to look for
  84455. * @returns null if not found else the requested animation range
  84456. */
  84457. getAnimationRange(name: string): Nullable<AnimationRange>;
  84458. /**
  84459. * Gets the list of all animation ranges defined on this node
  84460. * @returns an array
  84461. */
  84462. getAnimationRanges(): Nullable<AnimationRange>[];
  84463. /**
  84464. * Will start the animation sequence
  84465. * @param name defines the range frames for animation sequence
  84466. * @param loop defines if the animation should loop (false by default)
  84467. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  84468. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  84469. * @returns the object created for this animation. If range does not exist, it will return null
  84470. */
  84471. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84472. /**
  84473. * Serialize animation ranges into a JSON compatible object
  84474. * @returns serialization object
  84475. */
  84476. serializeAnimationRanges(): any;
  84477. /**
  84478. * Computes the world matrix of the node
  84479. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84480. * @returns the world matrix
  84481. */
  84482. computeWorldMatrix(force?: boolean): Matrix;
  84483. /**
  84484. * Releases resources associated with this node.
  84485. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84486. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84487. */
  84488. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84489. /**
  84490. * Parse animation range data from a serialization object and store them into a given node
  84491. * @param node defines where to store the animation ranges
  84492. * @param parsedNode defines the serialization object to read data from
  84493. * @param scene defines the hosting scene
  84494. */
  84495. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  84496. }
  84497. }
  84498. declare module BABYLON {
  84499. /**
  84500. * @hidden
  84501. */
  84502. export class _IAnimationState {
  84503. key: number;
  84504. repeatCount: number;
  84505. workValue?: any;
  84506. loopMode?: number;
  84507. offsetValue?: any;
  84508. highLimitValue?: any;
  84509. }
  84510. /**
  84511. * Class used to store any kind of animation
  84512. */
  84513. export class Animation {
  84514. /**Name of the animation */
  84515. name: string;
  84516. /**Property to animate */
  84517. targetProperty: string;
  84518. /**The frames per second of the animation */
  84519. framePerSecond: number;
  84520. /**The data type of the animation */
  84521. dataType: number;
  84522. /**The loop mode of the animation */
  84523. loopMode?: number | undefined;
  84524. /**Specifies if blending should be enabled */
  84525. enableBlending?: boolean | undefined;
  84526. /**
  84527. * Use matrix interpolation instead of using direct key value when animating matrices
  84528. */
  84529. static AllowMatricesInterpolation: boolean;
  84530. /**
  84531. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  84532. */
  84533. static AllowMatrixDecomposeForInterpolation: boolean;
  84534. /**
  84535. * Stores the key frames of the animation
  84536. */
  84537. private _keys;
  84538. /**
  84539. * Stores the easing function of the animation
  84540. */
  84541. private _easingFunction;
  84542. /**
  84543. * @hidden Internal use only
  84544. */
  84545. _runtimeAnimations: RuntimeAnimation[];
  84546. /**
  84547. * The set of event that will be linked to this animation
  84548. */
  84549. private _events;
  84550. /**
  84551. * Stores an array of target property paths
  84552. */
  84553. targetPropertyPath: string[];
  84554. /**
  84555. * Stores the blending speed of the animation
  84556. */
  84557. blendingSpeed: number;
  84558. /**
  84559. * Stores the animation ranges for the animation
  84560. */
  84561. private _ranges;
  84562. /**
  84563. * @hidden Internal use
  84564. */
  84565. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  84566. /**
  84567. * Sets up an animation
  84568. * @param property The property to animate
  84569. * @param animationType The animation type to apply
  84570. * @param framePerSecond The frames per second of the animation
  84571. * @param easingFunction The easing function used in the animation
  84572. * @returns The created animation
  84573. */
  84574. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  84575. /**
  84576. * Create and start an animation on a node
  84577. * @param name defines the name of the global animation that will be run on all nodes
  84578. * @param node defines the root node where the animation will take place
  84579. * @param targetProperty defines property to animate
  84580. * @param framePerSecond defines the number of frame per second yo use
  84581. * @param totalFrame defines the number of frames in total
  84582. * @param from defines the initial value
  84583. * @param to defines the final value
  84584. * @param loopMode defines which loop mode you want to use (off by default)
  84585. * @param easingFunction defines the easing function to use (linear by default)
  84586. * @param onAnimationEnd defines the callback to call when animation end
  84587. * @returns the animatable created for this animation
  84588. */
  84589. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84590. /**
  84591. * Create and start an animation on a node and its descendants
  84592. * @param name defines the name of the global animation that will be run on all nodes
  84593. * @param node defines the root node where the animation will take place
  84594. * @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
  84595. * @param targetProperty defines property to animate
  84596. * @param framePerSecond defines the number of frame per second to use
  84597. * @param totalFrame defines the number of frames in total
  84598. * @param from defines the initial value
  84599. * @param to defines the final value
  84600. * @param loopMode defines which loop mode you want to use (off by default)
  84601. * @param easingFunction defines the easing function to use (linear by default)
  84602. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84603. * @returns the list of animatables created for all nodes
  84604. * @example https://www.babylonjs-playground.com/#MH0VLI
  84605. */
  84606. 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[]>;
  84607. /**
  84608. * Creates a new animation, merges it with the existing animations and starts it
  84609. * @param name Name of the animation
  84610. * @param node Node which contains the scene that begins the animations
  84611. * @param targetProperty Specifies which property to animate
  84612. * @param framePerSecond The frames per second of the animation
  84613. * @param totalFrame The total number of frames
  84614. * @param from The frame at the beginning of the animation
  84615. * @param to The frame at the end of the animation
  84616. * @param loopMode Specifies the loop mode of the animation
  84617. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  84618. * @param onAnimationEnd Callback to run once the animation is complete
  84619. * @returns Nullable animation
  84620. */
  84621. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84622. /**
  84623. * Transition property of an host to the target Value
  84624. * @param property The property to transition
  84625. * @param targetValue The target Value of the property
  84626. * @param host The object where the property to animate belongs
  84627. * @param scene Scene used to run the animation
  84628. * @param frameRate Framerate (in frame/s) to use
  84629. * @param transition The transition type we want to use
  84630. * @param duration The duration of the animation, in milliseconds
  84631. * @param onAnimationEnd Callback trigger at the end of the animation
  84632. * @returns Nullable animation
  84633. */
  84634. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  84635. /**
  84636. * Return the array of runtime animations currently using this animation
  84637. */
  84638. readonly runtimeAnimations: RuntimeAnimation[];
  84639. /**
  84640. * Specifies if any of the runtime animations are currently running
  84641. */
  84642. readonly hasRunningRuntimeAnimations: boolean;
  84643. /**
  84644. * Initializes the animation
  84645. * @param name Name of the animation
  84646. * @param targetProperty Property to animate
  84647. * @param framePerSecond The frames per second of the animation
  84648. * @param dataType The data type of the animation
  84649. * @param loopMode The loop mode of the animation
  84650. * @param enableBlending Specifies if blending should be enabled
  84651. */
  84652. constructor(
  84653. /**Name of the animation */
  84654. name: string,
  84655. /**Property to animate */
  84656. targetProperty: string,
  84657. /**The frames per second of the animation */
  84658. framePerSecond: number,
  84659. /**The data type of the animation */
  84660. dataType: number,
  84661. /**The loop mode of the animation */
  84662. loopMode?: number | undefined,
  84663. /**Specifies if blending should be enabled */
  84664. enableBlending?: boolean | undefined);
  84665. /**
  84666. * Converts the animation to a string
  84667. * @param fullDetails support for multiple levels of logging within scene loading
  84668. * @returns String form of the animation
  84669. */
  84670. toString(fullDetails?: boolean): string;
  84671. /**
  84672. * Add an event to this animation
  84673. * @param event Event to add
  84674. */
  84675. addEvent(event: AnimationEvent): void;
  84676. /**
  84677. * Remove all events found at the given frame
  84678. * @param frame The frame to remove events from
  84679. */
  84680. removeEvents(frame: number): void;
  84681. /**
  84682. * Retrieves all the events from the animation
  84683. * @returns Events from the animation
  84684. */
  84685. getEvents(): AnimationEvent[];
  84686. /**
  84687. * Creates an animation range
  84688. * @param name Name of the animation range
  84689. * @param from Starting frame of the animation range
  84690. * @param to Ending frame of the animation
  84691. */
  84692. createRange(name: string, from: number, to: number): void;
  84693. /**
  84694. * Deletes an animation range by name
  84695. * @param name Name of the animation range to delete
  84696. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  84697. */
  84698. deleteRange(name: string, deleteFrames?: boolean): void;
  84699. /**
  84700. * Gets the animation range by name, or null if not defined
  84701. * @param name Name of the animation range
  84702. * @returns Nullable animation range
  84703. */
  84704. getRange(name: string): Nullable<AnimationRange>;
  84705. /**
  84706. * Gets the key frames from the animation
  84707. * @returns The key frames of the animation
  84708. */
  84709. getKeys(): Array<IAnimationKey>;
  84710. /**
  84711. * Gets the highest frame rate of the animation
  84712. * @returns Highest frame rate of the animation
  84713. */
  84714. getHighestFrame(): number;
  84715. /**
  84716. * Gets the easing function of the animation
  84717. * @returns Easing function of the animation
  84718. */
  84719. getEasingFunction(): IEasingFunction;
  84720. /**
  84721. * Sets the easing function of the animation
  84722. * @param easingFunction A custom mathematical formula for animation
  84723. */
  84724. setEasingFunction(easingFunction: EasingFunction): void;
  84725. /**
  84726. * Interpolates a scalar linearly
  84727. * @param startValue Start value of the animation curve
  84728. * @param endValue End value of the animation curve
  84729. * @param gradient Scalar amount to interpolate
  84730. * @returns Interpolated scalar value
  84731. */
  84732. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  84733. /**
  84734. * Interpolates a scalar cubically
  84735. * @param startValue Start value of the animation curve
  84736. * @param outTangent End tangent of the animation
  84737. * @param endValue End value of the animation curve
  84738. * @param inTangent Start tangent of the animation curve
  84739. * @param gradient Scalar amount to interpolate
  84740. * @returns Interpolated scalar value
  84741. */
  84742. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  84743. /**
  84744. * Interpolates a quaternion using a spherical linear interpolation
  84745. * @param startValue Start value of the animation curve
  84746. * @param endValue End value of the animation curve
  84747. * @param gradient Scalar amount to interpolate
  84748. * @returns Interpolated quaternion value
  84749. */
  84750. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  84751. /**
  84752. * Interpolates a quaternion cubically
  84753. * @param startValue Start value of the animation curve
  84754. * @param outTangent End tangent of the animation curve
  84755. * @param endValue End value of the animation curve
  84756. * @param inTangent Start tangent of the animation curve
  84757. * @param gradient Scalar amount to interpolate
  84758. * @returns Interpolated quaternion value
  84759. */
  84760. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  84761. /**
  84762. * Interpolates a Vector3 linearl
  84763. * @param startValue Start value of the animation curve
  84764. * @param endValue End value of the animation curve
  84765. * @param gradient Scalar amount to interpolate
  84766. * @returns Interpolated scalar value
  84767. */
  84768. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  84769. /**
  84770. * Interpolates a Vector3 cubically
  84771. * @param startValue Start value of the animation curve
  84772. * @param outTangent End tangent of the animation
  84773. * @param endValue End value of the animation curve
  84774. * @param inTangent Start tangent of the animation curve
  84775. * @param gradient Scalar amount to interpolate
  84776. * @returns InterpolatedVector3 value
  84777. */
  84778. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  84779. /**
  84780. * Interpolates a Vector2 linearly
  84781. * @param startValue Start value of the animation curve
  84782. * @param endValue End value of the animation curve
  84783. * @param gradient Scalar amount to interpolate
  84784. * @returns Interpolated Vector2 value
  84785. */
  84786. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  84787. /**
  84788. * Interpolates a Vector2 cubically
  84789. * @param startValue Start value of the animation curve
  84790. * @param outTangent End tangent of the animation
  84791. * @param endValue End value of the animation curve
  84792. * @param inTangent Start tangent of the animation curve
  84793. * @param gradient Scalar amount to interpolate
  84794. * @returns Interpolated Vector2 value
  84795. */
  84796. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  84797. /**
  84798. * Interpolates a size linearly
  84799. * @param startValue Start value of the animation curve
  84800. * @param endValue End value of the animation curve
  84801. * @param gradient Scalar amount to interpolate
  84802. * @returns Interpolated Size value
  84803. */
  84804. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  84805. /**
  84806. * Interpolates a Color3 linearly
  84807. * @param startValue Start value of the animation curve
  84808. * @param endValue End value of the animation curve
  84809. * @param gradient Scalar amount to interpolate
  84810. * @returns Interpolated Color3 value
  84811. */
  84812. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  84813. /**
  84814. * @hidden Internal use only
  84815. */
  84816. _getKeyValue(value: any): any;
  84817. /**
  84818. * @hidden Internal use only
  84819. */
  84820. _interpolate(currentFrame: number, state: _IAnimationState): any;
  84821. /**
  84822. * Defines the function to use to interpolate matrices
  84823. * @param startValue defines the start matrix
  84824. * @param endValue defines the end matrix
  84825. * @param gradient defines the gradient between both matrices
  84826. * @param result defines an optional target matrix where to store the interpolation
  84827. * @returns the interpolated matrix
  84828. */
  84829. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  84830. /**
  84831. * Makes a copy of the animation
  84832. * @returns Cloned animation
  84833. */
  84834. clone(): Animation;
  84835. /**
  84836. * Sets the key frames of the animation
  84837. * @param values The animation key frames to set
  84838. */
  84839. setKeys(values: Array<IAnimationKey>): void;
  84840. /**
  84841. * Serializes the animation to an object
  84842. * @returns Serialized object
  84843. */
  84844. serialize(): any;
  84845. /**
  84846. * Float animation type
  84847. */
  84848. private static _ANIMATIONTYPE_FLOAT;
  84849. /**
  84850. * Vector3 animation type
  84851. */
  84852. private static _ANIMATIONTYPE_VECTOR3;
  84853. /**
  84854. * Quaternion animation type
  84855. */
  84856. private static _ANIMATIONTYPE_QUATERNION;
  84857. /**
  84858. * Matrix animation type
  84859. */
  84860. private static _ANIMATIONTYPE_MATRIX;
  84861. /**
  84862. * Color3 animation type
  84863. */
  84864. private static _ANIMATIONTYPE_COLOR3;
  84865. /**
  84866. * Vector2 animation type
  84867. */
  84868. private static _ANIMATIONTYPE_VECTOR2;
  84869. /**
  84870. * Size animation type
  84871. */
  84872. private static _ANIMATIONTYPE_SIZE;
  84873. /**
  84874. * Relative Loop Mode
  84875. */
  84876. private static _ANIMATIONLOOPMODE_RELATIVE;
  84877. /**
  84878. * Cycle Loop Mode
  84879. */
  84880. private static _ANIMATIONLOOPMODE_CYCLE;
  84881. /**
  84882. * Constant Loop Mode
  84883. */
  84884. private static _ANIMATIONLOOPMODE_CONSTANT;
  84885. /**
  84886. * Get the float animation type
  84887. */
  84888. static readonly ANIMATIONTYPE_FLOAT: number;
  84889. /**
  84890. * Get the Vector3 animation type
  84891. */
  84892. static readonly ANIMATIONTYPE_VECTOR3: number;
  84893. /**
  84894. * Get the Vector2 animation type
  84895. */
  84896. static readonly ANIMATIONTYPE_VECTOR2: number;
  84897. /**
  84898. * Get the Size animation type
  84899. */
  84900. static readonly ANIMATIONTYPE_SIZE: number;
  84901. /**
  84902. * Get the Quaternion animation type
  84903. */
  84904. static readonly ANIMATIONTYPE_QUATERNION: number;
  84905. /**
  84906. * Get the Matrix animation type
  84907. */
  84908. static readonly ANIMATIONTYPE_MATRIX: number;
  84909. /**
  84910. * Get the Color3 animation type
  84911. */
  84912. static readonly ANIMATIONTYPE_COLOR3: number;
  84913. /**
  84914. * Get the Relative Loop Mode
  84915. */
  84916. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  84917. /**
  84918. * Get the Cycle Loop Mode
  84919. */
  84920. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  84921. /**
  84922. * Get the Constant Loop Mode
  84923. */
  84924. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  84925. /** @hidden */
  84926. static _UniversalLerp(left: any, right: any, amount: number): any;
  84927. /**
  84928. * Parses an animation object and creates an animation
  84929. * @param parsedAnimation Parsed animation object
  84930. * @returns Animation object
  84931. */
  84932. static Parse(parsedAnimation: any): Animation;
  84933. /**
  84934. * Appends the serialized animations from the source animations
  84935. * @param source Source containing the animations
  84936. * @param destination Target to store the animations
  84937. */
  84938. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  84939. }
  84940. }
  84941. declare module BABYLON {
  84942. /**
  84943. * Base class of all the textures in babylon.
  84944. * It groups all the common properties the materials, post process, lights... might need
  84945. * in order to make a correct use of the texture.
  84946. */
  84947. export class BaseTexture implements IAnimatable {
  84948. /**
  84949. * Default anisotropic filtering level for the application.
  84950. * It is set to 4 as a good tradeoff between perf and quality.
  84951. */
  84952. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  84953. /**
  84954. * Gets or sets the unique id of the texture
  84955. */
  84956. uniqueId: number;
  84957. /**
  84958. * Define the name of the texture.
  84959. */
  84960. name: string;
  84961. /**
  84962. * Gets or sets an object used to store user defined information.
  84963. */
  84964. metadata: any;
  84965. /**
  84966. * For internal use only. Please do not use.
  84967. */
  84968. reservedDataStore: any;
  84969. private _hasAlpha;
  84970. /**
  84971. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  84972. */
  84973. hasAlpha: boolean;
  84974. /**
  84975. * Defines if the alpha value should be determined via the rgb values.
  84976. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  84977. */
  84978. getAlphaFromRGB: boolean;
  84979. /**
  84980. * Intensity or strength of the texture.
  84981. * It is commonly used by materials to fine tune the intensity of the texture
  84982. */
  84983. level: number;
  84984. /**
  84985. * Define the UV chanel to use starting from 0 and defaulting to 0.
  84986. * This is part of the texture as textures usually maps to one uv set.
  84987. */
  84988. coordinatesIndex: number;
  84989. private _coordinatesMode;
  84990. /**
  84991. * How a texture is mapped.
  84992. *
  84993. * | Value | Type | Description |
  84994. * | ----- | ----------------------------------- | ----------- |
  84995. * | 0 | EXPLICIT_MODE | |
  84996. * | 1 | SPHERICAL_MODE | |
  84997. * | 2 | PLANAR_MODE | |
  84998. * | 3 | CUBIC_MODE | |
  84999. * | 4 | PROJECTION_MODE | |
  85000. * | 5 | SKYBOX_MODE | |
  85001. * | 6 | INVCUBIC_MODE | |
  85002. * | 7 | EQUIRECTANGULAR_MODE | |
  85003. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85004. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85005. */
  85006. coordinatesMode: number;
  85007. /**
  85008. * | Value | Type | Description |
  85009. * | ----- | ------------------ | ----------- |
  85010. * | 0 | CLAMP_ADDRESSMODE | |
  85011. * | 1 | WRAP_ADDRESSMODE | |
  85012. * | 2 | MIRROR_ADDRESSMODE | |
  85013. */
  85014. wrapU: number;
  85015. /**
  85016. * | Value | Type | Description |
  85017. * | ----- | ------------------ | ----------- |
  85018. * | 0 | CLAMP_ADDRESSMODE | |
  85019. * | 1 | WRAP_ADDRESSMODE | |
  85020. * | 2 | MIRROR_ADDRESSMODE | |
  85021. */
  85022. wrapV: number;
  85023. /**
  85024. * | Value | Type | Description |
  85025. * | ----- | ------------------ | ----------- |
  85026. * | 0 | CLAMP_ADDRESSMODE | |
  85027. * | 1 | WRAP_ADDRESSMODE | |
  85028. * | 2 | MIRROR_ADDRESSMODE | |
  85029. */
  85030. wrapR: number;
  85031. /**
  85032. * With compliant hardware and browser (supporting anisotropic filtering)
  85033. * this defines the level of anisotropic filtering in the texture.
  85034. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85035. */
  85036. anisotropicFilteringLevel: number;
  85037. /**
  85038. * Define if the texture is a cube texture or if false a 2d texture.
  85039. */
  85040. isCube: boolean;
  85041. /**
  85042. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85043. */
  85044. is3D: boolean;
  85045. /**
  85046. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85047. * HDR texture are usually stored in linear space.
  85048. * This only impacts the PBR and Background materials
  85049. */
  85050. gammaSpace: boolean;
  85051. /**
  85052. * Gets whether or not the texture contains RGBD data.
  85053. */
  85054. readonly isRGBD: boolean;
  85055. /**
  85056. * Is Z inverted in the texture (useful in a cube texture).
  85057. */
  85058. invertZ: boolean;
  85059. /**
  85060. * Are mip maps generated for this texture or not.
  85061. */
  85062. readonly noMipmap: boolean;
  85063. /**
  85064. * @hidden
  85065. */
  85066. lodLevelInAlpha: boolean;
  85067. /**
  85068. * With prefiltered texture, defined the offset used during the prefiltering steps.
  85069. */
  85070. lodGenerationOffset: number;
  85071. /**
  85072. * With prefiltered texture, defined the scale used during the prefiltering steps.
  85073. */
  85074. lodGenerationScale: number;
  85075. /**
  85076. * Define if the texture is a render target.
  85077. */
  85078. isRenderTarget: boolean;
  85079. /**
  85080. * Define the unique id of the texture in the scene.
  85081. */
  85082. readonly uid: string;
  85083. /**
  85084. * Return a string representation of the texture.
  85085. * @returns the texture as a string
  85086. */
  85087. toString(): string;
  85088. /**
  85089. * Get the class name of the texture.
  85090. * @returns "BaseTexture"
  85091. */
  85092. getClassName(): string;
  85093. /**
  85094. * Define the list of animation attached to the texture.
  85095. */
  85096. animations: Animation[];
  85097. /**
  85098. * An event triggered when the texture is disposed.
  85099. */
  85100. onDisposeObservable: Observable<BaseTexture>;
  85101. private _onDisposeObserver;
  85102. /**
  85103. * Callback triggered when the texture has been disposed.
  85104. * Kept for back compatibility, you can use the onDisposeObservable instead.
  85105. */
  85106. onDispose: () => void;
  85107. /**
  85108. * Define the current state of the loading sequence when in delayed load mode.
  85109. */
  85110. delayLoadState: number;
  85111. private _scene;
  85112. /** @hidden */
  85113. _texture: Nullable<InternalTexture>;
  85114. private _uid;
  85115. /**
  85116. * Define if the texture is preventinga material to render or not.
  85117. * If not and the texture is not ready, the engine will use a default black texture instead.
  85118. */
  85119. readonly isBlocking: boolean;
  85120. /**
  85121. * Instantiates a new BaseTexture.
  85122. * Base class of all the textures in babylon.
  85123. * It groups all the common properties the materials, post process, lights... might need
  85124. * in order to make a correct use of the texture.
  85125. * @param scene Define the scene the texture blongs to
  85126. */
  85127. constructor(scene: Nullable<Scene>);
  85128. /**
  85129. * Get the scene the texture belongs to.
  85130. * @returns the scene or null if undefined
  85131. */
  85132. getScene(): Nullable<Scene>;
  85133. /**
  85134. * Get the texture transform matrix used to offset tile the texture for istance.
  85135. * @returns the transformation matrix
  85136. */
  85137. getTextureMatrix(): Matrix;
  85138. /**
  85139. * Get the texture reflection matrix used to rotate/transform the reflection.
  85140. * @returns the reflection matrix
  85141. */
  85142. getReflectionTextureMatrix(): Matrix;
  85143. /**
  85144. * Get the underlying lower level texture from Babylon.
  85145. * @returns the insternal texture
  85146. */
  85147. getInternalTexture(): Nullable<InternalTexture>;
  85148. /**
  85149. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  85150. * @returns true if ready or not blocking
  85151. */
  85152. isReadyOrNotBlocking(): boolean;
  85153. /**
  85154. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  85155. * @returns true if fully ready
  85156. */
  85157. isReady(): boolean;
  85158. private _cachedSize;
  85159. /**
  85160. * Get the size of the texture.
  85161. * @returns the texture size.
  85162. */
  85163. getSize(): ISize;
  85164. /**
  85165. * Get the base size of the texture.
  85166. * It can be different from the size if the texture has been resized for POT for instance
  85167. * @returns the base size
  85168. */
  85169. getBaseSize(): ISize;
  85170. /**
  85171. * Update the sampling mode of the texture.
  85172. * Default is Trilinear mode.
  85173. *
  85174. * | Value | Type | Description |
  85175. * | ----- | ------------------ | ----------- |
  85176. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  85177. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  85178. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  85179. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  85180. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  85181. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  85182. * | 7 | NEAREST_LINEAR | |
  85183. * | 8 | NEAREST_NEAREST | |
  85184. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  85185. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  85186. * | 11 | LINEAR_LINEAR | |
  85187. * | 12 | LINEAR_NEAREST | |
  85188. *
  85189. * > _mag_: magnification filter (close to the viewer)
  85190. * > _min_: minification filter (far from the viewer)
  85191. * > _mip_: filter used between mip map levels
  85192. *@param samplingMode Define the new sampling mode of the texture
  85193. */
  85194. updateSamplingMode(samplingMode: number): void;
  85195. /**
  85196. * Scales the texture if is `canRescale()`
  85197. * @param ratio the resize factor we want to use to rescale
  85198. */
  85199. scale(ratio: number): void;
  85200. /**
  85201. * Get if the texture can rescale.
  85202. */
  85203. readonly canRescale: boolean;
  85204. /** @hidden */
  85205. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  85206. /** @hidden */
  85207. _rebuild(): void;
  85208. /**
  85209. * Triggers the load sequence in delayed load mode.
  85210. */
  85211. delayLoad(): void;
  85212. /**
  85213. * Clones the texture.
  85214. * @returns the cloned texture
  85215. */
  85216. clone(): Nullable<BaseTexture>;
  85217. /**
  85218. * Get the texture underlying type (INT, FLOAT...)
  85219. */
  85220. readonly textureType: number;
  85221. /**
  85222. * Get the texture underlying format (RGB, RGBA...)
  85223. */
  85224. readonly textureFormat: number;
  85225. /**
  85226. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  85227. * This will returns an RGBA array buffer containing either in values (0-255) or
  85228. * float values (0-1) depending of the underlying buffer type.
  85229. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  85230. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  85231. * @param buffer defines a user defined buffer to fill with data (can be null)
  85232. * @returns The Array buffer containing the pixels data.
  85233. */
  85234. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  85235. /**
  85236. * Release and destroy the underlying lower level texture aka internalTexture.
  85237. */
  85238. releaseInternalTexture(): void;
  85239. /**
  85240. * Get the polynomial representation of the texture data.
  85241. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  85242. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  85243. */
  85244. sphericalPolynomial: Nullable<SphericalPolynomial>;
  85245. /** @hidden */
  85246. readonly _lodTextureHigh: Nullable<BaseTexture>;
  85247. /** @hidden */
  85248. readonly _lodTextureMid: Nullable<BaseTexture>;
  85249. /** @hidden */
  85250. readonly _lodTextureLow: Nullable<BaseTexture>;
  85251. /**
  85252. * Dispose the texture and release its associated resources.
  85253. */
  85254. dispose(): void;
  85255. /**
  85256. * Serialize the texture into a JSON representation that can be parsed later on.
  85257. * @returns the JSON representation of the texture
  85258. */
  85259. serialize(): any;
  85260. /**
  85261. * Helper function to be called back once a list of texture contains only ready textures.
  85262. * @param textures Define the list of textures to wait for
  85263. * @param callback Define the callback triggered once the entire list will be ready
  85264. */
  85265. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  85266. }
  85267. }
  85268. declare module BABYLON {
  85269. /**
  85270. * Uniform buffer objects.
  85271. *
  85272. * Handles blocks of uniform on the GPU.
  85273. *
  85274. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85275. *
  85276. * For more information, please refer to :
  85277. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85278. */
  85279. export class UniformBuffer {
  85280. private _engine;
  85281. private _buffer;
  85282. private _data;
  85283. private _bufferData;
  85284. private _dynamic?;
  85285. private _uniformLocations;
  85286. private _uniformSizes;
  85287. private _uniformLocationPointer;
  85288. private _needSync;
  85289. private _noUBO;
  85290. private _currentEffect;
  85291. private static _MAX_UNIFORM_SIZE;
  85292. private static _tempBuffer;
  85293. /**
  85294. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85295. * This is dynamic to allow compat with webgl 1 and 2.
  85296. * You will need to pass the name of the uniform as well as the value.
  85297. */
  85298. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85299. /**
  85300. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85301. * This is dynamic to allow compat with webgl 1 and 2.
  85302. * You will need to pass the name of the uniform as well as the value.
  85303. */
  85304. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85305. /**
  85306. * Lambda to Update a single float in a uniform buffer.
  85307. * This is dynamic to allow compat with webgl 1 and 2.
  85308. * You will need to pass the name of the uniform as well as the value.
  85309. */
  85310. updateFloat: (name: string, x: number) => void;
  85311. /**
  85312. * Lambda to Update a vec2 of float in a uniform buffer.
  85313. * This is dynamic to allow compat with webgl 1 and 2.
  85314. * You will need to pass the name of the uniform as well as the value.
  85315. */
  85316. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85317. /**
  85318. * Lambda to Update a vec3 of float in a uniform buffer.
  85319. * This is dynamic to allow compat with webgl 1 and 2.
  85320. * You will need to pass the name of the uniform as well as the value.
  85321. */
  85322. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85323. /**
  85324. * Lambda to Update a vec4 of float in a uniform buffer.
  85325. * This is dynamic to allow compat with webgl 1 and 2.
  85326. * You will need to pass the name of the uniform as well as the value.
  85327. */
  85328. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85329. /**
  85330. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85331. * This is dynamic to allow compat with webgl 1 and 2.
  85332. * You will need to pass the name of the uniform as well as the value.
  85333. */
  85334. updateMatrix: (name: string, mat: Matrix) => void;
  85335. /**
  85336. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85337. * This is dynamic to allow compat with webgl 1 and 2.
  85338. * You will need to pass the name of the uniform as well as the value.
  85339. */
  85340. updateVector3: (name: string, vector: Vector3) => void;
  85341. /**
  85342. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85343. * This is dynamic to allow compat with webgl 1 and 2.
  85344. * You will need to pass the name of the uniform as well as the value.
  85345. */
  85346. updateVector4: (name: string, vector: Vector4) => void;
  85347. /**
  85348. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85349. * This is dynamic to allow compat with webgl 1 and 2.
  85350. * You will need to pass the name of the uniform as well as the value.
  85351. */
  85352. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85353. /**
  85354. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85355. * This is dynamic to allow compat with webgl 1 and 2.
  85356. * You will need to pass the name of the uniform as well as the value.
  85357. */
  85358. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85359. /**
  85360. * Instantiates a new Uniform buffer objects.
  85361. *
  85362. * Handles blocks of uniform on the GPU.
  85363. *
  85364. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85365. *
  85366. * For more information, please refer to :
  85367. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85368. * @param engine Define the engine the buffer is associated with
  85369. * @param data Define the data contained in the buffer
  85370. * @param dynamic Define if the buffer is updatable
  85371. */
  85372. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85373. /**
  85374. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85375. * or just falling back on setUniformXXX calls.
  85376. */
  85377. readonly useUbo: boolean;
  85378. /**
  85379. * Indicates if the WebGL underlying uniform buffer is in sync
  85380. * with the javascript cache data.
  85381. */
  85382. readonly isSync: boolean;
  85383. /**
  85384. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85385. * Also, a dynamic UniformBuffer will disable cache verification and always
  85386. * update the underlying WebGL uniform buffer to the GPU.
  85387. * @returns if Dynamic, otherwise false
  85388. */
  85389. isDynamic(): boolean;
  85390. /**
  85391. * The data cache on JS side.
  85392. * @returns the underlying data as a float array
  85393. */
  85394. getData(): Float32Array;
  85395. /**
  85396. * The underlying WebGL Uniform buffer.
  85397. * @returns the webgl buffer
  85398. */
  85399. getBuffer(): Nullable<WebGLBuffer>;
  85400. /**
  85401. * std140 layout specifies how to align data within an UBO structure.
  85402. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85403. * for specs.
  85404. */
  85405. private _fillAlignment;
  85406. /**
  85407. * Adds an uniform in the buffer.
  85408. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85409. * for the layout to be correct !
  85410. * @param name Name of the uniform, as used in the uniform block in the shader.
  85411. * @param size Data size, or data directly.
  85412. */
  85413. addUniform(name: string, size: number | number[]): void;
  85414. /**
  85415. * Adds a Matrix 4x4 to the uniform buffer.
  85416. * @param name Name of the uniform, as used in the uniform block in the shader.
  85417. * @param mat A 4x4 matrix.
  85418. */
  85419. addMatrix(name: string, mat: Matrix): void;
  85420. /**
  85421. * Adds a vec2 to the uniform buffer.
  85422. * @param name Name of the uniform, as used in the uniform block in the shader.
  85423. * @param x Define the x component value of the vec2
  85424. * @param y Define the y component value of the vec2
  85425. */
  85426. addFloat2(name: string, x: number, y: number): void;
  85427. /**
  85428. * Adds a vec3 to the uniform buffer.
  85429. * @param name Name of the uniform, as used in the uniform block in the shader.
  85430. * @param x Define the x component value of the vec3
  85431. * @param y Define the y component value of the vec3
  85432. * @param z Define the z component value of the vec3
  85433. */
  85434. addFloat3(name: string, x: number, y: number, z: number): void;
  85435. /**
  85436. * Adds a vec3 to the uniform buffer.
  85437. * @param name Name of the uniform, as used in the uniform block in the shader.
  85438. * @param color Define the vec3 from a Color
  85439. */
  85440. addColor3(name: string, color: Color3): void;
  85441. /**
  85442. * Adds a vec4 to the uniform buffer.
  85443. * @param name Name of the uniform, as used in the uniform block in the shader.
  85444. * @param color Define the rgb components from a Color
  85445. * @param alpha Define the a component of the vec4
  85446. */
  85447. addColor4(name: string, color: Color3, alpha: number): void;
  85448. /**
  85449. * Adds a vec3 to the uniform buffer.
  85450. * @param name Name of the uniform, as used in the uniform block in the shader.
  85451. * @param vector Define the vec3 components from a Vector
  85452. */
  85453. addVector3(name: string, vector: Vector3): void;
  85454. /**
  85455. * Adds a Matrix 3x3 to the uniform buffer.
  85456. * @param name Name of the uniform, as used in the uniform block in the shader.
  85457. */
  85458. addMatrix3x3(name: string): void;
  85459. /**
  85460. * Adds a Matrix 2x2 to the uniform buffer.
  85461. * @param name Name of the uniform, as used in the uniform block in the shader.
  85462. */
  85463. addMatrix2x2(name: string): void;
  85464. /**
  85465. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85466. */
  85467. create(): void;
  85468. /** @hidden */
  85469. _rebuild(): void;
  85470. /**
  85471. * Updates the WebGL Uniform Buffer on the GPU.
  85472. * If the `dynamic` flag is set to true, no cache comparison is done.
  85473. * Otherwise, the buffer will be updated only if the cache differs.
  85474. */
  85475. update(): void;
  85476. /**
  85477. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85478. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85479. * @param data Define the flattened data
  85480. * @param size Define the size of the data.
  85481. */
  85482. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85483. private _updateMatrix3x3ForUniform;
  85484. private _updateMatrix3x3ForEffect;
  85485. private _updateMatrix2x2ForEffect;
  85486. private _updateMatrix2x2ForUniform;
  85487. private _updateFloatForEffect;
  85488. private _updateFloatForUniform;
  85489. private _updateFloat2ForEffect;
  85490. private _updateFloat2ForUniform;
  85491. private _updateFloat3ForEffect;
  85492. private _updateFloat3ForUniform;
  85493. private _updateFloat4ForEffect;
  85494. private _updateFloat4ForUniform;
  85495. private _updateMatrixForEffect;
  85496. private _updateMatrixForUniform;
  85497. private _updateVector3ForEffect;
  85498. private _updateVector3ForUniform;
  85499. private _updateVector4ForEffect;
  85500. private _updateVector4ForUniform;
  85501. private _updateColor3ForEffect;
  85502. private _updateColor3ForUniform;
  85503. private _updateColor4ForEffect;
  85504. private _updateColor4ForUniform;
  85505. /**
  85506. * Sets a sampler uniform on the effect.
  85507. * @param name Define the name of the sampler.
  85508. * @param texture Define the texture to set in the sampler
  85509. */
  85510. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85511. /**
  85512. * Directly updates the value of the uniform in the cache AND on the GPU.
  85513. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85514. * @param data Define the flattened data
  85515. */
  85516. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85517. /**
  85518. * Binds this uniform buffer to an effect.
  85519. * @param effect Define the effect to bind the buffer to
  85520. * @param name Name of the uniform block in the shader.
  85521. */
  85522. bindToEffect(effect: Effect, name: string): void;
  85523. /**
  85524. * Disposes the uniform buffer.
  85525. */
  85526. dispose(): void;
  85527. }
  85528. }
  85529. declare module BABYLON {
  85530. /**
  85531. * This represents the required contract to create a new type of texture loader.
  85532. */
  85533. export interface IInternalTextureLoader {
  85534. /**
  85535. * Defines wether the loader supports cascade loading the different faces.
  85536. */
  85537. supportCascades: boolean;
  85538. /**
  85539. * This returns if the loader support the current file information.
  85540. * @param extension defines the file extension of the file being loaded
  85541. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85542. * @param fallback defines the fallback internal texture if any
  85543. * @param isBase64 defines whether the texture is encoded as a base64
  85544. * @param isBuffer defines whether the texture data are stored as a buffer
  85545. * @returns true if the loader can load the specified file
  85546. */
  85547. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  85548. /**
  85549. * Transform the url before loading if required.
  85550. * @param rootUrl the url of the texture
  85551. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85552. * @returns the transformed texture
  85553. */
  85554. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  85555. /**
  85556. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  85557. * @param rootUrl the url of the texture
  85558. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85559. * @returns the fallback texture
  85560. */
  85561. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  85562. /**
  85563. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  85564. * @param data contains the texture data
  85565. * @param texture defines the BabylonJS internal texture
  85566. * @param createPolynomials will be true if polynomials have been requested
  85567. * @param onLoad defines the callback to trigger once the texture is ready
  85568. * @param onError defines the callback to trigger in case of error
  85569. */
  85570. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  85571. /**
  85572. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  85573. * @param data contains the texture data
  85574. * @param texture defines the BabylonJS internal texture
  85575. * @param callback defines the method to call once ready to upload
  85576. */
  85577. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  85578. }
  85579. }
  85580. declare module BABYLON {
  85581. /**
  85582. * Creation options of the multi render target texture.
  85583. */
  85584. export interface IMultiRenderTargetOptions {
  85585. /**
  85586. * Define if the texture needs to create mip maps after render.
  85587. */
  85588. generateMipMaps?: boolean;
  85589. /**
  85590. * Define the types of all the draw buffers we want to create
  85591. */
  85592. types?: number[];
  85593. /**
  85594. * Define the sampling modes of all the draw buffers we want to create
  85595. */
  85596. samplingModes?: number[];
  85597. /**
  85598. * Define if a depth buffer is required
  85599. */
  85600. generateDepthBuffer?: boolean;
  85601. /**
  85602. * Define if a stencil buffer is required
  85603. */
  85604. generateStencilBuffer?: boolean;
  85605. /**
  85606. * Define if a depth texture is required instead of a depth buffer
  85607. */
  85608. generateDepthTexture?: boolean;
  85609. /**
  85610. * Define the number of desired draw buffers
  85611. */
  85612. textureCount?: number;
  85613. /**
  85614. * Define if aspect ratio should be adapted to the texture or stay the scene one
  85615. */
  85616. doNotChangeAspectRatio?: boolean;
  85617. /**
  85618. * Define the default type of the buffers we are creating
  85619. */
  85620. defaultType?: number;
  85621. }
  85622. /**
  85623. * A multi render target, like a render target provides the ability to render to a texture.
  85624. * Unlike the render target, it can render to several draw buffers in one draw.
  85625. * This is specially interesting in deferred rendering or for any effects requiring more than
  85626. * just one color from a single pass.
  85627. */
  85628. export class MultiRenderTarget extends RenderTargetTexture {
  85629. private _internalTextures;
  85630. private _textures;
  85631. private _multiRenderTargetOptions;
  85632. /**
  85633. * Get if draw buffers are currently supported by the used hardware and browser.
  85634. */
  85635. readonly isSupported: boolean;
  85636. /**
  85637. * Get the list of textures generated by the multi render target.
  85638. */
  85639. readonly textures: Texture[];
  85640. /**
  85641. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  85642. */
  85643. readonly depthTexture: Texture;
  85644. /**
  85645. * Set the wrapping mode on U of all the textures we are rendering to.
  85646. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85647. */
  85648. wrapU: number;
  85649. /**
  85650. * Set the wrapping mode on V of all the textures we are rendering to.
  85651. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85652. */
  85653. wrapV: number;
  85654. /**
  85655. * Instantiate a new multi render target texture.
  85656. * A multi render target, like a render target provides the ability to render to a texture.
  85657. * Unlike the render target, it can render to several draw buffers in one draw.
  85658. * This is specially interesting in deferred rendering or for any effects requiring more than
  85659. * just one color from a single pass.
  85660. * @param name Define the name of the texture
  85661. * @param size Define the size of the buffers to render to
  85662. * @param count Define the number of target we are rendering into
  85663. * @param scene Define the scene the texture belongs to
  85664. * @param options Define the options used to create the multi render target
  85665. */
  85666. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  85667. /** @hidden */
  85668. _rebuild(): void;
  85669. private _createInternalTextures;
  85670. private _createTextures;
  85671. /**
  85672. * Define the number of samples used if MSAA is enabled.
  85673. */
  85674. samples: number;
  85675. /**
  85676. * Resize all the textures in the multi render target.
  85677. * Be carrefull as it will recreate all the data in the new texture.
  85678. * @param size Define the new size
  85679. */
  85680. resize(size: any): void;
  85681. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85682. /**
  85683. * Dispose the render targets and their associated resources
  85684. */
  85685. dispose(): void;
  85686. /**
  85687. * Release all the underlying texture used as draw buffers.
  85688. */
  85689. releaseInternalTextures(): void;
  85690. }
  85691. }
  85692. declare module BABYLON {
  85693. /**
  85694. * Class used to work with sound analyzer using fast fourier transform (FFT)
  85695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85696. */
  85697. export class Analyser {
  85698. /**
  85699. * Gets or sets the smoothing
  85700. * @ignorenaming
  85701. */
  85702. SMOOTHING: number;
  85703. /**
  85704. * Gets or sets the FFT table size
  85705. * @ignorenaming
  85706. */
  85707. FFT_SIZE: number;
  85708. /**
  85709. * Gets or sets the bar graph amplitude
  85710. * @ignorenaming
  85711. */
  85712. BARGRAPHAMPLITUDE: number;
  85713. /**
  85714. * Gets or sets the position of the debug canvas
  85715. * @ignorenaming
  85716. */
  85717. DEBUGCANVASPOS: {
  85718. x: number;
  85719. y: number;
  85720. };
  85721. /**
  85722. * Gets or sets the debug canvas size
  85723. * @ignorenaming
  85724. */
  85725. DEBUGCANVASSIZE: {
  85726. width: number;
  85727. height: number;
  85728. };
  85729. private _byteFreqs;
  85730. private _byteTime;
  85731. private _floatFreqs;
  85732. private _webAudioAnalyser;
  85733. private _debugCanvas;
  85734. private _debugCanvasContext;
  85735. private _scene;
  85736. private _registerFunc;
  85737. private _audioEngine;
  85738. /**
  85739. * Creates a new analyser
  85740. * @param scene defines hosting scene
  85741. */
  85742. constructor(scene: Scene);
  85743. /**
  85744. * Get the number of data values you will have to play with for the visualization
  85745. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  85746. * @returns a number
  85747. */
  85748. getFrequencyBinCount(): number;
  85749. /**
  85750. * Gets the current frequency data as a byte array
  85751. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85752. * @returns a Uint8Array
  85753. */
  85754. getByteFrequencyData(): Uint8Array;
  85755. /**
  85756. * Gets the current waveform as a byte array
  85757. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  85758. * @returns a Uint8Array
  85759. */
  85760. getByteTimeDomainData(): Uint8Array;
  85761. /**
  85762. * Gets the current frequency data as a float array
  85763. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85764. * @returns a Float32Array
  85765. */
  85766. getFloatFrequencyData(): Float32Array;
  85767. /**
  85768. * Renders the debug canvas
  85769. */
  85770. drawDebugCanvas(): void;
  85771. /**
  85772. * Stops rendering the debug canvas and removes it
  85773. */
  85774. stopDebugCanvas(): void;
  85775. /**
  85776. * Connects two audio nodes
  85777. * @param inputAudioNode defines first node to connect
  85778. * @param outputAudioNode defines second node to connect
  85779. */
  85780. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  85781. /**
  85782. * Releases all associated resources
  85783. */
  85784. dispose(): void;
  85785. }
  85786. }
  85787. declare module BABYLON {
  85788. /**
  85789. * This represents an audio engine and it is responsible
  85790. * to play, synchronize and analyse sounds throughout the application.
  85791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85792. */
  85793. export interface IAudioEngine extends IDisposable {
  85794. /**
  85795. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85796. */
  85797. readonly canUseWebAudio: boolean;
  85798. /**
  85799. * Gets the current AudioContext if available.
  85800. */
  85801. readonly audioContext: Nullable<AudioContext>;
  85802. /**
  85803. * The master gain node defines the global audio volume of your audio engine.
  85804. */
  85805. readonly masterGain: GainNode;
  85806. /**
  85807. * Gets whether or not mp3 are supported by your browser.
  85808. */
  85809. readonly isMP3supported: boolean;
  85810. /**
  85811. * Gets whether or not ogg are supported by your browser.
  85812. */
  85813. readonly isOGGsupported: boolean;
  85814. /**
  85815. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85816. * @ignoreNaming
  85817. */
  85818. WarnedWebAudioUnsupported: boolean;
  85819. /**
  85820. * Defines if the audio engine relies on a custom unlocked button.
  85821. * In this case, the embedded button will not be displayed.
  85822. */
  85823. useCustomUnlockedButton: boolean;
  85824. /**
  85825. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  85826. */
  85827. readonly unlocked: boolean;
  85828. /**
  85829. * Event raised when audio has been unlocked on the browser.
  85830. */
  85831. onAudioUnlockedObservable: Observable<AudioEngine>;
  85832. /**
  85833. * Event raised when audio has been locked on the browser.
  85834. */
  85835. onAudioLockedObservable: Observable<AudioEngine>;
  85836. /**
  85837. * Flags the audio engine in Locked state.
  85838. * This happens due to new browser policies preventing audio to autoplay.
  85839. */
  85840. lock(): void;
  85841. /**
  85842. * Unlocks the audio engine once a user action has been done on the dom.
  85843. * This is helpful to resume play once browser policies have been satisfied.
  85844. */
  85845. unlock(): void;
  85846. }
  85847. /**
  85848. * This represents the default audio engine used in babylon.
  85849. * It is responsible to play, synchronize and analyse sounds throughout the application.
  85850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85851. */
  85852. export class AudioEngine implements IAudioEngine {
  85853. private _audioContext;
  85854. private _audioContextInitialized;
  85855. private _muteButton;
  85856. private _hostElement;
  85857. /**
  85858. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85859. */
  85860. canUseWebAudio: boolean;
  85861. /**
  85862. * The master gain node defines the global audio volume of your audio engine.
  85863. */
  85864. masterGain: GainNode;
  85865. /**
  85866. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85867. * @ignoreNaming
  85868. */
  85869. WarnedWebAudioUnsupported: boolean;
  85870. /**
  85871. * Gets whether or not mp3 are supported by your browser.
  85872. */
  85873. isMP3supported: boolean;
  85874. /**
  85875. * Gets whether or not ogg are supported by your browser.
  85876. */
  85877. isOGGsupported: boolean;
  85878. /**
  85879. * Gets whether audio has been unlocked on the device.
  85880. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  85881. * a user interaction has happened.
  85882. */
  85883. unlocked: boolean;
  85884. /**
  85885. * Defines if the audio engine relies on a custom unlocked button.
  85886. * In this case, the embedded button will not be displayed.
  85887. */
  85888. useCustomUnlockedButton: boolean;
  85889. /**
  85890. * Event raised when audio has been unlocked on the browser.
  85891. */
  85892. onAudioUnlockedObservable: Observable<AudioEngine>;
  85893. /**
  85894. * Event raised when audio has been locked on the browser.
  85895. */
  85896. onAudioLockedObservable: Observable<AudioEngine>;
  85897. /**
  85898. * Gets the current AudioContext if available.
  85899. */
  85900. readonly audioContext: Nullable<AudioContext>;
  85901. private _connectedAnalyser;
  85902. /**
  85903. * Instantiates a new audio engine.
  85904. *
  85905. * There should be only one per page as some browsers restrict the number
  85906. * of audio contexts you can create.
  85907. * @param hostElement defines the host element where to display the mute icon if necessary
  85908. */
  85909. constructor(hostElement?: Nullable<HTMLElement>);
  85910. /**
  85911. * Flags the audio engine in Locked state.
  85912. * This happens due to new browser policies preventing audio to autoplay.
  85913. */
  85914. lock(): void;
  85915. /**
  85916. * Unlocks the audio engine once a user action has been done on the dom.
  85917. * This is helpful to resume play once browser policies have been satisfied.
  85918. */
  85919. unlock(): void;
  85920. private _resumeAudioContext;
  85921. private _initializeAudioContext;
  85922. private _tryToRun;
  85923. private _triggerRunningState;
  85924. private _triggerSuspendedState;
  85925. private _displayMuteButton;
  85926. private _moveButtonToTopLeft;
  85927. private _onResize;
  85928. private _hideMuteButton;
  85929. /**
  85930. * Destroy and release the resources associated with the audio ccontext.
  85931. */
  85932. dispose(): void;
  85933. /**
  85934. * Gets the global volume sets on the master gain.
  85935. * @returns the global volume if set or -1 otherwise
  85936. */
  85937. getGlobalVolume(): number;
  85938. /**
  85939. * Sets the global volume of your experience (sets on the master gain).
  85940. * @param newVolume Defines the new global volume of the application
  85941. */
  85942. setGlobalVolume(newVolume: number): void;
  85943. /**
  85944. * Connect the audio engine to an audio analyser allowing some amazing
  85945. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  85946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  85947. * @param analyser The analyser to connect to the engine
  85948. */
  85949. connectToAnalyser(analyser: Analyser): void;
  85950. }
  85951. }
  85952. declare module BABYLON {
  85953. /**
  85954. * Interface used to present a loading screen while loading a scene
  85955. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85956. */
  85957. export interface ILoadingScreen {
  85958. /**
  85959. * Function called to display the loading screen
  85960. */
  85961. displayLoadingUI: () => void;
  85962. /**
  85963. * Function called to hide the loading screen
  85964. */
  85965. hideLoadingUI: () => void;
  85966. /**
  85967. * Gets or sets the color to use for the background
  85968. */
  85969. loadingUIBackgroundColor: string;
  85970. /**
  85971. * Gets or sets the text to display while loading
  85972. */
  85973. loadingUIText: string;
  85974. }
  85975. /**
  85976. * Class used for the default loading screen
  85977. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85978. */
  85979. export class DefaultLoadingScreen implements ILoadingScreen {
  85980. private _renderingCanvas;
  85981. private _loadingText;
  85982. private _loadingDivBackgroundColor;
  85983. private _loadingDiv;
  85984. private _loadingTextDiv;
  85985. /**
  85986. * Creates a new default loading screen
  85987. * @param _renderingCanvas defines the canvas used to render the scene
  85988. * @param _loadingText defines the default text to display
  85989. * @param _loadingDivBackgroundColor defines the default background color
  85990. */
  85991. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  85992. /**
  85993. * Function called to display the loading screen
  85994. */
  85995. displayLoadingUI(): void;
  85996. /**
  85997. * Function called to hide the loading screen
  85998. */
  85999. hideLoadingUI(): void;
  86000. /**
  86001. * Gets or sets the text to display while loading
  86002. */
  86003. loadingUIText: string;
  86004. /**
  86005. * Gets or sets the color to use for the background
  86006. */
  86007. loadingUIBackgroundColor: string;
  86008. private _resizeLoadingUI;
  86009. }
  86010. }
  86011. declare module BABYLON {
  86012. /**
  86013. * Settings for finer control over video usage
  86014. */
  86015. export interface VideoTextureSettings {
  86016. /**
  86017. * Applies `autoplay` to video, if specified
  86018. */
  86019. autoPlay?: boolean;
  86020. /**
  86021. * Applies `loop` to video, if specified
  86022. */
  86023. loop?: boolean;
  86024. /**
  86025. * Automatically updates internal texture from video at every frame in the render loop
  86026. */
  86027. autoUpdateTexture: boolean;
  86028. /**
  86029. * Image src displayed during the video loading or until the user interacts with the video.
  86030. */
  86031. poster?: string;
  86032. }
  86033. /**
  86034. * If you want to display a video in your scene, this is the special texture for that.
  86035. * This special texture works similar to other textures, with the exception of a few parameters.
  86036. * @see https://doc.babylonjs.com/how_to/video_texture
  86037. */
  86038. export class VideoTexture extends Texture {
  86039. /**
  86040. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86041. */
  86042. readonly autoUpdateTexture: boolean;
  86043. /**
  86044. * The video instance used by the texture internally
  86045. */
  86046. readonly video: HTMLVideoElement;
  86047. private _onUserActionRequestedObservable;
  86048. /**
  86049. * Event triggerd when a dom action is required by the user to play the video.
  86050. * This happens due to recent changes in browser policies preventing video to auto start.
  86051. */
  86052. readonly onUserActionRequestedObservable: Observable<Texture>;
  86053. private _generateMipMaps;
  86054. private _engine;
  86055. private _stillImageCaptured;
  86056. private _displayingPosterTexture;
  86057. private _settings;
  86058. private _createInternalTextureOnEvent;
  86059. /**
  86060. * Creates a video texture.
  86061. * If you want to display a video in your scene, this is the special texture for that.
  86062. * This special texture works similar to other textures, with the exception of a few parameters.
  86063. * @see https://doc.babylonjs.com/how_to/video_texture
  86064. * @param name optional name, will detect from video source, if not defined
  86065. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86066. * @param scene is obviously the current scene.
  86067. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86068. * @param invertY is false by default but can be used to invert video on Y axis
  86069. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86070. * @param settings allows finer control over video usage
  86071. */
  86072. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86073. private _getName;
  86074. private _getVideo;
  86075. private _createInternalTexture;
  86076. private reset;
  86077. /**
  86078. * @hidden Internal method to initiate `update`.
  86079. */
  86080. _rebuild(): void;
  86081. /**
  86082. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86083. */
  86084. update(): void;
  86085. /**
  86086. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86087. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86088. */
  86089. updateTexture(isVisible: boolean): void;
  86090. protected _updateInternalTexture: () => void;
  86091. /**
  86092. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86093. * @param url New url.
  86094. */
  86095. updateURL(url: string): void;
  86096. /**
  86097. * Dispose the texture and release its associated resources.
  86098. */
  86099. dispose(): void;
  86100. /**
  86101. * Creates a video texture straight from a stream.
  86102. * @param scene Define the scene the texture should be created in
  86103. * @param stream Define the stream the texture should be created from
  86104. * @returns The created video texture as a promise
  86105. */
  86106. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86107. /**
  86108. * Creates a video texture straight from your WebCam video feed.
  86109. * @param scene Define the scene the texture should be created in
  86110. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86111. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86112. * @returns The created video texture as a promise
  86113. */
  86114. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86115. minWidth: number;
  86116. maxWidth: number;
  86117. minHeight: number;
  86118. maxHeight: number;
  86119. deviceId: string;
  86120. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86121. /**
  86122. * Creates a video texture straight from your WebCam video feed.
  86123. * @param scene Define the scene the texture should be created in
  86124. * @param onReady Define a callback to triggered once the texture will be ready
  86125. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86126. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86127. */
  86128. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86129. minWidth: number;
  86130. maxWidth: number;
  86131. minHeight: number;
  86132. maxHeight: number;
  86133. deviceId: string;
  86134. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86135. }
  86136. }
  86137. declare module BABYLON {
  86138. /**
  86139. * Interface for attribute information associated with buffer instanciation
  86140. */
  86141. export class InstancingAttributeInfo {
  86142. /**
  86143. * Index/offset of the attribute in the vertex shader
  86144. */
  86145. index: number;
  86146. /**
  86147. * size of the attribute, 1, 2, 3 or 4
  86148. */
  86149. attributeSize: number;
  86150. /**
  86151. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86152. * default is FLOAT
  86153. */
  86154. attribyteType: number;
  86155. /**
  86156. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86157. */
  86158. normalized: boolean;
  86159. /**
  86160. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86161. */
  86162. offset: number;
  86163. /**
  86164. * Name of the GLSL attribute, for debugging purpose only
  86165. */
  86166. attributeName: string;
  86167. }
  86168. /**
  86169. * Define options used to create a depth texture
  86170. */
  86171. export class DepthTextureCreationOptions {
  86172. /** Specifies whether or not a stencil should be allocated in the texture */
  86173. generateStencil?: boolean;
  86174. /** Specifies whether or not bilinear filtering is enable on the texture */
  86175. bilinearFiltering?: boolean;
  86176. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86177. comparisonFunction?: number;
  86178. /** Specifies if the created texture is a cube texture */
  86179. isCube?: boolean;
  86180. }
  86181. /**
  86182. * Class used to describe the capabilities of the engine relatively to the current browser
  86183. */
  86184. export class EngineCapabilities {
  86185. /** Maximum textures units per fragment shader */
  86186. maxTexturesImageUnits: number;
  86187. /** Maximum texture units per vertex shader */
  86188. maxVertexTextureImageUnits: number;
  86189. /** Maximum textures units in the entire pipeline */
  86190. maxCombinedTexturesImageUnits: number;
  86191. /** Maximum texture size */
  86192. maxTextureSize: number;
  86193. /** Maximum cube texture size */
  86194. maxCubemapTextureSize: number;
  86195. /** Maximum render texture size */
  86196. maxRenderTextureSize: number;
  86197. /** Maximum number of vertex attributes */
  86198. maxVertexAttribs: number;
  86199. /** Maximum number of varyings */
  86200. maxVaryingVectors: number;
  86201. /** Maximum number of uniforms per vertex shader */
  86202. maxVertexUniformVectors: number;
  86203. /** Maximum number of uniforms per fragment shader */
  86204. maxFragmentUniformVectors: number;
  86205. /** Defines if standard derivates (dx/dy) are supported */
  86206. standardDerivatives: boolean;
  86207. /** Defines if s3tc texture compression is supported */
  86208. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86209. /** Defines if pvrtc texture compression is supported */
  86210. pvrtc: any;
  86211. /** Defines if etc1 texture compression is supported */
  86212. etc1: any;
  86213. /** Defines if etc2 texture compression is supported */
  86214. etc2: any;
  86215. /** Defines if astc texture compression is supported */
  86216. astc: any;
  86217. /** Defines if float textures are supported */
  86218. textureFloat: boolean;
  86219. /** Defines if vertex array objects are supported */
  86220. vertexArrayObject: boolean;
  86221. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  86222. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  86223. /** Gets the maximum level of anisotropy supported */
  86224. maxAnisotropy: number;
  86225. /** Defines if instancing is supported */
  86226. instancedArrays: boolean;
  86227. /** Defines if 32 bits indices are supported */
  86228. uintIndices: boolean;
  86229. /** Defines if high precision shaders are supported */
  86230. highPrecisionShaderSupported: boolean;
  86231. /** Defines if depth reading in the fragment shader is supported */
  86232. fragmentDepthSupported: boolean;
  86233. /** Defines if float texture linear filtering is supported*/
  86234. textureFloatLinearFiltering: boolean;
  86235. /** Defines if rendering to float textures is supported */
  86236. textureFloatRender: boolean;
  86237. /** Defines if half float textures are supported*/
  86238. textureHalfFloat: boolean;
  86239. /** Defines if half float texture linear filtering is supported*/
  86240. textureHalfFloatLinearFiltering: boolean;
  86241. /** Defines if rendering to half float textures is supported */
  86242. textureHalfFloatRender: boolean;
  86243. /** Defines if textureLOD shader command is supported */
  86244. textureLOD: boolean;
  86245. /** Defines if draw buffers extension is supported */
  86246. drawBuffersExtension: boolean;
  86247. /** Defines if depth textures are supported */
  86248. depthTextureExtension: boolean;
  86249. /** Defines if float color buffer are supported */
  86250. colorBufferFloat: boolean;
  86251. /** Gets disjoint timer query extension (null if not supported) */
  86252. timerQuery: EXT_disjoint_timer_query;
  86253. /** Defines if timestamp can be used with timer query */
  86254. canUseTimestampForTimerQuery: boolean;
  86255. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  86256. multiview: any;
  86257. /** Function used to let the system compiles shaders in background */
  86258. parallelShaderCompile: {
  86259. COMPLETION_STATUS_KHR: number;
  86260. };
  86261. }
  86262. /** Interface defining initialization parameters for Engine class */
  86263. export interface EngineOptions extends WebGLContextAttributes {
  86264. /**
  86265. * Defines if the engine should no exceed a specified device ratio
  86266. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  86267. */
  86268. limitDeviceRatio?: number;
  86269. /**
  86270. * Defines if webvr should be enabled automatically
  86271. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86272. */
  86273. autoEnableWebVR?: boolean;
  86274. /**
  86275. * Defines if webgl2 should be turned off even if supported
  86276. * @see http://doc.babylonjs.com/features/webgl2
  86277. */
  86278. disableWebGL2Support?: boolean;
  86279. /**
  86280. * Defines if webaudio should be initialized as well
  86281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86282. */
  86283. audioEngine?: boolean;
  86284. /**
  86285. * Defines if animations should run using a deterministic lock step
  86286. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86287. */
  86288. deterministicLockstep?: boolean;
  86289. /** Defines the maximum steps to use with deterministic lock step mode */
  86290. lockstepMaxSteps?: number;
  86291. /**
  86292. * Defines that engine should ignore context lost events
  86293. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  86294. */
  86295. doNotHandleContextLost?: boolean;
  86296. /**
  86297. * Defines that engine should ignore modifying touch action attribute and style
  86298. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  86299. */
  86300. doNotHandleTouchAction?: boolean;
  86301. /**
  86302. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  86303. */
  86304. useHighPrecisionFloats?: boolean;
  86305. }
  86306. /**
  86307. * Defines the interface used by display changed events
  86308. */
  86309. export interface IDisplayChangedEventArgs {
  86310. /** Gets the vrDisplay object (if any) */
  86311. vrDisplay: Nullable<any>;
  86312. /** Gets a boolean indicating if webVR is supported */
  86313. vrSupported: boolean;
  86314. }
  86315. /**
  86316. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  86317. */
  86318. export class Engine {
  86319. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  86320. static ExceptionList: ({
  86321. key: string;
  86322. capture: string;
  86323. captureConstraint: number;
  86324. targets: string[];
  86325. } | {
  86326. key: string;
  86327. capture: null;
  86328. captureConstraint: null;
  86329. targets: string[];
  86330. })[];
  86331. /** Gets the list of created engines */
  86332. static readonly Instances: Engine[];
  86333. /**
  86334. * Gets the latest created engine
  86335. */
  86336. static readonly LastCreatedEngine: Nullable<Engine>;
  86337. /**
  86338. * Gets the latest created scene
  86339. */
  86340. static readonly LastCreatedScene: Nullable<Scene>;
  86341. /**
  86342. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  86343. * @param flag defines which part of the materials must be marked as dirty
  86344. * @param predicate defines a predicate used to filter which materials should be affected
  86345. */
  86346. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  86347. /**
  86348. * Hidden
  86349. */
  86350. static _TextureLoaders: IInternalTextureLoader[];
  86351. /** Defines that alpha blending is disabled */
  86352. static readonly ALPHA_DISABLE: number;
  86353. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  86354. static readonly ALPHA_ADD: number;
  86355. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86356. static readonly ALPHA_COMBINE: number;
  86357. /** Defines that alpha blending to DEST - SRC * DEST */
  86358. static readonly ALPHA_SUBTRACT: number;
  86359. /** Defines that alpha blending to SRC * DEST */
  86360. static readonly ALPHA_MULTIPLY: number;
  86361. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  86362. static readonly ALPHA_MAXIMIZED: number;
  86363. /** Defines that alpha blending to SRC + DEST */
  86364. static readonly ALPHA_ONEONE: number;
  86365. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  86366. static readonly ALPHA_PREMULTIPLIED: number;
  86367. /**
  86368. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86369. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86370. */
  86371. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86372. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86373. static readonly ALPHA_INTERPOLATE: number;
  86374. /**
  86375. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86376. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86377. */
  86378. static readonly ALPHA_SCREENMODE: number;
  86379. /** Defines that the ressource is not delayed*/
  86380. static readonly DELAYLOADSTATE_NONE: number;
  86381. /** Defines that the ressource was successfully delay loaded */
  86382. static readonly DELAYLOADSTATE_LOADED: number;
  86383. /** Defines that the ressource is currently delay loading */
  86384. static readonly DELAYLOADSTATE_LOADING: number;
  86385. /** Defines that the ressource is delayed and has not started loading */
  86386. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86387. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86388. static readonly NEVER: number;
  86389. /** 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 */
  86390. static readonly ALWAYS: number;
  86391. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86392. static readonly LESS: number;
  86393. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86394. static readonly EQUAL: number;
  86395. /** 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 */
  86396. static readonly LEQUAL: number;
  86397. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86398. static readonly GREATER: number;
  86399. /** 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 */
  86400. static readonly GEQUAL: number;
  86401. /** 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 */
  86402. static readonly NOTEQUAL: number;
  86403. /** Passed to stencilOperation to specify that stencil value must be kept */
  86404. static readonly KEEP: number;
  86405. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86406. static readonly REPLACE: number;
  86407. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86408. static readonly INCR: number;
  86409. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86410. static readonly DECR: number;
  86411. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86412. static readonly INVERT: number;
  86413. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86414. static readonly INCR_WRAP: number;
  86415. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86416. static readonly DECR_WRAP: number;
  86417. /** Texture is not repeating outside of 0..1 UVs */
  86418. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86419. /** Texture is repeating outside of 0..1 UVs */
  86420. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86421. /** Texture is repeating and mirrored */
  86422. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86423. /** ALPHA */
  86424. static readonly TEXTUREFORMAT_ALPHA: number;
  86425. /** LUMINANCE */
  86426. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86427. /** LUMINANCE_ALPHA */
  86428. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86429. /** RGB */
  86430. static readonly TEXTUREFORMAT_RGB: number;
  86431. /** RGBA */
  86432. static readonly TEXTUREFORMAT_RGBA: number;
  86433. /** RED */
  86434. static readonly TEXTUREFORMAT_RED: number;
  86435. /** RED (2nd reference) */
  86436. static readonly TEXTUREFORMAT_R: number;
  86437. /** RG */
  86438. static readonly TEXTUREFORMAT_RG: number;
  86439. /** RED_INTEGER */
  86440. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86441. /** RED_INTEGER (2nd reference) */
  86442. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86443. /** RG_INTEGER */
  86444. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86445. /** RGB_INTEGER */
  86446. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86447. /** RGBA_INTEGER */
  86448. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86449. /** UNSIGNED_BYTE */
  86450. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86451. /** UNSIGNED_BYTE (2nd reference) */
  86452. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86453. /** FLOAT */
  86454. static readonly TEXTURETYPE_FLOAT: number;
  86455. /** HALF_FLOAT */
  86456. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86457. /** BYTE */
  86458. static readonly TEXTURETYPE_BYTE: number;
  86459. /** SHORT */
  86460. static readonly TEXTURETYPE_SHORT: number;
  86461. /** UNSIGNED_SHORT */
  86462. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86463. /** INT */
  86464. static readonly TEXTURETYPE_INT: number;
  86465. /** UNSIGNED_INT */
  86466. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86467. /** UNSIGNED_SHORT_4_4_4_4 */
  86468. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86469. /** UNSIGNED_SHORT_5_5_5_1 */
  86470. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86471. /** UNSIGNED_SHORT_5_6_5 */
  86472. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86473. /** UNSIGNED_INT_2_10_10_10_REV */
  86474. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86475. /** UNSIGNED_INT_24_8 */
  86476. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86477. /** UNSIGNED_INT_10F_11F_11F_REV */
  86478. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86479. /** UNSIGNED_INT_5_9_9_9_REV */
  86480. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86481. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86482. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86483. /** nearest is mag = nearest and min = nearest and mip = linear */
  86484. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86485. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86486. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86487. /** Trilinear is mag = linear and min = linear and mip = linear */
  86488. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86489. /** nearest is mag = nearest and min = nearest and mip = linear */
  86490. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86491. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86492. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86493. /** Trilinear is mag = linear and min = linear and mip = linear */
  86494. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86495. /** mag = nearest and min = nearest and mip = nearest */
  86496. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86497. /** mag = nearest and min = linear and mip = nearest */
  86498. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86499. /** mag = nearest and min = linear and mip = linear */
  86500. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86501. /** mag = nearest and min = linear and mip = none */
  86502. static readonly TEXTURE_NEAREST_LINEAR: number;
  86503. /** mag = nearest and min = nearest and mip = none */
  86504. static readonly TEXTURE_NEAREST_NEAREST: number;
  86505. /** mag = linear and min = nearest and mip = nearest */
  86506. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86507. /** mag = linear and min = nearest and mip = linear */
  86508. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86509. /** mag = linear and min = linear and mip = none */
  86510. static readonly TEXTURE_LINEAR_LINEAR: number;
  86511. /** mag = linear and min = nearest and mip = none */
  86512. static readonly TEXTURE_LINEAR_NEAREST: number;
  86513. /** Explicit coordinates mode */
  86514. static readonly TEXTURE_EXPLICIT_MODE: number;
  86515. /** Spherical coordinates mode */
  86516. static readonly TEXTURE_SPHERICAL_MODE: number;
  86517. /** Planar coordinates mode */
  86518. static readonly TEXTURE_PLANAR_MODE: number;
  86519. /** Cubic coordinates mode */
  86520. static readonly TEXTURE_CUBIC_MODE: number;
  86521. /** Projection coordinates mode */
  86522. static readonly TEXTURE_PROJECTION_MODE: number;
  86523. /** Skybox coordinates mode */
  86524. static readonly TEXTURE_SKYBOX_MODE: number;
  86525. /** Inverse Cubic coordinates mode */
  86526. static readonly TEXTURE_INVCUBIC_MODE: number;
  86527. /** Equirectangular coordinates mode */
  86528. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86529. /** Equirectangular Fixed coordinates mode */
  86530. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86531. /** Equirectangular Fixed Mirrored coordinates mode */
  86532. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86533. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86534. static readonly SCALEMODE_FLOOR: number;
  86535. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86536. static readonly SCALEMODE_NEAREST: number;
  86537. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86538. static readonly SCALEMODE_CEILING: number;
  86539. /**
  86540. * Returns the current npm package of the sdk
  86541. */
  86542. static readonly NpmPackage: string;
  86543. /**
  86544. * Returns the current version of the framework
  86545. */
  86546. static readonly Version: string;
  86547. /**
  86548. * Returns a string describing the current engine
  86549. */
  86550. readonly description: string;
  86551. /**
  86552. * Gets or sets the epsilon value used by collision engine
  86553. */
  86554. static CollisionsEpsilon: number;
  86555. /**
  86556. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86557. */
  86558. static ShadersRepository: string;
  86559. /**
  86560. * Method called to create the default loading screen.
  86561. * This can be overriden in your own app.
  86562. * @param canvas The rendering canvas element
  86563. * @returns The loading screen
  86564. */
  86565. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  86566. /**
  86567. * Method called to create the default rescale post process on each engine.
  86568. */
  86569. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  86570. /**
  86571. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  86572. */
  86573. forcePOTTextures: boolean;
  86574. /**
  86575. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  86576. */
  86577. isFullscreen: boolean;
  86578. /**
  86579. * Gets a boolean indicating if the pointer is currently locked
  86580. */
  86581. isPointerLock: boolean;
  86582. /**
  86583. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  86584. */
  86585. cullBackFaces: boolean;
  86586. /**
  86587. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  86588. */
  86589. renderEvenInBackground: boolean;
  86590. /**
  86591. * Gets or sets a boolean indicating that cache can be kept between frames
  86592. */
  86593. preventCacheWipeBetweenFrames: boolean;
  86594. /**
  86595. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  86596. **/
  86597. enableOfflineSupport: boolean;
  86598. /**
  86599. * 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)
  86600. **/
  86601. disableManifestCheck: boolean;
  86602. /**
  86603. * Gets the list of created scenes
  86604. */
  86605. scenes: Scene[];
  86606. /**
  86607. * Event raised when a new scene is created
  86608. */
  86609. onNewSceneAddedObservable: Observable<Scene>;
  86610. /**
  86611. * Gets the list of created postprocesses
  86612. */
  86613. postProcesses: PostProcess[];
  86614. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  86615. validateShaderPrograms: boolean;
  86616. /**
  86617. * Observable event triggered each time the rendering canvas is resized
  86618. */
  86619. onResizeObservable: Observable<Engine>;
  86620. /**
  86621. * Observable event triggered each time the canvas loses focus
  86622. */
  86623. onCanvasBlurObservable: Observable<Engine>;
  86624. /**
  86625. * Observable event triggered each time the canvas gains focus
  86626. */
  86627. onCanvasFocusObservable: Observable<Engine>;
  86628. /**
  86629. * Observable event triggered each time the canvas receives pointerout event
  86630. */
  86631. onCanvasPointerOutObservable: Observable<PointerEvent>;
  86632. /**
  86633. * Observable event triggered before each texture is initialized
  86634. */
  86635. onBeforeTextureInitObservable: Observable<Texture>;
  86636. private _vrDisplay;
  86637. private _vrSupported;
  86638. private _oldSize;
  86639. private _oldHardwareScaleFactor;
  86640. private _vrExclusivePointerMode;
  86641. private _webVRInitPromise;
  86642. /**
  86643. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86644. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86645. */
  86646. readonly isInVRExclusivePointerMode: boolean;
  86647. /**
  86648. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  86649. */
  86650. disableUniformBuffers: boolean;
  86651. /** @hidden */
  86652. _uniformBuffers: UniformBuffer[];
  86653. /**
  86654. * Gets a boolean indicating that the engine supports uniform buffers
  86655. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86656. */
  86657. readonly supportsUniformBuffers: boolean;
  86658. /**
  86659. * Observable raised when the engine begins a new frame
  86660. */
  86661. onBeginFrameObservable: Observable<Engine>;
  86662. /**
  86663. * If set, will be used to request the next animation frame for the render loop
  86664. */
  86665. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  86666. /**
  86667. * Observable raised when the engine ends the current frame
  86668. */
  86669. onEndFrameObservable: Observable<Engine>;
  86670. /**
  86671. * Observable raised when the engine is about to compile a shader
  86672. */
  86673. onBeforeShaderCompilationObservable: Observable<Engine>;
  86674. /**
  86675. * Observable raised when the engine has jsut compiled a shader
  86676. */
  86677. onAfterShaderCompilationObservable: Observable<Engine>;
  86678. /** @hidden */
  86679. _gl: WebGLRenderingContext;
  86680. private _renderingCanvas;
  86681. private _windowIsBackground;
  86682. private _webGLVersion;
  86683. protected _highPrecisionShadersAllowed: boolean;
  86684. /** @hidden */
  86685. readonly _shouldUseHighPrecisionShader: boolean;
  86686. /**
  86687. * Gets a boolean indicating that only power of 2 textures are supported
  86688. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  86689. */
  86690. readonly needPOTTextures: boolean;
  86691. /** @hidden */
  86692. _badOS: boolean;
  86693. /** @hidden */
  86694. _badDesktopOS: boolean;
  86695. /**
  86696. * Gets the audio engine
  86697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86698. * @ignorenaming
  86699. */
  86700. static audioEngine: IAudioEngine;
  86701. /**
  86702. * Default AudioEngine factory responsible of creating the Audio Engine.
  86703. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  86704. */
  86705. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  86706. /**
  86707. * Default offline support factory responsible of creating a tool used to store data locally.
  86708. * By default, this will create a Database object if the workload has been embedded.
  86709. */
  86710. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  86711. private _onFocus;
  86712. private _onBlur;
  86713. private _onCanvasPointerOut;
  86714. private _onCanvasBlur;
  86715. private _onCanvasFocus;
  86716. private _onFullscreenChange;
  86717. private _onPointerLockChange;
  86718. private _onVRDisplayPointerRestricted;
  86719. private _onVRDisplayPointerUnrestricted;
  86720. private _onVrDisplayConnect;
  86721. private _onVrDisplayDisconnect;
  86722. private _onVrDisplayPresentChange;
  86723. /**
  86724. * Observable signaled when VR display mode changes
  86725. */
  86726. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86727. /**
  86728. * Observable signaled when VR request present is complete
  86729. */
  86730. onVRRequestPresentComplete: Observable<boolean>;
  86731. /**
  86732. * Observable signaled when VR request present starts
  86733. */
  86734. onVRRequestPresentStart: Observable<Engine>;
  86735. private _hardwareScalingLevel;
  86736. /** @hidden */
  86737. protected _caps: EngineCapabilities;
  86738. private _pointerLockRequested;
  86739. private _isStencilEnable;
  86740. private _colorWrite;
  86741. private _loadingScreen;
  86742. /** @hidden */
  86743. _drawCalls: PerfCounter;
  86744. private _glVersion;
  86745. private _glRenderer;
  86746. private _glVendor;
  86747. private _videoTextureSupported;
  86748. private _renderingQueueLaunched;
  86749. private _activeRenderLoops;
  86750. private _deterministicLockstep;
  86751. private _lockstepMaxSteps;
  86752. /**
  86753. * Observable signaled when a context lost event is raised
  86754. */
  86755. onContextLostObservable: Observable<Engine>;
  86756. /**
  86757. * Observable signaled when a context restored event is raised
  86758. */
  86759. onContextRestoredObservable: Observable<Engine>;
  86760. private _onContextLost;
  86761. private _onContextRestored;
  86762. private _contextWasLost;
  86763. private _doNotHandleContextLost;
  86764. /**
  86765. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  86766. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  86767. */
  86768. doNotHandleContextLost: boolean;
  86769. private _performanceMonitor;
  86770. private _fps;
  86771. private _deltaTime;
  86772. /**
  86773. * Turn this value on if you want to pause FPS computation when in background
  86774. */
  86775. disablePerformanceMonitorInBackground: boolean;
  86776. /**
  86777. * Gets the performance monitor attached to this engine
  86778. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  86779. */
  86780. readonly performanceMonitor: PerformanceMonitor;
  86781. /**
  86782. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  86783. */
  86784. disableVertexArrayObjects: boolean;
  86785. /** @hidden */
  86786. protected _depthCullingState: _DepthCullingState;
  86787. /** @hidden */
  86788. protected _stencilState: _StencilState;
  86789. /** @hidden */
  86790. protected _alphaState: _AlphaState;
  86791. /** @hidden */
  86792. protected _alphaMode: number;
  86793. protected _internalTexturesCache: InternalTexture[];
  86794. /** @hidden */
  86795. protected _activeChannel: number;
  86796. private _currentTextureChannel;
  86797. /** @hidden */
  86798. protected _boundTexturesCache: {
  86799. [key: string]: Nullable<InternalTexture>;
  86800. };
  86801. /** @hidden */
  86802. protected _currentEffect: Nullable<Effect>;
  86803. /** @hidden */
  86804. protected _currentProgram: Nullable<WebGLProgram>;
  86805. private _compiledEffects;
  86806. private _vertexAttribArraysEnabled;
  86807. /** @hidden */
  86808. protected _cachedViewport: Nullable<Viewport>;
  86809. private _cachedVertexArrayObject;
  86810. /** @hidden */
  86811. protected _cachedVertexBuffers: any;
  86812. /** @hidden */
  86813. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  86814. /** @hidden */
  86815. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  86816. /** @hidden */
  86817. protected _currentRenderTarget: Nullable<InternalTexture>;
  86818. private _uintIndicesCurrentlySet;
  86819. private _currentBoundBuffer;
  86820. /** @hidden */
  86821. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  86822. private _currentBufferPointers;
  86823. private _currentInstanceLocations;
  86824. private _currentInstanceBuffers;
  86825. private _textureUnits;
  86826. private _workingCanvas;
  86827. private _workingContext;
  86828. private _rescalePostProcess;
  86829. private _dummyFramebuffer;
  86830. private _externalData;
  86831. private _bindedRenderFunction;
  86832. private _vaoRecordInProgress;
  86833. private _mustWipeVertexAttributes;
  86834. private _emptyTexture;
  86835. private _emptyCubeTexture;
  86836. private _emptyTexture3D;
  86837. /** @hidden */
  86838. _frameHandler: number;
  86839. private _nextFreeTextureSlots;
  86840. private _maxSimultaneousTextures;
  86841. private _activeRequests;
  86842. private _texturesSupported;
  86843. private _textureFormatInUse;
  86844. /**
  86845. * Gets the list of texture formats supported
  86846. */
  86847. readonly texturesSupported: Array<string>;
  86848. /**
  86849. * Gets the list of texture formats in use
  86850. */
  86851. readonly textureFormatInUse: Nullable<string>;
  86852. /**
  86853. * Gets the current viewport
  86854. */
  86855. readonly currentViewport: Nullable<Viewport>;
  86856. /**
  86857. * Gets the default empty texture
  86858. */
  86859. readonly emptyTexture: InternalTexture;
  86860. /**
  86861. * Gets the default empty 3D texture
  86862. */
  86863. readonly emptyTexture3D: InternalTexture;
  86864. /**
  86865. * Gets the default empty cube texture
  86866. */
  86867. readonly emptyCubeTexture: InternalTexture;
  86868. /**
  86869. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  86870. */
  86871. readonly premultipliedAlpha: boolean;
  86872. /**
  86873. * Creates a new engine
  86874. * @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
  86875. * @param antialias defines enable antialiasing (default: false)
  86876. * @param options defines further options to be sent to the getContext() function
  86877. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  86878. */
  86879. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  86880. private _disableTouchAction;
  86881. private _rebuildInternalTextures;
  86882. private _rebuildEffects;
  86883. /**
  86884. * Gets a boolean indicating if all created effects are ready
  86885. * @returns true if all effects are ready
  86886. */
  86887. areAllEffectsReady(): boolean;
  86888. private _rebuildBuffers;
  86889. private _initGLContext;
  86890. /**
  86891. * Gets version of the current webGL context
  86892. */
  86893. readonly webGLVersion: number;
  86894. /**
  86895. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  86896. */
  86897. readonly isStencilEnable: boolean;
  86898. private _prepareWorkingCanvas;
  86899. /**
  86900. * Reset the texture cache to empty state
  86901. */
  86902. resetTextureCache(): void;
  86903. /**
  86904. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  86905. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86906. * @returns true if engine is in deterministic lock step mode
  86907. */
  86908. isDeterministicLockStep(): boolean;
  86909. /**
  86910. * Gets the max steps when engine is running in deterministic lock step
  86911. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86912. * @returns the max steps
  86913. */
  86914. getLockstepMaxSteps(): number;
  86915. /**
  86916. * Gets an object containing information about the current webGL context
  86917. * @returns an object containing the vender, the renderer and the version of the current webGL context
  86918. */
  86919. getGlInfo(): {
  86920. vendor: string;
  86921. renderer: string;
  86922. version: string;
  86923. };
  86924. /**
  86925. * Gets current aspect ratio
  86926. * @param camera defines the camera to use to get the aspect ratio
  86927. * @param useScreen defines if screen size must be used (or the current render target if any)
  86928. * @returns a number defining the aspect ratio
  86929. */
  86930. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  86931. /**
  86932. * Gets current screen aspect ratio
  86933. * @returns a number defining the aspect ratio
  86934. */
  86935. getScreenAspectRatio(): number;
  86936. /**
  86937. * Gets the current render width
  86938. * @param useScreen defines if screen size must be used (or the current render target if any)
  86939. * @returns a number defining the current render width
  86940. */
  86941. getRenderWidth(useScreen?: boolean): number;
  86942. /**
  86943. * Gets the current render height
  86944. * @param useScreen defines if screen size must be used (or the current render target if any)
  86945. * @returns a number defining the current render height
  86946. */
  86947. getRenderHeight(useScreen?: boolean): number;
  86948. /**
  86949. * Gets the HTML canvas attached with the current webGL context
  86950. * @returns a HTML canvas
  86951. */
  86952. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  86953. /**
  86954. * Gets the client rect of the HTML canvas attached with the current webGL context
  86955. * @returns a client rectanglee
  86956. */
  86957. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  86958. /**
  86959. * Defines the hardware scaling level.
  86960. * By default the hardware scaling level is computed from the window device ratio.
  86961. * 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.
  86962. * @param level defines the level to use
  86963. */
  86964. setHardwareScalingLevel(level: number): void;
  86965. /**
  86966. * Gets the current hardware scaling level.
  86967. * By default the hardware scaling level is computed from the window device ratio.
  86968. * 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.
  86969. * @returns a number indicating the current hardware scaling level
  86970. */
  86971. getHardwareScalingLevel(): number;
  86972. /**
  86973. * Gets the list of loaded textures
  86974. * @returns an array containing all loaded textures
  86975. */
  86976. getLoadedTexturesCache(): InternalTexture[];
  86977. /**
  86978. * Gets the object containing all engine capabilities
  86979. * @returns the EngineCapabilities object
  86980. */
  86981. getCaps(): EngineCapabilities;
  86982. /**
  86983. * Gets the current depth function
  86984. * @returns a number defining the depth function
  86985. */
  86986. getDepthFunction(): Nullable<number>;
  86987. /**
  86988. * Sets the current depth function
  86989. * @param depthFunc defines the function to use
  86990. */
  86991. setDepthFunction(depthFunc: number): void;
  86992. /**
  86993. * Sets the current depth function to GREATER
  86994. */
  86995. setDepthFunctionToGreater(): void;
  86996. /**
  86997. * Sets the current depth function to GEQUAL
  86998. */
  86999. setDepthFunctionToGreaterOrEqual(): void;
  87000. /**
  87001. * Sets the current depth function to LESS
  87002. */
  87003. setDepthFunctionToLess(): void;
  87004. private _cachedStencilBuffer;
  87005. private _cachedStencilFunction;
  87006. private _cachedStencilMask;
  87007. private _cachedStencilOperationPass;
  87008. private _cachedStencilOperationFail;
  87009. private _cachedStencilOperationDepthFail;
  87010. private _cachedStencilReference;
  87011. /**
  87012. * Caches the the state of the stencil buffer
  87013. */
  87014. cacheStencilState(): void;
  87015. /**
  87016. * Restores the state of the stencil buffer
  87017. */
  87018. restoreStencilState(): void;
  87019. /**
  87020. * Sets the current depth function to LEQUAL
  87021. */
  87022. setDepthFunctionToLessOrEqual(): void;
  87023. /**
  87024. * Gets a boolean indicating if stencil buffer is enabled
  87025. * @returns the current stencil buffer state
  87026. */
  87027. getStencilBuffer(): boolean;
  87028. /**
  87029. * Enable or disable the stencil buffer
  87030. * @param enable defines if the stencil buffer must be enabled or disabled
  87031. */
  87032. setStencilBuffer(enable: boolean): void;
  87033. /**
  87034. * Gets the current stencil mask
  87035. * @returns a number defining the new stencil mask to use
  87036. */
  87037. getStencilMask(): number;
  87038. /**
  87039. * Sets the current stencil mask
  87040. * @param mask defines the new stencil mask to use
  87041. */
  87042. setStencilMask(mask: number): void;
  87043. /**
  87044. * Gets the current stencil function
  87045. * @returns a number defining the stencil function to use
  87046. */
  87047. getStencilFunction(): number;
  87048. /**
  87049. * Gets the current stencil reference value
  87050. * @returns a number defining the stencil reference value to use
  87051. */
  87052. getStencilFunctionReference(): number;
  87053. /**
  87054. * Gets the current stencil mask
  87055. * @returns a number defining the stencil mask to use
  87056. */
  87057. getStencilFunctionMask(): number;
  87058. /**
  87059. * Sets the current stencil function
  87060. * @param stencilFunc defines the new stencil function to use
  87061. */
  87062. setStencilFunction(stencilFunc: number): void;
  87063. /**
  87064. * Sets the current stencil reference
  87065. * @param reference defines the new stencil reference to use
  87066. */
  87067. setStencilFunctionReference(reference: number): void;
  87068. /**
  87069. * Sets the current stencil mask
  87070. * @param mask defines the new stencil mask to use
  87071. */
  87072. setStencilFunctionMask(mask: number): void;
  87073. /**
  87074. * Gets the current stencil operation when stencil fails
  87075. * @returns a number defining stencil operation to use when stencil fails
  87076. */
  87077. getStencilOperationFail(): number;
  87078. /**
  87079. * Gets the current stencil operation when depth fails
  87080. * @returns a number defining stencil operation to use when depth fails
  87081. */
  87082. getStencilOperationDepthFail(): number;
  87083. /**
  87084. * Gets the current stencil operation when stencil passes
  87085. * @returns a number defining stencil operation to use when stencil passes
  87086. */
  87087. getStencilOperationPass(): number;
  87088. /**
  87089. * Sets the stencil operation to use when stencil fails
  87090. * @param operation defines the stencil operation to use when stencil fails
  87091. */
  87092. setStencilOperationFail(operation: number): void;
  87093. /**
  87094. * Sets the stencil operation to use when depth fails
  87095. * @param operation defines the stencil operation to use when depth fails
  87096. */
  87097. setStencilOperationDepthFail(operation: number): void;
  87098. /**
  87099. * Sets the stencil operation to use when stencil passes
  87100. * @param operation defines the stencil operation to use when stencil passes
  87101. */
  87102. setStencilOperationPass(operation: number): void;
  87103. /**
  87104. * Sets a boolean indicating if the dithering state is enabled or disabled
  87105. * @param value defines the dithering state
  87106. */
  87107. setDitheringState(value: boolean): void;
  87108. /**
  87109. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87110. * @param value defines the rasterizer state
  87111. */
  87112. setRasterizerState(value: boolean): void;
  87113. /**
  87114. * stop executing a render loop function and remove it from the execution array
  87115. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87116. */
  87117. stopRenderLoop(renderFunction?: () => void): void;
  87118. /** @hidden */
  87119. _renderLoop(): void;
  87120. /**
  87121. * Register and execute a render loop. The engine can have more than one render function
  87122. * @param renderFunction defines the function to continuously execute
  87123. */
  87124. runRenderLoop(renderFunction: () => void): void;
  87125. /**
  87126. * Toggle full screen mode
  87127. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87128. */
  87129. switchFullscreen(requestPointerLock: boolean): void;
  87130. /**
  87131. * Enters full screen mode
  87132. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87133. */
  87134. enterFullscreen(requestPointerLock: boolean): void;
  87135. /**
  87136. * Exits full screen mode
  87137. */
  87138. exitFullscreen(): void;
  87139. /**
  87140. * Clear the current render buffer or the current render target (if any is set up)
  87141. * @param color defines the color to use
  87142. * @param backBuffer defines if the back buffer must be cleared
  87143. * @param depth defines if the depth buffer must be cleared
  87144. * @param stencil defines if the stencil buffer must be cleared
  87145. */
  87146. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87147. /**
  87148. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87149. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87150. * @param y defines the y-coordinate of the corner of the clear rectangle
  87151. * @param width defines the width of the clear rectangle
  87152. * @param height defines the height of the clear rectangle
  87153. * @param clearColor defines the clear color
  87154. */
  87155. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87156. /**
  87157. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87158. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87159. * @param y defines the y-coordinate of the corner of the clear rectangle
  87160. * @param width defines the width of the clear rectangle
  87161. * @param height defines the height of the clear rectangle
  87162. */
  87163. enableScissor(x: number, y: number, width: number, height: number): void;
  87164. /**
  87165. * Disable previously set scissor test rectangle
  87166. */
  87167. disableScissor(): void;
  87168. private _viewportCached;
  87169. /** @hidden */
  87170. _viewport(x: number, y: number, width: number, height: number): void;
  87171. /**
  87172. * Set the WebGL's viewport
  87173. * @param viewport defines the viewport element to be used
  87174. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87175. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87176. */
  87177. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87178. /**
  87179. * Directly set the WebGL Viewport
  87180. * @param x defines the x coordinate of the viewport (in screen space)
  87181. * @param y defines the y coordinate of the viewport (in screen space)
  87182. * @param width defines the width of the viewport (in screen space)
  87183. * @param height defines the height of the viewport (in screen space)
  87184. * @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
  87185. */
  87186. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87187. /**
  87188. * Begin a new frame
  87189. */
  87190. beginFrame(): void;
  87191. /**
  87192. * Enf the current frame
  87193. */
  87194. endFrame(): void;
  87195. /**
  87196. * Resize the view according to the canvas' size
  87197. */
  87198. resize(): void;
  87199. /**
  87200. * Force a specific size of the canvas
  87201. * @param width defines the new canvas' width
  87202. * @param height defines the new canvas' height
  87203. */
  87204. setSize(width: number, height: number): void;
  87205. /**
  87206. * Gets a boolean indicating if a webVR device was detected
  87207. * @returns true if a webVR device was detected
  87208. */
  87209. isVRDevicePresent(): boolean;
  87210. /**
  87211. * Gets the current webVR device
  87212. * @returns the current webVR device (or null)
  87213. */
  87214. getVRDevice(): any;
  87215. /**
  87216. * Initializes a webVR display and starts listening to display change events
  87217. * The onVRDisplayChangedObservable will be notified upon these changes
  87218. * @returns The onVRDisplayChangedObservable
  87219. */
  87220. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87221. /**
  87222. * Initializes a webVR display and starts listening to display change events
  87223. * The onVRDisplayChangedObservable will be notified upon these changes
  87224. * @returns A promise containing a VRDisplay and if vr is supported
  87225. */
  87226. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87227. /**
  87228. * Call this function to switch to webVR mode
  87229. * Will do nothing if webVR is not supported or if there is no webVR device
  87230. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87231. */
  87232. enableVR(): void;
  87233. /**
  87234. * Call this function to leave webVR mode
  87235. * Will do nothing if webVR is not supported or if there is no webVR device
  87236. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87237. */
  87238. disableVR(): void;
  87239. private _onVRFullScreenTriggered;
  87240. private _getVRDisplaysAsync;
  87241. /**
  87242. * Binds the frame buffer to the specified texture.
  87243. * @param texture The texture to render to or null for the default canvas
  87244. * @param faceIndex The face of the texture to render to in case of cube texture
  87245. * @param requiredWidth The width of the target to render to
  87246. * @param requiredHeight The height of the target to render to
  87247. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87248. * @param depthStencilTexture The depth stencil texture to use to render
  87249. * @param lodLevel defines le lod level to bind to the frame buffer
  87250. */
  87251. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87252. private bindUnboundFramebuffer;
  87253. /**
  87254. * Unbind the current render target texture from the webGL context
  87255. * @param texture defines the render target texture to unbind
  87256. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87257. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87258. */
  87259. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87260. /**
  87261. * Unbind a list of render target textures from the webGL context
  87262. * This is used only when drawBuffer extension or webGL2 are active
  87263. * @param textures defines the render target textures to unbind
  87264. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87265. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87266. */
  87267. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87268. /**
  87269. * Force the mipmap generation for the given render target texture
  87270. * @param texture defines the render target texture to use
  87271. */
  87272. generateMipMapsForCubemap(texture: InternalTexture): void;
  87273. /**
  87274. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  87275. */
  87276. flushFramebuffer(): void;
  87277. /**
  87278. * Unbind the current render target and bind the default framebuffer
  87279. */
  87280. restoreDefaultFramebuffer(): void;
  87281. /**
  87282. * Create an uniform buffer
  87283. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87284. * @param elements defines the content of the uniform buffer
  87285. * @returns the webGL uniform buffer
  87286. */
  87287. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  87288. /**
  87289. * Create a dynamic uniform buffer
  87290. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87291. * @param elements defines the content of the uniform buffer
  87292. * @returns the webGL uniform buffer
  87293. */
  87294. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  87295. /**
  87296. * Update an existing uniform buffer
  87297. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87298. * @param uniformBuffer defines the target uniform buffer
  87299. * @param elements defines the content to update
  87300. * @param offset defines the offset in the uniform buffer where update should start
  87301. * @param count defines the size of the data to update
  87302. */
  87303. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87304. private _resetVertexBufferBinding;
  87305. /**
  87306. * Creates a vertex buffer
  87307. * @param data the data for the vertex buffer
  87308. * @returns the new WebGL static buffer
  87309. */
  87310. createVertexBuffer(data: DataArray): WebGLBuffer;
  87311. /**
  87312. * Creates a dynamic vertex buffer
  87313. * @param data the data for the dynamic vertex buffer
  87314. * @returns the new WebGL dynamic buffer
  87315. */
  87316. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  87317. /**
  87318. * Update a dynamic index buffer
  87319. * @param indexBuffer defines the target index buffer
  87320. * @param indices defines the data to update
  87321. * @param offset defines the offset in the target index buffer where update should start
  87322. */
  87323. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  87324. /**
  87325. * Updates a dynamic vertex buffer.
  87326. * @param vertexBuffer the vertex buffer to update
  87327. * @param data the data used to update the vertex buffer
  87328. * @param byteOffset the byte offset of the data
  87329. * @param byteLength the byte length of the data
  87330. */
  87331. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  87332. private _resetIndexBufferBinding;
  87333. /**
  87334. * Creates a new index buffer
  87335. * @param indices defines the content of the index buffer
  87336. * @param updatable defines if the index buffer must be updatable
  87337. * @returns a new webGL buffer
  87338. */
  87339. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  87340. /**
  87341. * Bind a webGL buffer to the webGL context
  87342. * @param buffer defines the buffer to bind
  87343. */
  87344. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  87345. /**
  87346. * Bind an uniform buffer to the current webGL context
  87347. * @param buffer defines the buffer to bind
  87348. */
  87349. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  87350. /**
  87351. * Bind a buffer to the current webGL context at a given location
  87352. * @param buffer defines the buffer to bind
  87353. * @param location defines the index where to bind the buffer
  87354. */
  87355. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  87356. /**
  87357. * Bind a specific block at a given index in a specific shader program
  87358. * @param shaderProgram defines the shader program
  87359. * @param blockName defines the block name
  87360. * @param index defines the index where to bind the block
  87361. */
  87362. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  87363. private bindIndexBuffer;
  87364. private bindBuffer;
  87365. /**
  87366. * update the bound buffer with the given data
  87367. * @param data defines the data to update
  87368. */
  87369. updateArrayBuffer(data: Float32Array): void;
  87370. private _vertexAttribPointer;
  87371. private _bindIndexBufferWithCache;
  87372. private _bindVertexBuffersAttributes;
  87373. /**
  87374. * Records a vertex array object
  87375. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87376. * @param vertexBuffers defines the list of vertex buffers to store
  87377. * @param indexBuffer defines the index buffer to store
  87378. * @param effect defines the effect to store
  87379. * @returns the new vertex array object
  87380. */
  87381. recordVertexArrayObject(vertexBuffers: {
  87382. [key: string]: VertexBuffer;
  87383. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  87384. /**
  87385. * Bind a specific vertex array object
  87386. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87387. * @param vertexArrayObject defines the vertex array object to bind
  87388. * @param indexBuffer defines the index buffer to bind
  87389. */
  87390. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  87391. /**
  87392. * Bind webGl buffers directly to the webGL context
  87393. * @param vertexBuffer defines the vertex buffer to bind
  87394. * @param indexBuffer defines the index buffer to bind
  87395. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87396. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87397. * @param effect defines the effect associated with the vertex buffer
  87398. */
  87399. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87400. private _unbindVertexArrayObject;
  87401. /**
  87402. * Bind a list of vertex buffers to the webGL context
  87403. * @param vertexBuffers defines the list of vertex buffers to bind
  87404. * @param indexBuffer defines the index buffer to bind
  87405. * @param effect defines the effect associated with the vertex buffers
  87406. */
  87407. bindBuffers(vertexBuffers: {
  87408. [key: string]: Nullable<VertexBuffer>;
  87409. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  87410. /**
  87411. * Unbind all instance attributes
  87412. */
  87413. unbindInstanceAttributes(): void;
  87414. /**
  87415. * Release and free the memory of a vertex array object
  87416. * @param vao defines the vertex array object to delete
  87417. */
  87418. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87419. /** @hidden */
  87420. _releaseBuffer(buffer: WebGLBuffer): boolean;
  87421. /**
  87422. * Creates a webGL buffer to use with instanciation
  87423. * @param capacity defines the size of the buffer
  87424. * @returns the webGL buffer
  87425. */
  87426. createInstancesBuffer(capacity: number): WebGLBuffer;
  87427. /**
  87428. * Delete a webGL buffer used with instanciation
  87429. * @param buffer defines the webGL buffer to delete
  87430. */
  87431. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87432. /**
  87433. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87434. * @param instancesBuffer defines the webGL buffer to update and bind
  87435. * @param data defines the data to store in the buffer
  87436. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87437. */
  87438. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87439. /**
  87440. * Apply all cached states (depth, culling, stencil and alpha)
  87441. */
  87442. applyStates(): void;
  87443. /**
  87444. * Send a draw order
  87445. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87446. * @param indexStart defines the starting index
  87447. * @param indexCount defines the number of index to draw
  87448. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87449. */
  87450. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87451. /**
  87452. * Draw a list of points
  87453. * @param verticesStart defines the index of first vertex to draw
  87454. * @param verticesCount defines the count of vertices to draw
  87455. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87456. */
  87457. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87458. /**
  87459. * Draw a list of unindexed primitives
  87460. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87461. * @param verticesStart defines the index of first vertex to draw
  87462. * @param verticesCount defines the count of vertices to draw
  87463. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87464. */
  87465. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87466. /**
  87467. * Draw a list of indexed primitives
  87468. * @param fillMode defines the primitive to use
  87469. * @param indexStart defines the starting index
  87470. * @param indexCount defines the number of index to draw
  87471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87472. */
  87473. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87474. /**
  87475. * Draw a list of unindexed primitives
  87476. * @param fillMode defines the primitive to use
  87477. * @param verticesStart defines the index of first vertex to draw
  87478. * @param verticesCount defines the count of vertices to draw
  87479. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87480. */
  87481. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87482. private _drawMode;
  87483. /** @hidden */
  87484. _releaseEffect(effect: Effect): void;
  87485. /** @hidden */
  87486. _deleteProgram(program: WebGLProgram): void;
  87487. /**
  87488. * Create a new effect (used to store vertex/fragment shaders)
  87489. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87490. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87491. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87492. * @param samplers defines an array of string used to represent textures
  87493. * @param defines defines the string containing the defines to use to compile the shaders
  87494. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87495. * @param onCompiled defines a function to call when the effect creation is successful
  87496. * @param onError defines a function to call when the effect creation has failed
  87497. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87498. * @returns the new Effect
  87499. */
  87500. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  87501. private _compileShader;
  87502. private _compileRawShader;
  87503. /**
  87504. * Directly creates a webGL program
  87505. * @param vertexCode defines the vertex shader code to use
  87506. * @param fragmentCode defines the fragment shader code to use
  87507. * @param context defines the webGL context to use (if not set, the current one will be used)
  87508. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87509. * @returns the new webGL program
  87510. */
  87511. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87512. /**
  87513. * Creates a webGL program
  87514. * @param vertexCode defines the vertex shader code to use
  87515. * @param fragmentCode defines the fragment shader code to use
  87516. * @param defines defines the string containing the defines to use to compile the shaders
  87517. * @param context defines the webGL context to use (if not set, the current one will be used)
  87518. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87519. * @returns the new webGL program
  87520. */
  87521. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87522. private _createShaderProgram;
  87523. private _finalizeProgram;
  87524. /** @hidden */
  87525. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  87526. /** @hidden */
  87527. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  87528. /**
  87529. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  87530. * @param shaderProgram defines the webGL program to use
  87531. * @param uniformsNames defines the list of uniform names
  87532. * @returns an array of webGL uniform locations
  87533. */
  87534. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  87535. /**
  87536. * Gets the lsit of active attributes for a given webGL program
  87537. * @param shaderProgram defines the webGL program to use
  87538. * @param attributesNames defines the list of attribute names to get
  87539. * @returns an array of indices indicating the offset of each attribute
  87540. */
  87541. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  87542. /**
  87543. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  87544. * @param effect defines the effect to activate
  87545. */
  87546. enableEffect(effect: Nullable<Effect>): void;
  87547. /**
  87548. * Set the value of an uniform to an array of int32
  87549. * @param uniform defines the webGL uniform location where to store the value
  87550. * @param array defines the array of int32 to store
  87551. */
  87552. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87553. /**
  87554. * Set the value of an uniform to an array of int32 (stored as vec2)
  87555. * @param uniform defines the webGL uniform location where to store the value
  87556. * @param array defines the array of int32 to store
  87557. */
  87558. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87559. /**
  87560. * Set the value of an uniform to an array of int32 (stored as vec3)
  87561. * @param uniform defines the webGL uniform location where to store the value
  87562. * @param array defines the array of int32 to store
  87563. */
  87564. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87565. /**
  87566. * Set the value of an uniform to an array of int32 (stored as vec4)
  87567. * @param uniform defines the webGL uniform location where to store the value
  87568. * @param array defines the array of int32 to store
  87569. */
  87570. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87571. /**
  87572. * Set the value of an uniform to an array of float32
  87573. * @param uniform defines the webGL uniform location where to store the value
  87574. * @param array defines the array of float32 to store
  87575. */
  87576. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87577. /**
  87578. * Set the value of an uniform to an array of float32 (stored as vec2)
  87579. * @param uniform defines the webGL uniform location where to store the value
  87580. * @param array defines the array of float32 to store
  87581. */
  87582. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87583. /**
  87584. * Set the value of an uniform to an array of float32 (stored as vec3)
  87585. * @param uniform defines the webGL uniform location where to store the value
  87586. * @param array defines the array of float32 to store
  87587. */
  87588. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87589. /**
  87590. * Set the value of an uniform to an array of float32 (stored as vec4)
  87591. * @param uniform defines the webGL uniform location where to store the value
  87592. * @param array defines the array of float32 to store
  87593. */
  87594. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87595. /**
  87596. * Set the value of an uniform to an array of number
  87597. * @param uniform defines the webGL uniform location where to store the value
  87598. * @param array defines the array of number to store
  87599. */
  87600. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87601. /**
  87602. * Set the value of an uniform to an array of number (stored as vec2)
  87603. * @param uniform defines the webGL uniform location where to store the value
  87604. * @param array defines the array of number to store
  87605. */
  87606. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87607. /**
  87608. * Set the value of an uniform to an array of number (stored as vec3)
  87609. * @param uniform defines the webGL uniform location where to store the value
  87610. * @param array defines the array of number to store
  87611. */
  87612. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87613. /**
  87614. * Set the value of an uniform to an array of number (stored as vec4)
  87615. * @param uniform defines the webGL uniform location where to store the value
  87616. * @param array defines the array of number to store
  87617. */
  87618. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87619. /**
  87620. * Set the value of an uniform to an array of float32 (stored as matrices)
  87621. * @param uniform defines the webGL uniform location where to store the value
  87622. * @param matrices defines the array of float32 to store
  87623. */
  87624. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  87625. /**
  87626. * Set the value of an uniform to a matrix
  87627. * @param uniform defines the webGL uniform location where to store the value
  87628. * @param matrix defines the matrix to store
  87629. */
  87630. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  87631. /**
  87632. * Set the value of an uniform to a matrix (3x3)
  87633. * @param uniform defines the webGL uniform location where to store the value
  87634. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  87635. */
  87636. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87637. /**
  87638. * Set the value of an uniform to a matrix (2x2)
  87639. * @param uniform defines the webGL uniform location where to store the value
  87640. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  87641. */
  87642. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87643. /**
  87644. * Set the value of an uniform to a number (int)
  87645. * @param uniform defines the webGL uniform location where to store the value
  87646. * @param value defines the int number to store
  87647. */
  87648. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87649. /**
  87650. * Set the value of an uniform to a number (float)
  87651. * @param uniform defines the webGL uniform location where to store the value
  87652. * @param value defines the float number to store
  87653. */
  87654. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87655. /**
  87656. * Set the value of an uniform to a vec2
  87657. * @param uniform defines the webGL uniform location where to store the value
  87658. * @param x defines the 1st component of the value
  87659. * @param y defines the 2nd component of the value
  87660. */
  87661. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  87662. /**
  87663. * Set the value of an uniform to a vec3
  87664. * @param uniform defines the webGL uniform location where to store the value
  87665. * @param x defines the 1st component of the value
  87666. * @param y defines the 2nd component of the value
  87667. * @param z defines the 3rd component of the value
  87668. */
  87669. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  87670. /**
  87671. * Set the value of an uniform to a boolean
  87672. * @param uniform defines the webGL uniform location where to store the value
  87673. * @param bool defines the boolean to store
  87674. */
  87675. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  87676. /**
  87677. * Set the value of an uniform to a vec4
  87678. * @param uniform defines the webGL uniform location where to store the value
  87679. * @param x defines the 1st component of the value
  87680. * @param y defines the 2nd component of the value
  87681. * @param z defines the 3rd component of the value
  87682. * @param w defines the 4th component of the value
  87683. */
  87684. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  87685. /**
  87686. * Set the value of an uniform to a Color3
  87687. * @param uniform defines the webGL uniform location where to store the value
  87688. * @param color3 defines the color to store
  87689. */
  87690. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  87691. /**
  87692. * Set the value of an uniform to a Color3 and an alpha value
  87693. * @param uniform defines the webGL uniform location where to store the value
  87694. * @param color3 defines the color to store
  87695. * @param alpha defines the alpha component to store
  87696. */
  87697. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  87698. /**
  87699. * Sets a Color4 on a uniform variable
  87700. * @param uniform defines the uniform location
  87701. * @param color4 defines the value to be set
  87702. */
  87703. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  87704. /**
  87705. * Set various states to the webGL context
  87706. * @param culling defines backface culling state
  87707. * @param zOffset defines the value to apply to zOffset (0 by default)
  87708. * @param force defines if states must be applied even if cache is up to date
  87709. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  87710. */
  87711. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  87712. /**
  87713. * Set the z offset to apply to current rendering
  87714. * @param value defines the offset to apply
  87715. */
  87716. setZOffset(value: number): void;
  87717. /**
  87718. * Gets the current value of the zOffset
  87719. * @returns the current zOffset state
  87720. */
  87721. getZOffset(): number;
  87722. /**
  87723. * Enable or disable depth buffering
  87724. * @param enable defines the state to set
  87725. */
  87726. setDepthBuffer(enable: boolean): void;
  87727. /**
  87728. * Gets a boolean indicating if depth writing is enabled
  87729. * @returns the current depth writing state
  87730. */
  87731. getDepthWrite(): boolean;
  87732. /**
  87733. * Enable or disable depth writing
  87734. * @param enable defines the state to set
  87735. */
  87736. setDepthWrite(enable: boolean): void;
  87737. /**
  87738. * Enable or disable color writing
  87739. * @param enable defines the state to set
  87740. */
  87741. setColorWrite(enable: boolean): void;
  87742. /**
  87743. * Gets a boolean indicating if color writing is enabled
  87744. * @returns the current color writing state
  87745. */
  87746. getColorWrite(): boolean;
  87747. /**
  87748. * Sets alpha constants used by some alpha blending modes
  87749. * @param r defines the red component
  87750. * @param g defines the green component
  87751. * @param b defines the blue component
  87752. * @param a defines the alpha component
  87753. */
  87754. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  87755. /**
  87756. * Sets the current alpha mode
  87757. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  87758. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  87759. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87760. */
  87761. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  87762. /**
  87763. * Gets the current alpha mode
  87764. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87765. * @returns the current alpha mode
  87766. */
  87767. getAlphaMode(): number;
  87768. /**
  87769. * Clears the list of texture accessible through engine.
  87770. * This can help preventing texture load conflict due to name collision.
  87771. */
  87772. clearInternalTexturesCache(): void;
  87773. /**
  87774. * Force the entire cache to be cleared
  87775. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  87776. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  87777. */
  87778. wipeCaches(bruteForce?: boolean): void;
  87779. /**
  87780. * Set the compressed texture format to use, based on the formats you have, and the formats
  87781. * supported by the hardware / browser.
  87782. *
  87783. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  87784. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  87785. * to API arguments needed to compressed textures. This puts the burden on the container
  87786. * generator to house the arcane code for determining these for current & future formats.
  87787. *
  87788. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  87789. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  87790. *
  87791. * Note: The result of this call is not taken into account when a texture is base64.
  87792. *
  87793. * @param formatsAvailable defines the list of those format families you have created
  87794. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  87795. *
  87796. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  87797. * @returns The extension selected.
  87798. */
  87799. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  87800. private _getSamplingParameters;
  87801. private _partialLoadImg;
  87802. private _cascadeLoadImgs;
  87803. /** @hidden */
  87804. _createTexture(): WebGLTexture;
  87805. /**
  87806. * Usually called from Texture.ts.
  87807. * Passed information to create a WebGLTexture
  87808. * @param urlArg defines a value which contains one of the following:
  87809. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  87810. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  87811. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  87812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  87813. * @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)
  87814. * @param scene needed for loading to the correct scene
  87815. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  87816. * @param onLoad optional callback to be called upon successful completion
  87817. * @param onError optional callback to be called upon failure
  87818. * @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
  87819. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  87820. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  87821. * @param forcedExtension defines the extension to use to pick the right loader
  87822. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  87823. * @returns a InternalTexture for assignment back into BABYLON.Texture
  87824. */
  87825. 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;
  87826. private _rescaleTexture;
  87827. /**
  87828. * Update a raw texture
  87829. * @param texture defines the texture to update
  87830. * @param data defines the data to store in the texture
  87831. * @param format defines the format of the data
  87832. * @param invertY defines if data must be stored with Y axis inverted
  87833. * @param compression defines the compression used (null by default)
  87834. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87835. */
  87836. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  87837. /**
  87838. * Creates a raw texture
  87839. * @param data defines the data to store in the texture
  87840. * @param width defines the width of the texture
  87841. * @param height defines the height of the texture
  87842. * @param format defines the format of the data
  87843. * @param generateMipMaps defines if the engine should generate the mip levels
  87844. * @param invertY defines if data must be stored with Y axis inverted
  87845. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87846. * @param compression defines the compression used (null by default)
  87847. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87848. * @returns the raw texture inside an InternalTexture
  87849. */
  87850. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  87851. private _unpackFlipYCached;
  87852. /**
  87853. * In case you are sharing the context with other applications, it might
  87854. * be interested to not cache the unpack flip y state to ensure a consistent
  87855. * value would be set.
  87856. */
  87857. enableUnpackFlipYCached: boolean;
  87858. /** @hidden */
  87859. _unpackFlipY(value: boolean): void;
  87860. /** @hidden */
  87861. _getUnpackAlignement(): number;
  87862. /**
  87863. * Creates a dynamic texture
  87864. * @param width defines the width of the texture
  87865. * @param height defines the height of the texture
  87866. * @param generateMipMaps defines if the engine should generate the mip levels
  87867. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87868. * @returns the dynamic texture inside an InternalTexture
  87869. */
  87870. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87871. /**
  87872. * Update the sampling mode of a given texture
  87873. * @param samplingMode defines the required sampling mode
  87874. * @param texture defines the texture to update
  87875. */
  87876. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  87877. /**
  87878. * Update the content of a dynamic texture
  87879. * @param texture defines the texture to update
  87880. * @param canvas defines the canvas containing the source
  87881. * @param invertY defines if data must be stored with Y axis inverted
  87882. * @param premulAlpha defines if alpha is stored as premultiplied
  87883. * @param format defines the format of the data
  87884. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87885. */
  87886. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87887. /**
  87888. * Update a video texture
  87889. * @param texture defines the texture to update
  87890. * @param video defines the video element to use
  87891. * @param invertY defines if data must be stored with Y axis inverted
  87892. */
  87893. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  87894. /**
  87895. * Updates a depth texture Comparison Mode and Function.
  87896. * If the comparison Function is equal to 0, the mode will be set to none.
  87897. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  87898. * @param texture The texture to set the comparison function for
  87899. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  87900. */
  87901. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  87902. private _setupDepthStencilTexture;
  87903. /**
  87904. * Creates a depth stencil texture.
  87905. * This is only available in WebGL 2 or with the depth texture extension available.
  87906. * @param size The size of face edge in the texture.
  87907. * @param options The options defining the texture.
  87908. * @returns The texture
  87909. */
  87910. createDepthStencilTexture(size: number | {
  87911. width: number;
  87912. height: number;
  87913. }, options: DepthTextureCreationOptions): InternalTexture;
  87914. /**
  87915. * Creates a depth stencil texture.
  87916. * This is only available in WebGL 2 or with the depth texture extension available.
  87917. * @param size The size of face edge in the texture.
  87918. * @param options The options defining the texture.
  87919. * @returns The texture
  87920. */
  87921. private _createDepthStencilTexture;
  87922. /**
  87923. * Creates a depth stencil cube texture.
  87924. * This is only available in WebGL 2.
  87925. * @param size The size of face edge in the cube texture.
  87926. * @param options The options defining the cube texture.
  87927. * @returns The cube texture
  87928. */
  87929. private _createDepthStencilCubeTexture;
  87930. /**
  87931. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  87932. * @param renderTarget The render target to set the frame buffer for
  87933. */
  87934. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  87935. /**
  87936. * Creates a new render target texture
  87937. * @param size defines the size of the texture
  87938. * @param options defines the options used to create the texture
  87939. * @returns a new render target texture stored in an InternalTexture
  87940. */
  87941. createRenderTargetTexture(size: number | {
  87942. width: number;
  87943. height: number;
  87944. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87945. /**
  87946. * Create a multi render target texture
  87947. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  87948. * @param size defines the size of the texture
  87949. * @param options defines the creation options
  87950. * @returns the cube texture as an InternalTexture
  87951. */
  87952. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  87953. private _setupFramebufferDepthAttachments;
  87954. /**
  87955. * Updates the sample count of a render target texture
  87956. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87957. * @param texture defines the texture to update
  87958. * @param samples defines the sample count to set
  87959. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87960. */
  87961. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  87962. /**
  87963. * Update the sample count for a given multiple render target texture
  87964. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87965. * @param textures defines the textures to update
  87966. * @param samples defines the sample count to set
  87967. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87968. */
  87969. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  87970. /** @hidden */
  87971. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87972. /** @hidden */
  87973. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87974. /** @hidden */
  87975. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87976. /** @hidden */
  87977. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  87978. /**
  87979. * Creates a new render target cube texture
  87980. * @param size defines the size of the texture
  87981. * @param options defines the options used to create the texture
  87982. * @returns a new render target cube texture stored in an InternalTexture
  87983. */
  87984. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87985. /**
  87986. * Creates a cube texture
  87987. * @param rootUrl defines the url where the files to load is located
  87988. * @param scene defines the current scene
  87989. * @param files defines the list of files to load (1 per face)
  87990. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87991. * @param onLoad defines an optional callback raised when the texture is loaded
  87992. * @param onError defines an optional callback raised if there is an issue to load the texture
  87993. * @param format defines the format of the data
  87994. * @param forcedExtension defines the extension to use to pick the right loader
  87995. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87996. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87997. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87998. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87999. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  88000. * @returns the cube texture as an InternalTexture
  88001. */
  88002. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  88003. /**
  88004. * @hidden
  88005. */
  88006. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88007. /**
  88008. * Update a raw cube texture
  88009. * @param texture defines the texture to udpdate
  88010. * @param data defines the data to store
  88011. * @param format defines the data format
  88012. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88013. * @param invertY defines if data must be stored with Y axis inverted
  88014. * @param compression defines the compression used (null by default)
  88015. * @param level defines which level of the texture to update
  88016. */
  88017. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  88018. /**
  88019. * Creates a new raw cube texture
  88020. * @param data defines the array of data to use to create each face
  88021. * @param size defines the size of the textures
  88022. * @param format defines the format of the data
  88023. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88024. * @param generateMipMaps defines if the engine should generate the mip levels
  88025. * @param invertY defines if data must be stored with Y axis inverted
  88026. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88027. * @param compression defines the compression used (null by default)
  88028. * @returns the cube texture as an InternalTexture
  88029. */
  88030. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  88031. /**
  88032. * Creates a new raw cube texture from a specified url
  88033. * @param url defines the url where the data is located
  88034. * @param scene defines the current scene
  88035. * @param size defines the size of the textures
  88036. * @param format defines the format of the data
  88037. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88038. * @param noMipmap defines if the engine should avoid generating the mip levels
  88039. * @param callback defines a callback used to extract texture data from loaded data
  88040. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88041. * @param onLoad defines a callback called when texture is loaded
  88042. * @param onError defines a callback called if there is an error
  88043. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88044. * @param invertY defines if data must be stored with Y axis inverted
  88045. * @returns the cube texture as an InternalTexture
  88046. */
  88047. 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;
  88048. /**
  88049. * Update a raw 3D texture
  88050. * @param texture defines the texture to update
  88051. * @param data defines the data to store
  88052. * @param format defines the data format
  88053. * @param invertY defines if data must be stored with Y axis inverted
  88054. * @param compression defines the used compression (can be null)
  88055. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88056. */
  88057. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  88058. /**
  88059. * Creates a new raw 3D texture
  88060. * @param data defines the data used to create the texture
  88061. * @param width defines the width of the texture
  88062. * @param height defines the height of the texture
  88063. * @param depth defines the depth of the texture
  88064. * @param format defines the format of the texture
  88065. * @param generateMipMaps defines if the engine must generate mip levels
  88066. * @param invertY defines if data must be stored with Y axis inverted
  88067. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88068. * @param compression defines the compressed used (can be null)
  88069. * @param textureType defines the compressed used (can be null)
  88070. * @returns a new raw 3D texture (stored in an InternalTexture)
  88071. */
  88072. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  88073. private _prepareWebGLTextureContinuation;
  88074. private _prepareWebGLTexture;
  88075. private _convertRGBtoRGBATextureData;
  88076. /** @hidden */
  88077. _releaseFramebufferObjects(texture: InternalTexture): void;
  88078. /** @hidden */
  88079. _releaseTexture(texture: InternalTexture): void;
  88080. private setProgram;
  88081. private _boundUniforms;
  88082. /**
  88083. * Binds an effect to the webGL context
  88084. * @param effect defines the effect to bind
  88085. */
  88086. bindSamplers(effect: Effect): void;
  88087. private _activateCurrentTexture;
  88088. /** @hidden */
  88089. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88090. /** @hidden */
  88091. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88092. /**
  88093. * Sets a texture to the webGL context from a postprocess
  88094. * @param channel defines the channel to use
  88095. * @param postProcess defines the source postprocess
  88096. */
  88097. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88098. /**
  88099. * Binds the output of the passed in post process to the texture channel specified
  88100. * @param channel The channel the texture should be bound to
  88101. * @param postProcess The post process which's output should be bound
  88102. */
  88103. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88104. /**
  88105. * Unbind all textures from the webGL context
  88106. */
  88107. unbindAllTextures(): void;
  88108. /**
  88109. * Sets a texture to the according uniform.
  88110. * @param channel The texture channel
  88111. * @param uniform The uniform to set
  88112. * @param texture The texture to apply
  88113. */
  88114. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88115. /**
  88116. * Sets a depth stencil texture from a render target to the according uniform.
  88117. * @param channel The texture channel
  88118. * @param uniform The uniform to set
  88119. * @param texture The render target texture containing the depth stencil texture to apply
  88120. */
  88121. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88122. private _bindSamplerUniformToChannel;
  88123. private _getTextureWrapMode;
  88124. private _setTexture;
  88125. /**
  88126. * Sets an array of texture to the webGL context
  88127. * @param channel defines the channel where the texture array must be set
  88128. * @param uniform defines the associated uniform location
  88129. * @param textures defines the array of textures to bind
  88130. */
  88131. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88132. /** @hidden */
  88133. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88134. private _setTextureParameterFloat;
  88135. private _setTextureParameterInteger;
  88136. /**
  88137. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88138. * @param x defines the x coordinate of the rectangle where pixels must be read
  88139. * @param y defines the y coordinate of the rectangle where pixels must be read
  88140. * @param width defines the width of the rectangle where pixels must be read
  88141. * @param height defines the height of the rectangle where pixels must be read
  88142. * @returns a Uint8Array containing RGBA colors
  88143. */
  88144. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88145. /**
  88146. * Add an externaly attached data from its key.
  88147. * This method call will fail and return false, if such key already exists.
  88148. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88149. * @param key the unique key that identifies the data
  88150. * @param data the data object to associate to the key for this Engine instance
  88151. * @return true if no such key were already present and the data was added successfully, false otherwise
  88152. */
  88153. addExternalData<T>(key: string, data: T): boolean;
  88154. /**
  88155. * Get an externaly attached data from its key
  88156. * @param key the unique key that identifies the data
  88157. * @return the associated data, if present (can be null), or undefined if not present
  88158. */
  88159. getExternalData<T>(key: string): T;
  88160. /**
  88161. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88162. * @param key the unique key that identifies the data
  88163. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88164. * @return the associated data, can be null if the factory returned null.
  88165. */
  88166. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88167. /**
  88168. * Remove an externaly attached data from the Engine instance
  88169. * @param key the unique key that identifies the data
  88170. * @return true if the data was successfully removed, false if it doesn't exist
  88171. */
  88172. removeExternalData(key: string): boolean;
  88173. /**
  88174. * Unbind all vertex attributes from the webGL context
  88175. */
  88176. unbindAllAttributes(): void;
  88177. /**
  88178. * 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
  88179. */
  88180. releaseEffects(): void;
  88181. /**
  88182. * Dispose and release all associated resources
  88183. */
  88184. dispose(): void;
  88185. /**
  88186. * Display the loading screen
  88187. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88188. */
  88189. displayLoadingUI(): void;
  88190. /**
  88191. * Hide the loading screen
  88192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88193. */
  88194. hideLoadingUI(): void;
  88195. /**
  88196. * Gets the current loading screen object
  88197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88198. */
  88199. /**
  88200. * Sets the current loading screen object
  88201. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88202. */
  88203. loadingScreen: ILoadingScreen;
  88204. /**
  88205. * Sets the current loading screen text
  88206. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88207. */
  88208. loadingUIText: string;
  88209. /**
  88210. * Sets the current loading screen background color
  88211. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88212. */
  88213. loadingUIBackgroundColor: string;
  88214. /**
  88215. * Attach a new callback raised when context lost event is fired
  88216. * @param callback defines the callback to call
  88217. */
  88218. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88219. /**
  88220. * Attach a new callback raised when context restored event is fired
  88221. * @param callback defines the callback to call
  88222. */
  88223. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88224. /**
  88225. * Gets the source code of the vertex shader associated with a specific webGL program
  88226. * @param program defines the program to use
  88227. * @returns a string containing the source code of the vertex shader associated with the program
  88228. */
  88229. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88230. /**
  88231. * Gets the source code of the fragment shader associated with a specific webGL program
  88232. * @param program defines the program to use
  88233. * @returns a string containing the source code of the fragment shader associated with the program
  88234. */
  88235. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88236. /**
  88237. * Get the current error code of the webGL context
  88238. * @returns the error code
  88239. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88240. */
  88241. getError(): number;
  88242. /**
  88243. * Gets the current framerate
  88244. * @returns a number representing the framerate
  88245. */
  88246. getFps(): number;
  88247. /**
  88248. * Gets the time spent between current and previous frame
  88249. * @returns a number representing the delta time in ms
  88250. */
  88251. getDeltaTime(): number;
  88252. private _measureFps;
  88253. /** @hidden */
  88254. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88255. private _canRenderToFloatFramebuffer;
  88256. private _canRenderToHalfFloatFramebuffer;
  88257. private _canRenderToFramebuffer;
  88258. /** @hidden */
  88259. _getWebGLTextureType(type: number): number;
  88260. private _getInternalFormat;
  88261. /** @hidden */
  88262. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88263. /** @hidden */
  88264. _getRGBAMultiSampleBufferFormat(type: number): number;
  88265. /** @hidden */
  88266. _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;
  88267. /** @hidden */
  88268. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88269. private _partialLoadFile;
  88270. private _cascadeLoadFiles;
  88271. /**
  88272. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88273. * @returns true if the engine can be created
  88274. * @ignorenaming
  88275. */
  88276. static isSupported(): boolean;
  88277. }
  88278. }
  88279. declare module BABYLON {
  88280. /**
  88281. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88282. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88283. */
  88284. export class EffectFallbacks {
  88285. private _defines;
  88286. private _currentRank;
  88287. private _maxRank;
  88288. private _mesh;
  88289. /**
  88290. * Removes the fallback from the bound mesh.
  88291. */
  88292. unBindMesh(): void;
  88293. /**
  88294. * Adds a fallback on the specified property.
  88295. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88296. * @param define The name of the define in the shader
  88297. */
  88298. addFallback(rank: number, define: string): void;
  88299. /**
  88300. * Sets the mesh to use CPU skinning when needing to fallback.
  88301. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88302. * @param mesh The mesh to use the fallbacks.
  88303. */
  88304. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88305. /**
  88306. * Checks to see if more fallbacks are still availible.
  88307. */
  88308. readonly isMoreFallbacks: boolean;
  88309. /**
  88310. * Removes the defines that shoould be removed when falling back.
  88311. * @param currentDefines defines the current define statements for the shader.
  88312. * @param effect defines the current effect we try to compile
  88313. * @returns The resulting defines with defines of the current rank removed.
  88314. */
  88315. reduce(currentDefines: string, effect: Effect): string;
  88316. }
  88317. /**
  88318. * Options to be used when creating an effect.
  88319. */
  88320. export class EffectCreationOptions {
  88321. /**
  88322. * Atrributes that will be used in the shader.
  88323. */
  88324. attributes: string[];
  88325. /**
  88326. * Uniform varible names that will be set in the shader.
  88327. */
  88328. uniformsNames: string[];
  88329. /**
  88330. * Uniform buffer varible names that will be set in the shader.
  88331. */
  88332. uniformBuffersNames: string[];
  88333. /**
  88334. * Sampler texture variable names that will be set in the shader.
  88335. */
  88336. samplers: string[];
  88337. /**
  88338. * Define statements that will be set in the shader.
  88339. */
  88340. defines: any;
  88341. /**
  88342. * Possible fallbacks for this effect to improve performance when needed.
  88343. */
  88344. fallbacks: Nullable<EffectFallbacks>;
  88345. /**
  88346. * Callback that will be called when the shader is compiled.
  88347. */
  88348. onCompiled: Nullable<(effect: Effect) => void>;
  88349. /**
  88350. * Callback that will be called if an error occurs during shader compilation.
  88351. */
  88352. onError: Nullable<(effect: Effect, errors: string) => void>;
  88353. /**
  88354. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88355. */
  88356. indexParameters: any;
  88357. /**
  88358. * Max number of lights that can be used in the shader.
  88359. */
  88360. maxSimultaneousLights: number;
  88361. /**
  88362. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88363. */
  88364. transformFeedbackVaryings: Nullable<string[]>;
  88365. }
  88366. /**
  88367. * Effect containing vertex and fragment shader that can be executed on an object.
  88368. */
  88369. export class Effect implements IDisposable {
  88370. /**
  88371. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88372. */
  88373. static ShadersRepository: string;
  88374. /**
  88375. * Name of the effect.
  88376. */
  88377. name: any;
  88378. /**
  88379. * String container all the define statements that should be set on the shader.
  88380. */
  88381. defines: string;
  88382. /**
  88383. * Callback that will be called when the shader is compiled.
  88384. */
  88385. onCompiled: Nullable<(effect: Effect) => void>;
  88386. /**
  88387. * Callback that will be called if an error occurs during shader compilation.
  88388. */
  88389. onError: Nullable<(effect: Effect, errors: string) => void>;
  88390. /**
  88391. * Callback that will be called when effect is bound.
  88392. */
  88393. onBind: Nullable<(effect: Effect) => void>;
  88394. /**
  88395. * Unique ID of the effect.
  88396. */
  88397. uniqueId: number;
  88398. /**
  88399. * Observable that will be called when the shader is compiled.
  88400. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88401. */
  88402. onCompileObservable: Observable<Effect>;
  88403. /**
  88404. * Observable that will be called if an error occurs during shader compilation.
  88405. */
  88406. onErrorObservable: Observable<Effect>;
  88407. /** @hidden */
  88408. _onBindObservable: Nullable<Observable<Effect>>;
  88409. /**
  88410. * Observable that will be called when effect is bound.
  88411. */
  88412. readonly onBindObservable: Observable<Effect>;
  88413. /** @hidden */
  88414. _bonesComputationForcedToCPU: boolean;
  88415. private static _uniqueIdSeed;
  88416. private _engine;
  88417. private _uniformBuffersNames;
  88418. private _uniformsNames;
  88419. private _samplerList;
  88420. private _samplers;
  88421. private _isReady;
  88422. private _compilationError;
  88423. private _attributesNames;
  88424. private _attributes;
  88425. private _uniforms;
  88426. /**
  88427. * Key for the effect.
  88428. * @hidden
  88429. */
  88430. _key: string;
  88431. private _indexParameters;
  88432. private _fallbacks;
  88433. private _vertexSourceCode;
  88434. private _fragmentSourceCode;
  88435. private _vertexSourceCodeOverride;
  88436. private _fragmentSourceCodeOverride;
  88437. private _transformFeedbackVaryings;
  88438. /**
  88439. * Compiled shader to webGL program.
  88440. * @hidden
  88441. */
  88442. _program: WebGLProgram;
  88443. private _valueCache;
  88444. private static _baseCache;
  88445. /**
  88446. * Instantiates an effect.
  88447. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88448. * @param baseName Name of the effect.
  88449. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88450. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88451. * @param samplers List of sampler variables that will be passed to the shader.
  88452. * @param engine Engine to be used to render the effect
  88453. * @param defines Define statements to be added to the shader.
  88454. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88455. * @param onCompiled Callback that will be called when the shader is compiled.
  88456. * @param onError Callback that will be called if an error occurs during shader compilation.
  88457. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88458. */
  88459. 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);
  88460. /**
  88461. * Unique key for this effect
  88462. */
  88463. readonly key: string;
  88464. /**
  88465. * If the effect has been compiled and prepared.
  88466. * @returns if the effect is compiled and prepared.
  88467. */
  88468. isReady(): boolean;
  88469. /**
  88470. * The engine the effect was initialized with.
  88471. * @returns the engine.
  88472. */
  88473. getEngine(): Engine;
  88474. /**
  88475. * The compiled webGL program for the effect
  88476. * @returns the webGL program.
  88477. */
  88478. getProgram(): WebGLProgram;
  88479. /**
  88480. * The set of names of attribute variables for the shader.
  88481. * @returns An array of attribute names.
  88482. */
  88483. getAttributesNames(): string[];
  88484. /**
  88485. * Returns the attribute at the given index.
  88486. * @param index The index of the attribute.
  88487. * @returns The location of the attribute.
  88488. */
  88489. getAttributeLocation(index: number): number;
  88490. /**
  88491. * Returns the attribute based on the name of the variable.
  88492. * @param name of the attribute to look up.
  88493. * @returns the attribute location.
  88494. */
  88495. getAttributeLocationByName(name: string): number;
  88496. /**
  88497. * The number of attributes.
  88498. * @returns the numnber of attributes.
  88499. */
  88500. getAttributesCount(): number;
  88501. /**
  88502. * Gets the index of a uniform variable.
  88503. * @param uniformName of the uniform to look up.
  88504. * @returns the index.
  88505. */
  88506. getUniformIndex(uniformName: string): number;
  88507. /**
  88508. * Returns the attribute based on the name of the variable.
  88509. * @param uniformName of the uniform to look up.
  88510. * @returns the location of the uniform.
  88511. */
  88512. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88513. /**
  88514. * Returns an array of sampler variable names
  88515. * @returns The array of sampler variable neames.
  88516. */
  88517. getSamplers(): string[];
  88518. /**
  88519. * The error from the last compilation.
  88520. * @returns the error string.
  88521. */
  88522. getCompilationError(): string;
  88523. /**
  88524. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88525. * @param func The callback to be used.
  88526. */
  88527. executeWhenCompiled(func: (effect: Effect) => void): void;
  88528. private _checkIsReady;
  88529. /** @hidden */
  88530. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88531. /** @hidden */
  88532. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88533. /** @hidden */
  88534. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88535. private _processShaderConversion;
  88536. private _processIncludes;
  88537. private _processPrecision;
  88538. /**
  88539. * Recompiles the webGL program
  88540. * @param vertexSourceCode The source code for the vertex shader.
  88541. * @param fragmentSourceCode The source code for the fragment shader.
  88542. * @param onCompiled Callback called when completed.
  88543. * @param onError Callback called on error.
  88544. * @hidden
  88545. */
  88546. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  88547. /**
  88548. * Gets the uniform locations of the the specified variable names
  88549. * @param names THe names of the variables to lookup.
  88550. * @returns Array of locations in the same order as variable names.
  88551. */
  88552. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  88553. /**
  88554. * Prepares the effect
  88555. * @hidden
  88556. */
  88557. _prepareEffect(): void;
  88558. /**
  88559. * Checks if the effect is supported. (Must be called after compilation)
  88560. */
  88561. readonly isSupported: boolean;
  88562. /**
  88563. * Binds a texture to the engine to be used as output of the shader.
  88564. * @param channel Name of the output variable.
  88565. * @param texture Texture to bind.
  88566. * @hidden
  88567. */
  88568. _bindTexture(channel: string, texture: InternalTexture): void;
  88569. /**
  88570. * Sets a texture on the engine to be used in the shader.
  88571. * @param channel Name of the sampler variable.
  88572. * @param texture Texture to set.
  88573. */
  88574. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88575. /**
  88576. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88577. * @param channel Name of the sampler variable.
  88578. * @param texture Texture to set.
  88579. */
  88580. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88581. /**
  88582. * Sets an array of textures on the engine to be used in the shader.
  88583. * @param channel Name of the variable.
  88584. * @param textures Textures to set.
  88585. */
  88586. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88587. /**
  88588. * 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)
  88589. * @param channel Name of the sampler variable.
  88590. * @param postProcess Post process to get the input texture from.
  88591. */
  88592. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88593. /**
  88594. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88595. * 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)
  88596. * @param channel Name of the sampler variable.
  88597. * @param postProcess Post process to get the output texture from.
  88598. */
  88599. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88600. /** @hidden */
  88601. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88602. /** @hidden */
  88603. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88604. /** @hidden */
  88605. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88606. /** @hidden */
  88607. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88608. /**
  88609. * Binds a buffer to a uniform.
  88610. * @param buffer Buffer to bind.
  88611. * @param name Name of the uniform variable to bind to.
  88612. */
  88613. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  88614. /**
  88615. * Binds block to a uniform.
  88616. * @param blockName Name of the block to bind.
  88617. * @param index Index to bind.
  88618. */
  88619. bindUniformBlock(blockName: string, index: number): void;
  88620. /**
  88621. * Sets an interger value on a uniform variable.
  88622. * @param uniformName Name of the variable.
  88623. * @param value Value to be set.
  88624. * @returns this effect.
  88625. */
  88626. setInt(uniformName: string, value: number): Effect;
  88627. /**
  88628. * Sets an int array on a uniform variable.
  88629. * @param uniformName Name of the variable.
  88630. * @param array array to be set.
  88631. * @returns this effect.
  88632. */
  88633. setIntArray(uniformName: string, array: Int32Array): Effect;
  88634. /**
  88635. * 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)
  88636. * @param uniformName Name of the variable.
  88637. * @param array array to be set.
  88638. * @returns this effect.
  88639. */
  88640. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88641. /**
  88642. * 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)
  88643. * @param uniformName Name of the variable.
  88644. * @param array array to be set.
  88645. * @returns this effect.
  88646. */
  88647. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88648. /**
  88649. * 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)
  88650. * @param uniformName Name of the variable.
  88651. * @param array array to be set.
  88652. * @returns this effect.
  88653. */
  88654. setIntArray4(uniformName: string, array: Int32Array): Effect;
  88655. /**
  88656. * Sets an float array on a uniform variable.
  88657. * @param uniformName Name of the variable.
  88658. * @param array array to be set.
  88659. * @returns this effect.
  88660. */
  88661. setFloatArray(uniformName: string, array: Float32Array): Effect;
  88662. /**
  88663. * 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)
  88664. * @param uniformName Name of the variable.
  88665. * @param array array to be set.
  88666. * @returns this effect.
  88667. */
  88668. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  88669. /**
  88670. * 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)
  88671. * @param uniformName Name of the variable.
  88672. * @param array array to be set.
  88673. * @returns this effect.
  88674. */
  88675. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  88676. /**
  88677. * 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)
  88678. * @param uniformName Name of the variable.
  88679. * @param array array to be set.
  88680. * @returns this effect.
  88681. */
  88682. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  88683. /**
  88684. * Sets an array on a uniform variable.
  88685. * @param uniformName Name of the variable.
  88686. * @param array array to be set.
  88687. * @returns this effect.
  88688. */
  88689. setArray(uniformName: string, array: number[]): Effect;
  88690. /**
  88691. * 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)
  88692. * @param uniformName Name of the variable.
  88693. * @param array array to be set.
  88694. * @returns this effect.
  88695. */
  88696. setArray2(uniformName: string, array: number[]): Effect;
  88697. /**
  88698. * 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)
  88699. * @param uniformName Name of the variable.
  88700. * @param array array to be set.
  88701. * @returns this effect.
  88702. */
  88703. setArray3(uniformName: string, array: number[]): Effect;
  88704. /**
  88705. * 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)
  88706. * @param uniformName Name of the variable.
  88707. * @param array array to be set.
  88708. * @returns this effect.
  88709. */
  88710. setArray4(uniformName: string, array: number[]): Effect;
  88711. /**
  88712. * Sets matrices on a uniform variable.
  88713. * @param uniformName Name of the variable.
  88714. * @param matrices matrices to be set.
  88715. * @returns this effect.
  88716. */
  88717. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  88718. /**
  88719. * Sets matrix on a uniform variable.
  88720. * @param uniformName Name of the variable.
  88721. * @param matrix matrix to be set.
  88722. * @returns this effect.
  88723. */
  88724. setMatrix(uniformName: string, matrix: Matrix): Effect;
  88725. /**
  88726. * 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)
  88727. * @param uniformName Name of the variable.
  88728. * @param matrix matrix to be set.
  88729. * @returns this effect.
  88730. */
  88731. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  88732. /**
  88733. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  88734. * @param uniformName Name of the variable.
  88735. * @param matrix matrix to be set.
  88736. * @returns this effect.
  88737. */
  88738. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  88739. /**
  88740. * Sets a float on a uniform variable.
  88741. * @param uniformName Name of the variable.
  88742. * @param value value to be set.
  88743. * @returns this effect.
  88744. */
  88745. setFloat(uniformName: string, value: number): Effect;
  88746. /**
  88747. * Sets a boolean on a uniform variable.
  88748. * @param uniformName Name of the variable.
  88749. * @param bool value to be set.
  88750. * @returns this effect.
  88751. */
  88752. setBool(uniformName: string, bool: boolean): Effect;
  88753. /**
  88754. * Sets a Vector2 on a uniform variable.
  88755. * @param uniformName Name of the variable.
  88756. * @param vector2 vector2 to be set.
  88757. * @returns this effect.
  88758. */
  88759. setVector2(uniformName: string, vector2: Vector2): Effect;
  88760. /**
  88761. * Sets a float2 on a uniform variable.
  88762. * @param uniformName Name of the variable.
  88763. * @param x First float in float2.
  88764. * @param y Second float in float2.
  88765. * @returns this effect.
  88766. */
  88767. setFloat2(uniformName: string, x: number, y: number): Effect;
  88768. /**
  88769. * Sets a Vector3 on a uniform variable.
  88770. * @param uniformName Name of the variable.
  88771. * @param vector3 Value to be set.
  88772. * @returns this effect.
  88773. */
  88774. setVector3(uniformName: string, vector3: Vector3): Effect;
  88775. /**
  88776. * Sets a float3 on a uniform variable.
  88777. * @param uniformName Name of the variable.
  88778. * @param x First float in float3.
  88779. * @param y Second float in float3.
  88780. * @param z Third float in float3.
  88781. * @returns this effect.
  88782. */
  88783. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88784. /**
  88785. * Sets a Vector4 on a uniform variable.
  88786. * @param uniformName Name of the variable.
  88787. * @param vector4 Value to be set.
  88788. * @returns this effect.
  88789. */
  88790. setVector4(uniformName: string, vector4: Vector4): Effect;
  88791. /**
  88792. * Sets a float4 on a uniform variable.
  88793. * @param uniformName Name of the variable.
  88794. * @param x First float in float4.
  88795. * @param y Second float in float4.
  88796. * @param z Third float in float4.
  88797. * @param w Fourth float in float4.
  88798. * @returns this effect.
  88799. */
  88800. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88801. /**
  88802. * Sets a Color3 on a uniform variable.
  88803. * @param uniformName Name of the variable.
  88804. * @param color3 Value to be set.
  88805. * @returns this effect.
  88806. */
  88807. setColor3(uniformName: string, color3: Color3): Effect;
  88808. /**
  88809. * Sets a Color4 on a uniform variable.
  88810. * @param uniformName Name of the variable.
  88811. * @param color3 Value to be set.
  88812. * @param alpha Alpha value to be set.
  88813. * @returns this effect.
  88814. */
  88815. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  88816. /**
  88817. * Sets a Color4 on a uniform variable
  88818. * @param uniformName defines the name of the variable
  88819. * @param color4 defines the value to be set
  88820. * @returns this effect.
  88821. */
  88822. setDirectColor4(uniformName: string, color4: Color4): Effect;
  88823. /** Release all associated resources */
  88824. dispose(): void;
  88825. /**
  88826. * This function will add a new shader to the shader store
  88827. * @param name the name of the shader
  88828. * @param pixelShader optional pixel shader content
  88829. * @param vertexShader optional vertex shader content
  88830. */
  88831. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  88832. /**
  88833. * Store of each shader (The can be looked up using effect.key)
  88834. */
  88835. static ShadersStore: {
  88836. [key: string]: string;
  88837. };
  88838. /**
  88839. * Store of each included file for a shader (The can be looked up using effect.key)
  88840. */
  88841. static IncludesShadersStore: {
  88842. [key: string]: string;
  88843. };
  88844. /**
  88845. * Resets the cache of effects.
  88846. */
  88847. static ResetCache(): void;
  88848. }
  88849. }
  88850. declare module BABYLON {
  88851. /**
  88852. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88853. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88854. * 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;
  88855. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88856. */
  88857. export class ColorCurves {
  88858. private _dirty;
  88859. private _tempColor;
  88860. private _globalCurve;
  88861. private _highlightsCurve;
  88862. private _midtonesCurve;
  88863. private _shadowsCurve;
  88864. private _positiveCurve;
  88865. private _negativeCurve;
  88866. private _globalHue;
  88867. private _globalDensity;
  88868. private _globalSaturation;
  88869. private _globalExposure;
  88870. /**
  88871. * Gets the global Hue value.
  88872. * 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).
  88873. */
  88874. /**
  88875. * Sets the global Hue value.
  88876. * 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).
  88877. */
  88878. globalHue: number;
  88879. /**
  88880. * Gets the global Density value.
  88881. * 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.
  88882. * Values less than zero provide a filter of opposite hue.
  88883. */
  88884. /**
  88885. * Sets the global Density value.
  88886. * 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.
  88887. * Values less than zero provide a filter of opposite hue.
  88888. */
  88889. globalDensity: number;
  88890. /**
  88891. * Gets the global Saturation value.
  88892. * 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.
  88893. */
  88894. /**
  88895. * Sets the global Saturation value.
  88896. * 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.
  88897. */
  88898. globalSaturation: number;
  88899. /**
  88900. * Gets the global Exposure value.
  88901. * 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.
  88902. */
  88903. /**
  88904. * Sets the global Exposure value.
  88905. * 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.
  88906. */
  88907. globalExposure: number;
  88908. private _highlightsHue;
  88909. private _highlightsDensity;
  88910. private _highlightsSaturation;
  88911. private _highlightsExposure;
  88912. /**
  88913. * Gets the highlights Hue value.
  88914. * 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).
  88915. */
  88916. /**
  88917. * Sets the highlights Hue value.
  88918. * 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).
  88919. */
  88920. highlightsHue: number;
  88921. /**
  88922. * Gets the highlights Density value.
  88923. * 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.
  88924. * Values less than zero provide a filter of opposite hue.
  88925. */
  88926. /**
  88927. * Sets the highlights Density value.
  88928. * 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.
  88929. * Values less than zero provide a filter of opposite hue.
  88930. */
  88931. highlightsDensity: number;
  88932. /**
  88933. * Gets the highlights Saturation value.
  88934. * 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.
  88935. */
  88936. /**
  88937. * Sets the highlights Saturation value.
  88938. * 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.
  88939. */
  88940. highlightsSaturation: number;
  88941. /**
  88942. * Gets the highlights Exposure value.
  88943. * 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.
  88944. */
  88945. /**
  88946. * Sets the highlights Exposure value.
  88947. * 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.
  88948. */
  88949. highlightsExposure: number;
  88950. private _midtonesHue;
  88951. private _midtonesDensity;
  88952. private _midtonesSaturation;
  88953. private _midtonesExposure;
  88954. /**
  88955. * Gets the midtones Hue value.
  88956. * 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).
  88957. */
  88958. /**
  88959. * Sets the midtones Hue value.
  88960. * 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).
  88961. */
  88962. midtonesHue: number;
  88963. /**
  88964. * Gets the midtones Density value.
  88965. * 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.
  88966. * Values less than zero provide a filter of opposite hue.
  88967. */
  88968. /**
  88969. * Sets the midtones Density value.
  88970. * 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.
  88971. * Values less than zero provide a filter of opposite hue.
  88972. */
  88973. midtonesDensity: number;
  88974. /**
  88975. * Gets the midtones Saturation value.
  88976. * 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.
  88977. */
  88978. /**
  88979. * Sets the midtones Saturation value.
  88980. * 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.
  88981. */
  88982. midtonesSaturation: number;
  88983. /**
  88984. * Gets the midtones Exposure value.
  88985. * 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.
  88986. */
  88987. /**
  88988. * Sets the midtones Exposure value.
  88989. * 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.
  88990. */
  88991. midtonesExposure: number;
  88992. private _shadowsHue;
  88993. private _shadowsDensity;
  88994. private _shadowsSaturation;
  88995. private _shadowsExposure;
  88996. /**
  88997. * Gets the shadows Hue value.
  88998. * 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).
  88999. */
  89000. /**
  89001. * Sets the shadows Hue value.
  89002. * 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).
  89003. */
  89004. shadowsHue: number;
  89005. /**
  89006. * Gets the shadows Density value.
  89007. * 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.
  89008. * Values less than zero provide a filter of opposite hue.
  89009. */
  89010. /**
  89011. * Sets the shadows Density value.
  89012. * 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.
  89013. * Values less than zero provide a filter of opposite hue.
  89014. */
  89015. shadowsDensity: number;
  89016. /**
  89017. * Gets the shadows Saturation value.
  89018. * 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.
  89019. */
  89020. /**
  89021. * Sets the shadows Saturation value.
  89022. * 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.
  89023. */
  89024. shadowsSaturation: number;
  89025. /**
  89026. * Gets the shadows Exposure value.
  89027. * 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.
  89028. */
  89029. /**
  89030. * Sets the shadows Exposure value.
  89031. * 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.
  89032. */
  89033. shadowsExposure: number;
  89034. /**
  89035. * Returns the class name
  89036. * @returns The class name
  89037. */
  89038. getClassName(): string;
  89039. /**
  89040. * Binds the color curves to the shader.
  89041. * @param colorCurves The color curve to bind
  89042. * @param effect The effect to bind to
  89043. * @param positiveUniform The positive uniform shader parameter
  89044. * @param neutralUniform The neutral uniform shader parameter
  89045. * @param negativeUniform The negative uniform shader parameter
  89046. */
  89047. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89048. /**
  89049. * Prepare the list of uniforms associated with the ColorCurves effects.
  89050. * @param uniformsList The list of uniforms used in the effect
  89051. */
  89052. static PrepareUniforms(uniformsList: string[]): void;
  89053. /**
  89054. * Returns color grading data based on a hue, density, saturation and exposure value.
  89055. * @param filterHue The hue of the color filter.
  89056. * @param filterDensity The density of the color filter.
  89057. * @param saturation The saturation.
  89058. * @param exposure The exposure.
  89059. * @param result The result data container.
  89060. */
  89061. private getColorGradingDataToRef;
  89062. /**
  89063. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89064. * @param value The input slider value in range [-100,100].
  89065. * @returns Adjusted value.
  89066. */
  89067. private static applyColorGradingSliderNonlinear;
  89068. /**
  89069. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89070. * @param hue The hue (H) input.
  89071. * @param saturation The saturation (S) input.
  89072. * @param brightness The brightness (B) input.
  89073. * @result An RGBA color represented as Vector4.
  89074. */
  89075. private static fromHSBToRef;
  89076. /**
  89077. * Returns a value clamped between min and max
  89078. * @param value The value to clamp
  89079. * @param min The minimum of value
  89080. * @param max The maximum of value
  89081. * @returns The clamped value.
  89082. */
  89083. private static clamp;
  89084. /**
  89085. * Clones the current color curve instance.
  89086. * @return The cloned curves
  89087. */
  89088. clone(): ColorCurves;
  89089. /**
  89090. * Serializes the current color curve instance to a json representation.
  89091. * @return a JSON representation
  89092. */
  89093. serialize(): any;
  89094. /**
  89095. * Parses the color curve from a json representation.
  89096. * @param source the JSON source to parse
  89097. * @return The parsed curves
  89098. */
  89099. static Parse(source: any): ColorCurves;
  89100. }
  89101. }
  89102. declare module BABYLON {
  89103. /**
  89104. * Interface to follow in your material defines to integrate easily the
  89105. * Image proccessing functions.
  89106. * @hidden
  89107. */
  89108. export interface IImageProcessingConfigurationDefines {
  89109. IMAGEPROCESSING: boolean;
  89110. VIGNETTE: boolean;
  89111. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89112. VIGNETTEBLENDMODEOPAQUE: boolean;
  89113. TONEMAPPING: boolean;
  89114. TONEMAPPING_ACES: boolean;
  89115. CONTRAST: boolean;
  89116. EXPOSURE: boolean;
  89117. COLORCURVES: boolean;
  89118. COLORGRADING: boolean;
  89119. COLORGRADING3D: boolean;
  89120. SAMPLER3DGREENDEPTH: boolean;
  89121. SAMPLER3DBGRMAP: boolean;
  89122. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89123. }
  89124. /**
  89125. * @hidden
  89126. */
  89127. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89128. IMAGEPROCESSING: boolean;
  89129. VIGNETTE: boolean;
  89130. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89131. VIGNETTEBLENDMODEOPAQUE: boolean;
  89132. TONEMAPPING: boolean;
  89133. TONEMAPPING_ACES: boolean;
  89134. CONTRAST: boolean;
  89135. COLORCURVES: boolean;
  89136. COLORGRADING: boolean;
  89137. COLORGRADING3D: boolean;
  89138. SAMPLER3DGREENDEPTH: boolean;
  89139. SAMPLER3DBGRMAP: boolean;
  89140. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89141. EXPOSURE: boolean;
  89142. constructor();
  89143. }
  89144. /**
  89145. * This groups together the common properties used for image processing either in direct forward pass
  89146. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89147. * or not.
  89148. */
  89149. export class ImageProcessingConfiguration {
  89150. /**
  89151. * Default tone mapping applied in BabylonJS.
  89152. */
  89153. static readonly TONEMAPPING_STANDARD: number;
  89154. /**
  89155. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89156. * to other engines rendering to increase portability.
  89157. */
  89158. static readonly TONEMAPPING_ACES: number;
  89159. /**
  89160. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89161. */
  89162. colorCurves: Nullable<ColorCurves>;
  89163. private _colorCurvesEnabled;
  89164. /**
  89165. * Gets wether the color curves effect is enabled.
  89166. */
  89167. /**
  89168. * Sets wether the color curves effect is enabled.
  89169. */
  89170. colorCurvesEnabled: boolean;
  89171. private _colorGradingTexture;
  89172. /**
  89173. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89174. */
  89175. /**
  89176. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89177. */
  89178. colorGradingTexture: Nullable<BaseTexture>;
  89179. private _colorGradingEnabled;
  89180. /**
  89181. * Gets wether the color grading effect is enabled.
  89182. */
  89183. /**
  89184. * Sets wether the color grading effect is enabled.
  89185. */
  89186. colorGradingEnabled: boolean;
  89187. private _colorGradingWithGreenDepth;
  89188. /**
  89189. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89190. */
  89191. /**
  89192. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89193. */
  89194. colorGradingWithGreenDepth: boolean;
  89195. private _colorGradingBGR;
  89196. /**
  89197. * Gets wether the color grading texture contains BGR values.
  89198. */
  89199. /**
  89200. * Sets wether the color grading texture contains BGR values.
  89201. */
  89202. colorGradingBGR: boolean;
  89203. /** @hidden */
  89204. _exposure: number;
  89205. /**
  89206. * Gets the Exposure used in the effect.
  89207. */
  89208. /**
  89209. * Sets the Exposure used in the effect.
  89210. */
  89211. exposure: number;
  89212. private _toneMappingEnabled;
  89213. /**
  89214. * Gets wether the tone mapping effect is enabled.
  89215. */
  89216. /**
  89217. * Sets wether the tone mapping effect is enabled.
  89218. */
  89219. toneMappingEnabled: boolean;
  89220. private _toneMappingType;
  89221. /**
  89222. * Gets the type of tone mapping effect.
  89223. */
  89224. /**
  89225. * Sets the type of tone mapping effect used in BabylonJS.
  89226. */
  89227. toneMappingType: number;
  89228. protected _contrast: number;
  89229. /**
  89230. * Gets the contrast used in the effect.
  89231. */
  89232. /**
  89233. * Sets the contrast used in the effect.
  89234. */
  89235. contrast: number;
  89236. /**
  89237. * Vignette stretch size.
  89238. */
  89239. vignetteStretch: number;
  89240. /**
  89241. * Vignette centre X Offset.
  89242. */
  89243. vignetteCentreX: number;
  89244. /**
  89245. * Vignette centre Y Offset.
  89246. */
  89247. vignetteCentreY: number;
  89248. /**
  89249. * Vignette weight or intensity of the vignette effect.
  89250. */
  89251. vignetteWeight: number;
  89252. /**
  89253. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89254. * if vignetteEnabled is set to true.
  89255. */
  89256. vignetteColor: Color4;
  89257. /**
  89258. * Camera field of view used by the Vignette effect.
  89259. */
  89260. vignetteCameraFov: number;
  89261. private _vignetteBlendMode;
  89262. /**
  89263. * Gets the vignette blend mode allowing different kind of effect.
  89264. */
  89265. /**
  89266. * Sets the vignette blend mode allowing different kind of effect.
  89267. */
  89268. vignetteBlendMode: number;
  89269. private _vignetteEnabled;
  89270. /**
  89271. * Gets wether the vignette effect is enabled.
  89272. */
  89273. /**
  89274. * Sets wether the vignette effect is enabled.
  89275. */
  89276. vignetteEnabled: boolean;
  89277. private _applyByPostProcess;
  89278. /**
  89279. * Gets wether the image processing is applied through a post process or not.
  89280. */
  89281. /**
  89282. * Sets wether the image processing is applied through a post process or not.
  89283. */
  89284. applyByPostProcess: boolean;
  89285. private _isEnabled;
  89286. /**
  89287. * Gets wether the image processing is enabled or not.
  89288. */
  89289. /**
  89290. * Sets wether the image processing is enabled or not.
  89291. */
  89292. isEnabled: boolean;
  89293. /**
  89294. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89295. */
  89296. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89297. /**
  89298. * Method called each time the image processing information changes requires to recompile the effect.
  89299. */
  89300. protected _updateParameters(): void;
  89301. /**
  89302. * Gets the current class name.
  89303. * @return "ImageProcessingConfiguration"
  89304. */
  89305. getClassName(): string;
  89306. /**
  89307. * Prepare the list of uniforms associated with the Image Processing effects.
  89308. * @param uniforms The list of uniforms used in the effect
  89309. * @param defines the list of defines currently in use
  89310. */
  89311. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89312. /**
  89313. * Prepare the list of samplers associated with the Image Processing effects.
  89314. * @param samplersList The list of uniforms used in the effect
  89315. * @param defines the list of defines currently in use
  89316. */
  89317. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89318. /**
  89319. * Prepare the list of defines associated to the shader.
  89320. * @param defines the list of defines to complete
  89321. * @param forPostProcess Define if we are currently in post process mode or not
  89322. */
  89323. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89324. /**
  89325. * Returns true if all the image processing information are ready.
  89326. * @returns True if ready, otherwise, false
  89327. */
  89328. isReady(): boolean;
  89329. /**
  89330. * Binds the image processing to the shader.
  89331. * @param effect The effect to bind to
  89332. * @param aspectRatio Define the current aspect ratio of the effect
  89333. */
  89334. bind(effect: Effect, aspectRatio?: number): void;
  89335. /**
  89336. * Clones the current image processing instance.
  89337. * @return The cloned image processing
  89338. */
  89339. clone(): ImageProcessingConfiguration;
  89340. /**
  89341. * Serializes the current image processing instance to a json representation.
  89342. * @return a JSON representation
  89343. */
  89344. serialize(): any;
  89345. /**
  89346. * Parses the image processing from a json representation.
  89347. * @param source the JSON source to parse
  89348. * @return The parsed image processing
  89349. */
  89350. static Parse(source: any): ImageProcessingConfiguration;
  89351. private static _VIGNETTEMODE_MULTIPLY;
  89352. private static _VIGNETTEMODE_OPAQUE;
  89353. /**
  89354. * Used to apply the vignette as a mix with the pixel color.
  89355. */
  89356. static readonly VIGNETTEMODE_MULTIPLY: number;
  89357. /**
  89358. * Used to apply the vignette as a replacement of the pixel color.
  89359. */
  89360. static readonly VIGNETTEMODE_OPAQUE: number;
  89361. }
  89362. }
  89363. declare module BABYLON {
  89364. /**
  89365. * This represents all the required information to add a fresnel effect on a material:
  89366. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89367. */
  89368. export class FresnelParameters {
  89369. private _isEnabled;
  89370. /**
  89371. * Define if the fresnel effect is enable or not.
  89372. */
  89373. isEnabled: boolean;
  89374. /**
  89375. * Define the color used on edges (grazing angle)
  89376. */
  89377. leftColor: Color3;
  89378. /**
  89379. * Define the color used on center
  89380. */
  89381. rightColor: Color3;
  89382. /**
  89383. * Define bias applied to computed fresnel term
  89384. */
  89385. bias: number;
  89386. /**
  89387. * Defined the power exponent applied to fresnel term
  89388. */
  89389. power: number;
  89390. /**
  89391. * Clones the current fresnel and its valuues
  89392. * @returns a clone fresnel configuration
  89393. */
  89394. clone(): FresnelParameters;
  89395. /**
  89396. * Serializes the current fresnel parameters to a JSON representation.
  89397. * @return the JSON serialization
  89398. */
  89399. serialize(): any;
  89400. /**
  89401. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89402. * @param parsedFresnelParameters Define the JSON representation
  89403. * @returns the parsed parameters
  89404. */
  89405. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89406. }
  89407. }
  89408. declare module BABYLON {
  89409. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89410. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89411. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89412. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89413. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89414. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89415. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89416. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89417. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89418. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89419. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89420. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89421. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89422. /**
  89423. * Decorator used to define property that can be serialized as reference to a camera
  89424. * @param sourceName defines the name of the property to decorate
  89425. */
  89426. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89427. /**
  89428. * Class used to help serialization objects
  89429. */
  89430. export class SerializationHelper {
  89431. /** hidden */
  89432. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89433. /** hidden */
  89434. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89435. /** hidden */
  89436. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89437. /** hidden */
  89438. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89439. /**
  89440. * Appends the serialized animations from the source animations
  89441. * @param source Source containing the animations
  89442. * @param destination Target to store the animations
  89443. */
  89444. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89445. /**
  89446. * Static function used to serialized a specific entity
  89447. * @param entity defines the entity to serialize
  89448. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89449. * @returns a JSON compatible object representing the serialization of the entity
  89450. */
  89451. static Serialize<T>(entity: T, serializationObject?: any): any;
  89452. /**
  89453. * Creates a new entity from a serialization data object
  89454. * @param creationFunction defines a function used to instanciated the new entity
  89455. * @param source defines the source serialization data
  89456. * @param scene defines the hosting scene
  89457. * @param rootUrl defines the root url for resources
  89458. * @returns a new entity
  89459. */
  89460. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89461. /**
  89462. * Clones an object
  89463. * @param creationFunction defines the function used to instanciate the new object
  89464. * @param source defines the source object
  89465. * @returns the cloned object
  89466. */
  89467. static Clone<T>(creationFunction: () => T, source: T): T;
  89468. /**
  89469. * Instanciates a new object based on a source one (some data will be shared between both object)
  89470. * @param creationFunction defines the function used to instanciate the new object
  89471. * @param source defines the source object
  89472. * @returns the new object
  89473. */
  89474. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89475. }
  89476. }
  89477. declare module BABYLON {
  89478. /**
  89479. * This is the base class of all the camera used in the application.
  89480. * @see http://doc.babylonjs.com/features/cameras
  89481. */
  89482. export class Camera extends Node {
  89483. /** @hidden */
  89484. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89485. /**
  89486. * This is the default projection mode used by the cameras.
  89487. * It helps recreating a feeling of perspective and better appreciate depth.
  89488. * This is the best way to simulate real life cameras.
  89489. */
  89490. static readonly PERSPECTIVE_CAMERA: number;
  89491. /**
  89492. * This helps creating camera with an orthographic mode.
  89493. * 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.
  89494. */
  89495. static readonly ORTHOGRAPHIC_CAMERA: number;
  89496. /**
  89497. * This is the default FOV mode for perspective cameras.
  89498. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89499. */
  89500. static readonly FOVMODE_VERTICAL_FIXED: number;
  89501. /**
  89502. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89503. */
  89504. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89505. /**
  89506. * This specifies ther is no need for a camera rig.
  89507. * Basically only one eye is rendered corresponding to the camera.
  89508. */
  89509. static readonly RIG_MODE_NONE: number;
  89510. /**
  89511. * Simulates a camera Rig with one blue eye and one red eye.
  89512. * This can be use with 3d blue and red glasses.
  89513. */
  89514. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89515. /**
  89516. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89517. */
  89518. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89519. /**
  89520. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89521. */
  89522. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89523. /**
  89524. * Defines that both eyes of the camera will be rendered over under each other.
  89525. */
  89526. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89527. /**
  89528. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89529. */
  89530. static readonly RIG_MODE_VR: number;
  89531. /**
  89532. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89533. */
  89534. static readonly RIG_MODE_WEBVR: number;
  89535. /**
  89536. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89537. */
  89538. static readonly RIG_MODE_CUSTOM: number;
  89539. /**
  89540. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89541. */
  89542. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89543. /**
  89544. * Define the input manager associated with the camera.
  89545. */
  89546. inputs: CameraInputsManager<Camera>;
  89547. /** @hidden */
  89548. _position: Vector3;
  89549. /**
  89550. * Define the current local position of the camera in the scene
  89551. */
  89552. position: Vector3;
  89553. /**
  89554. * The vector the camera should consider as up.
  89555. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89556. */
  89557. upVector: Vector3;
  89558. /**
  89559. * Define the current limit on the left side for an orthographic camera
  89560. * In scene unit
  89561. */
  89562. orthoLeft: Nullable<number>;
  89563. /**
  89564. * Define the current limit on the right side for an orthographic camera
  89565. * In scene unit
  89566. */
  89567. orthoRight: Nullable<number>;
  89568. /**
  89569. * Define the current limit on the bottom side for an orthographic camera
  89570. * In scene unit
  89571. */
  89572. orthoBottom: Nullable<number>;
  89573. /**
  89574. * Define the current limit on the top side for an orthographic camera
  89575. * In scene unit
  89576. */
  89577. orthoTop: Nullable<number>;
  89578. /**
  89579. * Field Of View is set in Radians. (default is 0.8)
  89580. */
  89581. fov: number;
  89582. /**
  89583. * Define the minimum distance the camera can see from.
  89584. * This is important to note that the depth buffer are not infinite and the closer it starts
  89585. * the more your scene might encounter depth fighting issue.
  89586. */
  89587. minZ: number;
  89588. /**
  89589. * Define the maximum distance the camera can see to.
  89590. * This is important to note that the depth buffer are not infinite and the further it end
  89591. * the more your scene might encounter depth fighting issue.
  89592. */
  89593. maxZ: number;
  89594. /**
  89595. * Define the default inertia of the camera.
  89596. * This helps giving a smooth feeling to the camera movement.
  89597. */
  89598. inertia: number;
  89599. /**
  89600. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89601. */
  89602. mode: number;
  89603. /**
  89604. * Define wether the camera is intermediate.
  89605. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89606. */
  89607. isIntermediate: boolean;
  89608. /**
  89609. * Define the viewport of the camera.
  89610. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89611. */
  89612. viewport: Viewport;
  89613. /**
  89614. * Restricts the camera to viewing objects with the same layerMask.
  89615. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89616. */
  89617. layerMask: number;
  89618. /**
  89619. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89620. */
  89621. fovMode: number;
  89622. /**
  89623. * Rig mode of the camera.
  89624. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89625. * This is normally controlled byt the camera themselves as internal use.
  89626. */
  89627. cameraRigMode: number;
  89628. /**
  89629. * Defines the distance between both "eyes" in case of a RIG
  89630. */
  89631. interaxialDistance: number;
  89632. /**
  89633. * Defines if stereoscopic rendering is done side by side or over under.
  89634. */
  89635. isStereoscopicSideBySide: boolean;
  89636. /**
  89637. * 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
  89638. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89639. * else in the scene.
  89640. */
  89641. customRenderTargets: RenderTargetTexture[];
  89642. /**
  89643. * When set, the camera will render to this render target instead of the default canvas
  89644. */
  89645. outputRenderTarget: Nullable<RenderTargetTexture>;
  89646. /**
  89647. * Observable triggered when the camera view matrix has changed.
  89648. */
  89649. onViewMatrixChangedObservable: Observable<Camera>;
  89650. /**
  89651. * Observable triggered when the camera Projection matrix has changed.
  89652. */
  89653. onProjectionMatrixChangedObservable: Observable<Camera>;
  89654. /**
  89655. * Observable triggered when the inputs have been processed.
  89656. */
  89657. onAfterCheckInputsObservable: Observable<Camera>;
  89658. /**
  89659. * Observable triggered when reset has been called and applied to the camera.
  89660. */
  89661. onRestoreStateObservable: Observable<Camera>;
  89662. /** @hidden */
  89663. _cameraRigParams: any;
  89664. /** @hidden */
  89665. _rigCameras: Camera[];
  89666. /** @hidden */
  89667. _rigPostProcess: Nullable<PostProcess>;
  89668. protected _webvrViewMatrix: Matrix;
  89669. /** @hidden */
  89670. _skipRendering: boolean;
  89671. /** @hidden */
  89672. _projectionMatrix: Matrix;
  89673. /** @hidden */
  89674. _postProcesses: Nullable<PostProcess>[];
  89675. /** @hidden */
  89676. _activeMeshes: SmartArray<AbstractMesh>;
  89677. protected _globalPosition: Vector3;
  89678. /** hidden */
  89679. _computedViewMatrix: Matrix;
  89680. private _doNotComputeProjectionMatrix;
  89681. private _transformMatrix;
  89682. private _frustumPlanes;
  89683. private _refreshFrustumPlanes;
  89684. private _storedFov;
  89685. private _stateStored;
  89686. /**
  89687. * Instantiates a new camera object.
  89688. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89689. * @see http://doc.babylonjs.com/features/cameras
  89690. * @param name Defines the name of the camera in the scene
  89691. * @param position Defines the position of the camera
  89692. * @param scene Defines the scene the camera belongs too
  89693. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89694. */
  89695. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89696. /**
  89697. * Store current camera state (fov, position, etc..)
  89698. * @returns the camera
  89699. */
  89700. storeState(): Camera;
  89701. /**
  89702. * Restores the camera state values if it has been stored. You must call storeState() first
  89703. */
  89704. protected _restoreStateValues(): boolean;
  89705. /**
  89706. * Restored camera state. You must call storeState() first.
  89707. * @returns true if restored and false otherwise
  89708. */
  89709. restoreState(): boolean;
  89710. /**
  89711. * Gets the class name of the camera.
  89712. * @returns the class name
  89713. */
  89714. getClassName(): string;
  89715. /** @hidden */
  89716. readonly _isCamera: boolean;
  89717. /**
  89718. * Gets a string representation of the camera useful for debug purpose.
  89719. * @param fullDetails Defines that a more verboe level of logging is required
  89720. * @returns the string representation
  89721. */
  89722. toString(fullDetails?: boolean): string;
  89723. /**
  89724. * Gets the current world space position of the camera.
  89725. */
  89726. readonly globalPosition: Vector3;
  89727. /**
  89728. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89729. * @returns the active meshe list
  89730. */
  89731. getActiveMeshes(): SmartArray<AbstractMesh>;
  89732. /**
  89733. * Check wether a mesh is part of the current active mesh list of the camera
  89734. * @param mesh Defines the mesh to check
  89735. * @returns true if active, false otherwise
  89736. */
  89737. isActiveMesh(mesh: Mesh): boolean;
  89738. /**
  89739. * Is this camera ready to be used/rendered
  89740. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89741. * @return true if the camera is ready
  89742. */
  89743. isReady(completeCheck?: boolean): boolean;
  89744. /** @hidden */
  89745. _initCache(): void;
  89746. /** @hidden */
  89747. _updateCache(ignoreParentClass?: boolean): void;
  89748. /** @hidden */
  89749. _isSynchronized(): boolean;
  89750. /** @hidden */
  89751. _isSynchronizedViewMatrix(): boolean;
  89752. /** @hidden */
  89753. _isSynchronizedProjectionMatrix(): boolean;
  89754. /**
  89755. * Attach the input controls to a specific dom element to get the input from.
  89756. * @param element Defines the element the controls should be listened from
  89757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89758. */
  89759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89760. /**
  89761. * Detach the current controls from the specified dom element.
  89762. * @param element Defines the element to stop listening the inputs from
  89763. */
  89764. detachControl(element: HTMLElement): void;
  89765. /**
  89766. * Update the camera state according to the different inputs gathered during the frame.
  89767. */
  89768. update(): void;
  89769. /** @hidden */
  89770. _checkInputs(): void;
  89771. /** @hidden */
  89772. readonly rigCameras: Camera[];
  89773. /**
  89774. * Gets the post process used by the rig cameras
  89775. */
  89776. readonly rigPostProcess: Nullable<PostProcess>;
  89777. /**
  89778. * Internal, gets the first post proces.
  89779. * @returns the first post process to be run on this camera.
  89780. */
  89781. _getFirstPostProcess(): Nullable<PostProcess>;
  89782. private _cascadePostProcessesToRigCams;
  89783. /**
  89784. * Attach a post process to the camera.
  89785. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89786. * @param postProcess The post process to attach to the camera
  89787. * @param insertAt The position of the post process in case several of them are in use in the scene
  89788. * @returns the position the post process has been inserted at
  89789. */
  89790. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89791. /**
  89792. * Detach a post process to the camera.
  89793. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89794. * @param postProcess The post process to detach from the camera
  89795. */
  89796. detachPostProcess(postProcess: PostProcess): void;
  89797. /**
  89798. * Gets the current world matrix of the camera
  89799. */
  89800. getWorldMatrix(): Matrix;
  89801. /** @hidden */
  89802. _getViewMatrix(): Matrix;
  89803. /**
  89804. * Gets the current view matrix of the camera.
  89805. * @param force forces the camera to recompute the matrix without looking at the cached state
  89806. * @returns the view matrix
  89807. */
  89808. getViewMatrix(force?: boolean): Matrix;
  89809. /**
  89810. * Freeze the projection matrix.
  89811. * It will prevent the cache check of the camera projection compute and can speed up perf
  89812. * if no parameter of the camera are meant to change
  89813. * @param projection Defines manually a projection if necessary
  89814. */
  89815. freezeProjectionMatrix(projection?: Matrix): void;
  89816. /**
  89817. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89818. */
  89819. unfreezeProjectionMatrix(): void;
  89820. /**
  89821. * Gets the current projection matrix of the camera.
  89822. * @param force forces the camera to recompute the matrix without looking at the cached state
  89823. * @returns the projection matrix
  89824. */
  89825. getProjectionMatrix(force?: boolean): Matrix;
  89826. /**
  89827. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89828. * @returns a Matrix
  89829. */
  89830. getTransformationMatrix(): Matrix;
  89831. private _updateFrustumPlanes;
  89832. /**
  89833. * Checks if a cullable object (mesh...) is in the camera frustum
  89834. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89835. * @param target The object to check
  89836. * @returns true if the object is in frustum otherwise false
  89837. */
  89838. isInFrustum(target: ICullable): boolean;
  89839. /**
  89840. * Checks if a cullable object (mesh...) is in the camera frustum
  89841. * Unlike isInFrustum this cheks the full bounding box
  89842. * @param target The object to check
  89843. * @returns true if the object is in frustum otherwise false
  89844. */
  89845. isCompletelyInFrustum(target: ICullable): boolean;
  89846. /**
  89847. * Gets a ray in the forward direction from the camera.
  89848. * @param length Defines the length of the ray to create
  89849. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89850. * @param origin Defines the start point of the ray which defaults to the camera position
  89851. * @returns the forward ray
  89852. */
  89853. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89854. /**
  89855. * Releases resources associated with this node.
  89856. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89857. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89858. */
  89859. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89860. /** @hidden */
  89861. _isLeftCamera: boolean;
  89862. /**
  89863. * Gets the left camera of a rig setup in case of Rigged Camera
  89864. */
  89865. readonly isLeftCamera: boolean;
  89866. /** @hidden */
  89867. _isRightCamera: boolean;
  89868. /**
  89869. * Gets the right camera of a rig setup in case of Rigged Camera
  89870. */
  89871. readonly isRightCamera: boolean;
  89872. /**
  89873. * Gets the left camera of a rig setup in case of Rigged Camera
  89874. */
  89875. readonly leftCamera: Nullable<FreeCamera>;
  89876. /**
  89877. * Gets the right camera of a rig setup in case of Rigged Camera
  89878. */
  89879. readonly rightCamera: Nullable<FreeCamera>;
  89880. /**
  89881. * Gets the left camera target of a rig setup in case of Rigged Camera
  89882. * @returns the target position
  89883. */
  89884. getLeftTarget(): Nullable<Vector3>;
  89885. /**
  89886. * Gets the right camera target of a rig setup in case of Rigged Camera
  89887. * @returns the target position
  89888. */
  89889. getRightTarget(): Nullable<Vector3>;
  89890. /**
  89891. * @hidden
  89892. */
  89893. setCameraRigMode(mode: number, rigParams: any): void;
  89894. /** @hidden */
  89895. static _setStereoscopicRigMode(camera: Camera): void;
  89896. /** @hidden */
  89897. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89898. /** @hidden */
  89899. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89900. /** @hidden */
  89901. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89902. /** @hidden */
  89903. _getVRProjectionMatrix(): Matrix;
  89904. protected _updateCameraRotationMatrix(): void;
  89905. protected _updateWebVRCameraRotationMatrix(): void;
  89906. /**
  89907. * This function MUST be overwritten by the different WebVR cameras available.
  89908. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89909. * @hidden
  89910. */
  89911. _getWebVRProjectionMatrix(): Matrix;
  89912. /**
  89913. * This function MUST be overwritten by the different WebVR cameras available.
  89914. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89915. * @hidden
  89916. */
  89917. _getWebVRViewMatrix(): Matrix;
  89918. /** @hidden */
  89919. setCameraRigParameter(name: string, value: any): void;
  89920. /**
  89921. * needs to be overridden by children so sub has required properties to be copied
  89922. * @hidden
  89923. */
  89924. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89925. /**
  89926. * May need to be overridden by children
  89927. * @hidden
  89928. */
  89929. _updateRigCameras(): void;
  89930. /** @hidden */
  89931. _setupInputs(): void;
  89932. /**
  89933. * Serialiaze the camera setup to a json represention
  89934. * @returns the JSON representation
  89935. */
  89936. serialize(): any;
  89937. /**
  89938. * Clones the current camera.
  89939. * @param name The cloned camera name
  89940. * @returns the cloned camera
  89941. */
  89942. clone(name: string): Camera;
  89943. /**
  89944. * Gets the direction of the camera relative to a given local axis.
  89945. * @param localAxis Defines the reference axis to provide a relative direction.
  89946. * @return the direction
  89947. */
  89948. getDirection(localAxis: Vector3): Vector3;
  89949. /**
  89950. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89951. * @param localAxis Defines the reference axis to provide a relative direction.
  89952. * @param result Defines the vector to store the result in
  89953. */
  89954. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89955. /**
  89956. * Gets a camera constructor for a given camera type
  89957. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89958. * @param name The name of the camera the result will be able to instantiate
  89959. * @param scene The scene the result will construct the camera in
  89960. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89961. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89962. * @returns a factory method to construc the camera
  89963. */
  89964. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89965. /**
  89966. * Compute the world matrix of the camera.
  89967. * @returns the camera workd matrix
  89968. */
  89969. computeWorldMatrix(): Matrix;
  89970. /**
  89971. * Parse a JSON and creates the camera from the parsed information
  89972. * @param parsedCamera The JSON to parse
  89973. * @param scene The scene to instantiate the camera in
  89974. * @returns the newly constructed camera
  89975. */
  89976. static Parse(parsedCamera: any, scene: Scene): Camera;
  89977. }
  89978. }
  89979. declare module BABYLON {
  89980. /**
  89981. * Interface for any object that can request an animation frame
  89982. */
  89983. export interface ICustomAnimationFrameRequester {
  89984. /**
  89985. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  89986. */
  89987. renderFunction?: Function;
  89988. /**
  89989. * Called to request the next frame to render to
  89990. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  89991. */
  89992. requestAnimationFrame: Function;
  89993. /**
  89994. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  89995. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  89996. */
  89997. requestID?: number;
  89998. }
  89999. /**
  90000. * Interface containing an array of animations
  90001. */
  90002. export interface IAnimatable {
  90003. /**
  90004. * Array of animations
  90005. */
  90006. animations: Array<Animation>;
  90007. }
  90008. /** Interface used by value gradients (color, factor, ...) */
  90009. export interface IValueGradient {
  90010. /**
  90011. * Gets or sets the gradient value (between 0 and 1)
  90012. */
  90013. gradient: number;
  90014. }
  90015. /** Class used to store color4 gradient */
  90016. export class ColorGradient implements IValueGradient {
  90017. /**
  90018. * Gets or sets the gradient value (between 0 and 1)
  90019. */
  90020. gradient: number;
  90021. /**
  90022. * Gets or sets first associated color
  90023. */
  90024. color1: Color4;
  90025. /**
  90026. * Gets or sets second associated color
  90027. */
  90028. color2?: Color4;
  90029. /**
  90030. * Will get a color picked randomly between color1 and color2.
  90031. * If color2 is undefined then color1 will be used
  90032. * @param result defines the target Color4 to store the result in
  90033. */
  90034. getColorToRef(result: Color4): void;
  90035. }
  90036. /** Class used to store color 3 gradient */
  90037. export class Color3Gradient implements IValueGradient {
  90038. /**
  90039. * Gets or sets the gradient value (between 0 and 1)
  90040. */
  90041. gradient: number;
  90042. /**
  90043. * Gets or sets the associated color
  90044. */
  90045. color: Color3;
  90046. }
  90047. /** Class used to store factor gradient */
  90048. export class FactorGradient implements IValueGradient {
  90049. /**
  90050. * Gets or sets the gradient value (between 0 and 1)
  90051. */
  90052. gradient: number;
  90053. /**
  90054. * Gets or sets first associated factor
  90055. */
  90056. factor1: number;
  90057. /**
  90058. * Gets or sets second associated factor
  90059. */
  90060. factor2?: number;
  90061. /**
  90062. * Will get a number picked randomly between factor1 and factor2.
  90063. * If factor2 is undefined then factor1 will be used
  90064. * @returns the picked number
  90065. */
  90066. getFactor(): number;
  90067. }
  90068. /**
  90069. * @ignore
  90070. * Application error to support additional information when loading a file
  90071. */
  90072. export class LoadFileError extends Error {
  90073. /** defines the optional web request */
  90074. request?: WebRequest | undefined;
  90075. private static _setPrototypeOf;
  90076. /**
  90077. * Creates a new LoadFileError
  90078. * @param message defines the message of the error
  90079. * @param request defines the optional web request
  90080. */
  90081. constructor(message: string,
  90082. /** defines the optional web request */
  90083. request?: WebRequest | undefined);
  90084. }
  90085. /**
  90086. * Class used to define a retry strategy when error happens while loading assets
  90087. */
  90088. export class RetryStrategy {
  90089. /**
  90090. * Function used to defines an exponential back off strategy
  90091. * @param maxRetries defines the maximum number of retries (3 by default)
  90092. * @param baseInterval defines the interval between retries
  90093. * @returns the strategy function to use
  90094. */
  90095. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90096. }
  90097. /**
  90098. * File request interface
  90099. */
  90100. export interface IFileRequest {
  90101. /**
  90102. * Raised when the request is complete (success or error).
  90103. */
  90104. onCompleteObservable: Observable<IFileRequest>;
  90105. /**
  90106. * Aborts the request for a file.
  90107. */
  90108. abort: () => void;
  90109. }
  90110. /**
  90111. * Class containing a set of static utilities functions
  90112. */
  90113. export class Tools {
  90114. /**
  90115. * Gets or sets the base URL to use to load assets
  90116. */
  90117. static BaseUrl: string;
  90118. /**
  90119. * Enable/Disable Custom HTTP Request Headers globally.
  90120. * default = false
  90121. * @see CustomRequestHeaders
  90122. */
  90123. static UseCustomRequestHeaders: boolean;
  90124. /**
  90125. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90126. * i.e. when loading files, where the server/service expects an Authorization header
  90127. */
  90128. static CustomRequestHeaders: {
  90129. [key: string]: string;
  90130. };
  90131. /**
  90132. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90133. */
  90134. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90135. /**
  90136. * Default behaviour for cors in the application.
  90137. * It can be a string if the expected behavior is identical in the entire app.
  90138. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90139. */
  90140. static CorsBehavior: string | ((url: string | string[]) => string);
  90141. /**
  90142. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90143. * @ignorenaming
  90144. */
  90145. static UseFallbackTexture: boolean;
  90146. /**
  90147. * Use this object to register external classes like custom textures or material
  90148. * to allow the laoders to instantiate them
  90149. */
  90150. static RegisteredExternalClasses: {
  90151. [key: string]: Object;
  90152. };
  90153. /**
  90154. * Texture content used if a texture cannot loaded
  90155. * @ignorenaming
  90156. */
  90157. static fallbackTexture: string;
  90158. /**
  90159. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90160. * @param u defines the coordinate on X axis
  90161. * @param v defines the coordinate on Y axis
  90162. * @param width defines the width of the source data
  90163. * @param height defines the height of the source data
  90164. * @param pixels defines the source byte array
  90165. * @param color defines the output color
  90166. */
  90167. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90168. /**
  90169. * Interpolates between a and b via alpha
  90170. * @param a The lower value (returned when alpha = 0)
  90171. * @param b The upper value (returned when alpha = 1)
  90172. * @param alpha The interpolation-factor
  90173. * @return The mixed value
  90174. */
  90175. static Mix(a: number, b: number, alpha: number): number;
  90176. /**
  90177. * Tries to instantiate a new object from a given class name
  90178. * @param className defines the class name to instantiate
  90179. * @returns the new object or null if the system was not able to do the instantiation
  90180. */
  90181. static Instantiate(className: string): any;
  90182. /**
  90183. * Provides a slice function that will work even on IE
  90184. * @param data defines the array to slice
  90185. * @param start defines the start of the data (optional)
  90186. * @param end defines the end of the data (optional)
  90187. * @returns the new sliced array
  90188. */
  90189. static Slice<T>(data: T, start?: number, end?: number): T;
  90190. /**
  90191. * Polyfill for setImmediate
  90192. * @param action defines the action to execute after the current execution block
  90193. */
  90194. static SetImmediate(action: () => void): void;
  90195. /**
  90196. * Function indicating if a number is an exponent of 2
  90197. * @param value defines the value to test
  90198. * @returns true if the value is an exponent of 2
  90199. */
  90200. static IsExponentOfTwo(value: number): boolean;
  90201. private static _tmpFloatArray;
  90202. /**
  90203. * Returns the nearest 32-bit single precision float representation of a Number
  90204. * @param value A Number. If the parameter is of a different type, it will get converted
  90205. * to a number or to NaN if it cannot be converted
  90206. * @returns number
  90207. */
  90208. static FloatRound(value: number): number;
  90209. /**
  90210. * Find the next highest power of two.
  90211. * @param x Number to start search from.
  90212. * @return Next highest power of two.
  90213. */
  90214. static CeilingPOT(x: number): number;
  90215. /**
  90216. * Find the next lowest power of two.
  90217. * @param x Number to start search from.
  90218. * @return Next lowest power of two.
  90219. */
  90220. static FloorPOT(x: number): number;
  90221. /**
  90222. * Find the nearest power of two.
  90223. * @param x Number to start search from.
  90224. * @return Next nearest power of two.
  90225. */
  90226. static NearestPOT(x: number): number;
  90227. /**
  90228. * Get the closest exponent of two
  90229. * @param value defines the value to approximate
  90230. * @param max defines the maximum value to return
  90231. * @param mode defines how to define the closest value
  90232. * @returns closest exponent of two of the given value
  90233. */
  90234. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90235. /**
  90236. * Extracts the filename from a path
  90237. * @param path defines the path to use
  90238. * @returns the filename
  90239. */
  90240. static GetFilename(path: string): string;
  90241. /**
  90242. * Extracts the "folder" part of a path (everything before the filename).
  90243. * @param uri The URI to extract the info from
  90244. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90245. * @returns The "folder" part of the path
  90246. */
  90247. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90248. /**
  90249. * Extracts text content from a DOM element hierarchy
  90250. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90251. */
  90252. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90253. /**
  90254. * Convert an angle in radians to degrees
  90255. * @param angle defines the angle to convert
  90256. * @returns the angle in degrees
  90257. */
  90258. static ToDegrees(angle: number): number;
  90259. /**
  90260. * Convert an angle in degrees to radians
  90261. * @param angle defines the angle to convert
  90262. * @returns the angle in radians
  90263. */
  90264. static ToRadians(angle: number): number;
  90265. /**
  90266. * Encode a buffer to a base64 string
  90267. * @param buffer defines the buffer to encode
  90268. * @returns the encoded string
  90269. */
  90270. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90271. /**
  90272. * Extracts minimum and maximum values from a list of indexed positions
  90273. * @param positions defines the positions to use
  90274. * @param indices defines the indices to the positions
  90275. * @param indexStart defines the start index
  90276. * @param indexCount defines the end index
  90277. * @param bias defines bias value to add to the result
  90278. * @return minimum and maximum values
  90279. */
  90280. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90281. minimum: Vector3;
  90282. maximum: Vector3;
  90283. };
  90284. /**
  90285. * Extracts minimum and maximum values from a list of positions
  90286. * @param positions defines the positions to use
  90287. * @param start defines the start index in the positions array
  90288. * @param count defines the number of positions to handle
  90289. * @param bias defines bias value to add to the result
  90290. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90291. * @return minimum and maximum values
  90292. */
  90293. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90294. minimum: Vector3;
  90295. maximum: Vector3;
  90296. };
  90297. /**
  90298. * Returns an array if obj is not an array
  90299. * @param obj defines the object to evaluate as an array
  90300. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90301. * @returns either obj directly if obj is an array or a new array containing obj
  90302. */
  90303. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90304. /**
  90305. * Gets the pointer prefix to use
  90306. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90307. */
  90308. static GetPointerPrefix(): string;
  90309. /**
  90310. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90311. * @param func - the function to be called
  90312. * @param requester - the object that will request the next frame. Falls back to window.
  90313. * @returns frame number
  90314. */
  90315. static QueueNewFrame(func: () => void, requester?: any): number;
  90316. /**
  90317. * Ask the browser to promote the current element to fullscreen rendering mode
  90318. * @param element defines the DOM element to promote
  90319. */
  90320. static RequestFullscreen(element: HTMLElement): void;
  90321. /**
  90322. * Asks the browser to exit fullscreen mode
  90323. */
  90324. static ExitFullscreen(): void;
  90325. /**
  90326. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90327. * @param url define the url we are trying
  90328. * @param element define the dom element where to configure the cors policy
  90329. */
  90330. static SetCorsBehavior(url: string | string[], element: {
  90331. crossOrigin: string | null;
  90332. }): void;
  90333. /**
  90334. * Removes unwanted characters from an url
  90335. * @param url defines the url to clean
  90336. * @returns the cleaned url
  90337. */
  90338. static CleanUrl(url: string): string;
  90339. /**
  90340. * Gets or sets a function used to pre-process url before using them to load assets
  90341. */
  90342. static PreprocessUrl: (url: string) => string;
  90343. /**
  90344. * Loads an image as an HTMLImageElement.
  90345. * @param input url string, ArrayBuffer, or Blob to load
  90346. * @param onLoad callback called when the image successfully loads
  90347. * @param onError callback called when the image fails to load
  90348. * @param offlineProvider offline provider for caching
  90349. * @returns the HTMLImageElement of the loaded image
  90350. */
  90351. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90352. /**
  90353. * Loads a file
  90354. * @param url url string, ArrayBuffer, or Blob to load
  90355. * @param onSuccess callback called when the file successfully loads
  90356. * @param onProgress callback called while file is loading (if the server supports this mode)
  90357. * @param offlineProvider defines the offline provider for caching
  90358. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90359. * @param onError callback called when the file fails to load
  90360. * @returns a file request object
  90361. */
  90362. 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;
  90363. /**
  90364. * Load a script (identified by an url). When the url returns, the
  90365. * content of this file is added into a new script element, attached to the DOM (body element)
  90366. * @param scriptUrl defines the url of the script to laod
  90367. * @param onSuccess defines the callback called when the script is loaded
  90368. * @param onError defines the callback to call if an error occurs
  90369. * @param scriptId defines the id of the script element
  90370. */
  90371. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90372. /**
  90373. * Load an asynchronous script (identified by an url). When the url returns, the
  90374. * content of this file is added into a new script element, attached to the DOM (body element)
  90375. * @param scriptUrl defines the url of the script to laod
  90376. * @param scriptId defines the id of the script element
  90377. * @returns a promise request object
  90378. */
  90379. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90380. /**
  90381. * Loads a file from a blob
  90382. * @param fileToLoad defines the blob to use
  90383. * @param callback defines the callback to call when data is loaded
  90384. * @param progressCallback defines the callback to call during loading process
  90385. * @returns a file request object
  90386. */
  90387. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90388. /**
  90389. * Loads a file
  90390. * @param fileToLoad defines the file to load
  90391. * @param callback defines the callback to call when data is loaded
  90392. * @param progressCallBack defines the callback to call during loading process
  90393. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90394. * @returns a file request object
  90395. */
  90396. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90397. /**
  90398. * Creates a data url from a given string content
  90399. * @param content defines the content to convert
  90400. * @returns the new data url link
  90401. */
  90402. static FileAsURL(content: string): string;
  90403. /**
  90404. * Format the given number to a specific decimal format
  90405. * @param value defines the number to format
  90406. * @param decimals defines the number of decimals to use
  90407. * @returns the formatted string
  90408. */
  90409. static Format(value: number, decimals?: number): string;
  90410. /**
  90411. * Checks if a given vector is inside a specific range
  90412. * @param v defines the vector to test
  90413. * @param min defines the minimum range
  90414. * @param max defines the maximum range
  90415. */
  90416. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90417. /**
  90418. * Tries to copy an object by duplicating every property
  90419. * @param source defines the source object
  90420. * @param destination defines the target object
  90421. * @param doNotCopyList defines a list of properties to avoid
  90422. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90423. */
  90424. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90425. /**
  90426. * Gets a boolean indicating if the given object has no own property
  90427. * @param obj defines the object to test
  90428. * @returns true if object has no own property
  90429. */
  90430. static IsEmpty(obj: any): boolean;
  90431. /**
  90432. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90433. * @param str Source string
  90434. * @param suffix Suffix to search for in the source string
  90435. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90436. */
  90437. static EndsWith(str: string, suffix: string): boolean;
  90438. /**
  90439. * Function used to register events at window level
  90440. * @param events defines the events to register
  90441. */
  90442. static RegisterTopRootEvents(events: {
  90443. name: string;
  90444. handler: Nullable<(e: FocusEvent) => any>;
  90445. }[]): void;
  90446. /**
  90447. * Function used to unregister events from window level
  90448. * @param events defines the events to unregister
  90449. */
  90450. static UnregisterTopRootEvents(events: {
  90451. name: string;
  90452. handler: Nullable<(e: FocusEvent) => any>;
  90453. }[]): void;
  90454. /**
  90455. * @ignore
  90456. */
  90457. static _ScreenshotCanvas: HTMLCanvasElement;
  90458. /**
  90459. * Dumps the current bound framebuffer
  90460. * @param width defines the rendering width
  90461. * @param height defines the rendering height
  90462. * @param engine defines the hosting engine
  90463. * @param successCallback defines the callback triggered once the data are available
  90464. * @param mimeType defines the mime type of the result
  90465. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90466. */
  90467. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90468. /**
  90469. * Converts the canvas data to blob.
  90470. * This acts as a polyfill for browsers not supporting the to blob function.
  90471. * @param canvas Defines the canvas to extract the data from
  90472. * @param successCallback Defines the callback triggered once the data are available
  90473. * @param mimeType Defines the mime type of the result
  90474. */
  90475. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90476. /**
  90477. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90478. * @param successCallback defines the callback triggered once the data are available
  90479. * @param mimeType defines the mime type of the result
  90480. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90481. */
  90482. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90483. /**
  90484. * Downloads a blob in the browser
  90485. * @param blob defines the blob to download
  90486. * @param fileName defines the name of the downloaded file
  90487. */
  90488. static Download(blob: Blob, fileName: string): void;
  90489. /**
  90490. * Captures a screenshot of the current rendering
  90491. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90492. * @param engine defines the rendering engine
  90493. * @param camera defines the source camera
  90494. * @param size This parameter can be set to a single number or to an object with the
  90495. * following (optional) properties: precision, width, height. If a single number is passed,
  90496. * it will be used for both width and height. If an object is passed, the screenshot size
  90497. * will be derived from the parameters. The precision property is a multiplier allowing
  90498. * rendering at a higher or lower resolution
  90499. * @param successCallback defines the callback receives a single parameter which contains the
  90500. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90501. * src parameter of an <img> to display it
  90502. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90503. * Check your browser for supported MIME types
  90504. */
  90505. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90506. /**
  90507. * Generates an image screenshot from the specified camera.
  90508. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90509. * @param engine The engine to use for rendering
  90510. * @param camera The camera to use for rendering
  90511. * @param size This parameter can be set to a single number or to an object with the
  90512. * following (optional) properties: precision, width, height. If a single number is passed,
  90513. * it will be used for both width and height. If an object is passed, the screenshot size
  90514. * will be derived from the parameters. The precision property is a multiplier allowing
  90515. * rendering at a higher or lower resolution
  90516. * @param successCallback The callback receives a single parameter which contains the
  90517. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90518. * src parameter of an <img> to display it
  90519. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90520. * Check your browser for supported MIME types
  90521. * @param samples Texture samples (default: 1)
  90522. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90523. * @param fileName A name for for the downloaded file.
  90524. */
  90525. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90526. /**
  90527. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90528. * Be aware Math.random() could cause collisions, but:
  90529. * "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"
  90530. * @returns a pseudo random id
  90531. */
  90532. static RandomId(): string;
  90533. /**
  90534. * Test if the given uri is a base64 string
  90535. * @param uri The uri to test
  90536. * @return True if the uri is a base64 string or false otherwise
  90537. */
  90538. static IsBase64(uri: string): boolean;
  90539. /**
  90540. * Decode the given base64 uri.
  90541. * @param uri The uri to decode
  90542. * @return The decoded base64 data.
  90543. */
  90544. static DecodeBase64(uri: string): ArrayBuffer;
  90545. /**
  90546. * Gets the absolute url.
  90547. * @param url the input url
  90548. * @return the absolute url
  90549. */
  90550. static GetAbsoluteUrl(url: string): string;
  90551. /**
  90552. * No log
  90553. */
  90554. static readonly NoneLogLevel: number;
  90555. /**
  90556. * Only message logs
  90557. */
  90558. static readonly MessageLogLevel: number;
  90559. /**
  90560. * Only warning logs
  90561. */
  90562. static readonly WarningLogLevel: number;
  90563. /**
  90564. * Only error logs
  90565. */
  90566. static readonly ErrorLogLevel: number;
  90567. /**
  90568. * All logs
  90569. */
  90570. static readonly AllLogLevel: number;
  90571. /**
  90572. * Gets a value indicating the number of loading errors
  90573. * @ignorenaming
  90574. */
  90575. static readonly errorsCount: number;
  90576. /**
  90577. * Callback called when a new log is added
  90578. */
  90579. static OnNewCacheEntry: (entry: string) => void;
  90580. /**
  90581. * Log a message to the console
  90582. * @param message defines the message to log
  90583. */
  90584. static Log(message: string): void;
  90585. /**
  90586. * Write a warning message to the console
  90587. * @param message defines the message to log
  90588. */
  90589. static Warn(message: string): void;
  90590. /**
  90591. * Write an error message to the console
  90592. * @param message defines the message to log
  90593. */
  90594. static Error(message: string): void;
  90595. /**
  90596. * Gets current log cache (list of logs)
  90597. */
  90598. static readonly LogCache: string;
  90599. /**
  90600. * Clears the log cache
  90601. */
  90602. static ClearLogCache(): void;
  90603. /**
  90604. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90605. */
  90606. static LogLevels: number;
  90607. /**
  90608. * Checks if the loaded document was accessed via `file:`-Protocol.
  90609. * @returns boolean
  90610. */
  90611. static IsFileURL(): boolean;
  90612. /**
  90613. * Checks if the window object exists
  90614. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90615. */
  90616. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90617. /**
  90618. * No performance log
  90619. */
  90620. static readonly PerformanceNoneLogLevel: number;
  90621. /**
  90622. * Use user marks to log performance
  90623. */
  90624. static readonly PerformanceUserMarkLogLevel: number;
  90625. /**
  90626. * Log performance to the console
  90627. */
  90628. static readonly PerformanceConsoleLogLevel: number;
  90629. private static _performance;
  90630. /**
  90631. * Sets the current performance log level
  90632. */
  90633. static PerformanceLogLevel: number;
  90634. private static _StartPerformanceCounterDisabled;
  90635. private static _EndPerformanceCounterDisabled;
  90636. private static _StartUserMark;
  90637. private static _EndUserMark;
  90638. private static _StartPerformanceConsole;
  90639. private static _EndPerformanceConsole;
  90640. /**
  90641. * Starts a performance counter
  90642. */
  90643. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90644. /**
  90645. * Ends a specific performance coutner
  90646. */
  90647. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90648. /**
  90649. * Gets either window.performance.now() if supported or Date.now() else
  90650. */
  90651. static readonly Now: number;
  90652. /**
  90653. * This method will return the name of the class used to create the instance of the given object.
  90654. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  90655. * @param object the object to get the class name from
  90656. * @param isType defines if the object is actually a type
  90657. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  90658. */
  90659. static GetClassName(object: any, isType?: boolean): string;
  90660. /**
  90661. * Gets the first element of an array satisfying a given predicate
  90662. * @param array defines the array to browse
  90663. * @param predicate defines the predicate to use
  90664. * @returns null if not found or the element
  90665. */
  90666. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  90667. /**
  90668. * This method will return the name of the full name of the class, including its owning module (if any).
  90669. * 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).
  90670. * @param object the object to get the class name from
  90671. * @param isType defines if the object is actually a type
  90672. * @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.
  90673. * @ignorenaming
  90674. */
  90675. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  90676. /**
  90677. * Returns a promise that resolves after the given amount of time.
  90678. * @param delay Number of milliseconds to delay
  90679. * @returns Promise that resolves after the given amount of time
  90680. */
  90681. static DelayAsync(delay: number): Promise<void>;
  90682. /**
  90683. * Gets the current gradient from an array of IValueGradient
  90684. * @param ratio defines the current ratio to get
  90685. * @param gradients defines the array of IValueGradient
  90686. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90687. */
  90688. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90689. }
  90690. /**
  90691. * This class is used to track a performance counter which is number based.
  90692. * The user has access to many properties which give statistics of different nature.
  90693. *
  90694. * The implementer can track two kinds of Performance Counter: time and count.
  90695. * 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.
  90696. * 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.
  90697. */
  90698. export class PerfCounter {
  90699. /**
  90700. * Gets or sets a global boolean to turn on and off all the counters
  90701. */
  90702. static Enabled: boolean;
  90703. /**
  90704. * Returns the smallest value ever
  90705. */
  90706. readonly min: number;
  90707. /**
  90708. * Returns the biggest value ever
  90709. */
  90710. readonly max: number;
  90711. /**
  90712. * Returns the average value since the performance counter is running
  90713. */
  90714. readonly average: number;
  90715. /**
  90716. * Returns the average value of the last second the counter was monitored
  90717. */
  90718. readonly lastSecAverage: number;
  90719. /**
  90720. * Returns the current value
  90721. */
  90722. readonly current: number;
  90723. /**
  90724. * Gets the accumulated total
  90725. */
  90726. readonly total: number;
  90727. /**
  90728. * Gets the total value count
  90729. */
  90730. readonly count: number;
  90731. /**
  90732. * Creates a new counter
  90733. */
  90734. constructor();
  90735. /**
  90736. * Call this method to start monitoring a new frame.
  90737. * 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.
  90738. */
  90739. fetchNewFrame(): void;
  90740. /**
  90741. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  90742. * @param newCount the count value to add to the monitored count
  90743. * @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.
  90744. */
  90745. addCount(newCount: number, fetchResult: boolean): void;
  90746. /**
  90747. * Start monitoring this performance counter
  90748. */
  90749. beginMonitoring(): void;
  90750. /**
  90751. * Compute the time lapsed since the previous beginMonitoring() call.
  90752. * @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
  90753. */
  90754. endMonitoring(newFrame?: boolean): void;
  90755. private _fetchResult;
  90756. private _startMonitoringTime;
  90757. private _min;
  90758. private _max;
  90759. private _average;
  90760. private _current;
  90761. private _totalValueCount;
  90762. private _totalAccumulated;
  90763. private _lastSecAverage;
  90764. private _lastSecAccumulated;
  90765. private _lastSecTime;
  90766. private _lastSecValueCount;
  90767. }
  90768. /**
  90769. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  90770. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  90771. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  90772. * @param name The name of the class, case should be preserved
  90773. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90774. */
  90775. export function className(name: string, module?: string): (target: Object) => void;
  90776. /**
  90777. * An implementation of a loop for asynchronous functions.
  90778. */
  90779. export class AsyncLoop {
  90780. /**
  90781. * Defines the number of iterations for the loop
  90782. */
  90783. iterations: number;
  90784. /**
  90785. * Defines the current index of the loop.
  90786. */
  90787. index: number;
  90788. private _done;
  90789. private _fn;
  90790. private _successCallback;
  90791. /**
  90792. * Constructor.
  90793. * @param iterations the number of iterations.
  90794. * @param func the function to run each iteration
  90795. * @param successCallback the callback that will be called upon succesful execution
  90796. * @param offset starting offset.
  90797. */
  90798. constructor(
  90799. /**
  90800. * Defines the number of iterations for the loop
  90801. */
  90802. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  90803. /**
  90804. * Execute the next iteration. Must be called after the last iteration was finished.
  90805. */
  90806. executeNext(): void;
  90807. /**
  90808. * Break the loop and run the success callback.
  90809. */
  90810. breakLoop(): void;
  90811. /**
  90812. * Create and run an async loop.
  90813. * @param iterations the number of iterations.
  90814. * @param fn the function to run each iteration
  90815. * @param successCallback the callback that will be called upon succesful execution
  90816. * @param offset starting offset.
  90817. * @returns the created async loop object
  90818. */
  90819. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  90820. /**
  90821. * A for-loop that will run a given number of iterations synchronous and the rest async.
  90822. * @param iterations total number of iterations
  90823. * @param syncedIterations number of synchronous iterations in each async iteration.
  90824. * @param fn the function to call each iteration.
  90825. * @param callback a success call back that will be called when iterating stops.
  90826. * @param breakFunction a break condition (optional)
  90827. * @param timeout timeout settings for the setTimeout function. default - 0.
  90828. * @returns the created async loop object
  90829. */
  90830. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  90831. }
  90832. }
  90833. declare module BABYLON {
  90834. /** @hidden */
  90835. export interface ICollisionCoordinator {
  90836. createCollider(): Collider;
  90837. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90838. init(scene: Scene): void;
  90839. }
  90840. /** @hidden */
  90841. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  90842. private _scene;
  90843. private _scaledPosition;
  90844. private _scaledVelocity;
  90845. private _finalPosition;
  90846. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90847. createCollider(): Collider;
  90848. init(scene: Scene): void;
  90849. private _collideWithWorld;
  90850. }
  90851. }
  90852. declare module BABYLON {
  90853. /**
  90854. * This class defines the direct association between an animation and a target
  90855. */
  90856. export class TargetedAnimation {
  90857. /**
  90858. * Animation to perform
  90859. */
  90860. animation: Animation;
  90861. /**
  90862. * Target to animate
  90863. */
  90864. target: any;
  90865. }
  90866. /**
  90867. * Use this class to create coordinated animations on multiple targets
  90868. */
  90869. export class AnimationGroup implements IDisposable {
  90870. /** The name of the animation group */
  90871. name: string;
  90872. private _scene;
  90873. private _targetedAnimations;
  90874. private _animatables;
  90875. private _from;
  90876. private _to;
  90877. private _isStarted;
  90878. private _isPaused;
  90879. private _speedRatio;
  90880. /**
  90881. * Gets or sets the unique id of the node
  90882. */
  90883. uniqueId: number;
  90884. /**
  90885. * This observable will notify when one animation have ended
  90886. */
  90887. onAnimationEndObservable: Observable<TargetedAnimation>;
  90888. /**
  90889. * Observer raised when one animation loops
  90890. */
  90891. onAnimationLoopObservable: Observable<TargetedAnimation>;
  90892. /**
  90893. * This observable will notify when all animations have ended.
  90894. */
  90895. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  90896. /**
  90897. * This observable will notify when all animations have paused.
  90898. */
  90899. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  90900. /**
  90901. * This observable will notify when all animations are playing.
  90902. */
  90903. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  90904. /**
  90905. * Gets the first frame
  90906. */
  90907. readonly from: number;
  90908. /**
  90909. * Gets the last frame
  90910. */
  90911. readonly to: number;
  90912. /**
  90913. * Define if the animations are started
  90914. */
  90915. readonly isStarted: boolean;
  90916. /**
  90917. * Gets a value indicating that the current group is playing
  90918. */
  90919. readonly isPlaying: boolean;
  90920. /**
  90921. * Gets or sets the speed ratio to use for all animations
  90922. */
  90923. /**
  90924. * Gets or sets the speed ratio to use for all animations
  90925. */
  90926. speedRatio: number;
  90927. /**
  90928. * Gets the targeted animations for this animation group
  90929. */
  90930. readonly targetedAnimations: Array<TargetedAnimation>;
  90931. /**
  90932. * returning the list of animatables controlled by this animation group.
  90933. */
  90934. readonly animatables: Array<Animatable>;
  90935. /**
  90936. * Instantiates a new Animation Group.
  90937. * This helps managing several animations at once.
  90938. * @see http://doc.babylonjs.com/how_to/group
  90939. * @param name Defines the name of the group
  90940. * @param scene Defines the scene the group belongs to
  90941. */
  90942. constructor(
  90943. /** The name of the animation group */
  90944. name: string, scene?: Nullable<Scene>);
  90945. /**
  90946. * Add an animation (with its target) in the group
  90947. * @param animation defines the animation we want to add
  90948. * @param target defines the target of the animation
  90949. * @returns the TargetedAnimation object
  90950. */
  90951. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  90952. /**
  90953. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  90954. * It can add constant keys at begin or end
  90955. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  90956. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  90957. * @returns the animation group
  90958. */
  90959. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  90960. /**
  90961. * Start all animations on given targets
  90962. * @param loop defines if animations must loop
  90963. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  90964. * @param from defines the from key (optional)
  90965. * @param to defines the to key (optional)
  90966. * @returns the current animation group
  90967. */
  90968. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  90969. /**
  90970. * Pause all animations
  90971. * @returns the animation group
  90972. */
  90973. pause(): AnimationGroup;
  90974. /**
  90975. * Play all animations to initial state
  90976. * This function will start() the animations if they were not started or will restart() them if they were paused
  90977. * @param loop defines if animations must loop
  90978. * @returns the animation group
  90979. */
  90980. play(loop?: boolean): AnimationGroup;
  90981. /**
  90982. * Reset all animations to initial state
  90983. * @returns the animation group
  90984. */
  90985. reset(): AnimationGroup;
  90986. /**
  90987. * Restart animations from key 0
  90988. * @returns the animation group
  90989. */
  90990. restart(): AnimationGroup;
  90991. /**
  90992. * Stop all animations
  90993. * @returns the animation group
  90994. */
  90995. stop(): AnimationGroup;
  90996. /**
  90997. * Set animation weight for all animatables
  90998. * @param weight defines the weight to use
  90999. * @return the animationGroup
  91000. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91001. */
  91002. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91003. /**
  91004. * Synchronize and normalize all animatables with a source animatable
  91005. * @param root defines the root animatable to synchronize with
  91006. * @return the animationGroup
  91007. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91008. */
  91009. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91010. /**
  91011. * Goes to a specific frame in this animation group
  91012. * @param frame the frame number to go to
  91013. * @return the animationGroup
  91014. */
  91015. goToFrame(frame: number): AnimationGroup;
  91016. /**
  91017. * Dispose all associated resources
  91018. */
  91019. dispose(): void;
  91020. private _checkAnimationGroupEnded;
  91021. /**
  91022. * Clone the current animation group and returns a copy
  91023. * @param newName defines the name of the new group
  91024. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91025. * @returns the new aniamtion group
  91026. */
  91027. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91028. /**
  91029. * Returns a new AnimationGroup object parsed from the source provided.
  91030. * @param parsedAnimationGroup defines the source
  91031. * @param scene defines the scene that will receive the animationGroup
  91032. * @returns a new AnimationGroup
  91033. */
  91034. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91035. /**
  91036. * Returns the string "AnimationGroup"
  91037. * @returns "AnimationGroup"
  91038. */
  91039. getClassName(): string;
  91040. /**
  91041. * Creates a detailled string about the object
  91042. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91043. * @returns a string representing the object
  91044. */
  91045. toString(fullDetails?: boolean): string;
  91046. }
  91047. }
  91048. declare module BABYLON {
  91049. /**
  91050. * Define an interface for all classes that will hold resources
  91051. */
  91052. export interface IDisposable {
  91053. /**
  91054. * Releases all held resources
  91055. */
  91056. dispose(): void;
  91057. }
  91058. /** Interface defining initialization parameters for Scene class */
  91059. export interface SceneOptions {
  91060. /**
  91061. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91062. * It will improve performance when the number of geometries becomes important.
  91063. */
  91064. useGeometryUniqueIdsMap?: boolean;
  91065. /**
  91066. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91067. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91068. */
  91069. useMaterialMeshMap?: boolean;
  91070. /**
  91071. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91072. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91073. */
  91074. useClonedMeshhMap?: boolean;
  91075. }
  91076. /**
  91077. * Represents a scene to be rendered by the engine.
  91078. * @see http://doc.babylonjs.com/features/scene
  91079. */
  91080. export class Scene extends AbstractScene implements IAnimatable {
  91081. private static _uniqueIdCounter;
  91082. /** The fog is deactivated */
  91083. static readonly FOGMODE_NONE: number;
  91084. /** The fog density is following an exponential function */
  91085. static readonly FOGMODE_EXP: number;
  91086. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91087. static readonly FOGMODE_EXP2: number;
  91088. /** The fog density is following a linear function. */
  91089. static readonly FOGMODE_LINEAR: number;
  91090. /**
  91091. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91092. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91093. */
  91094. static MinDeltaTime: number;
  91095. /**
  91096. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91097. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91098. */
  91099. static MaxDeltaTime: number;
  91100. /**
  91101. * Factory used to create the default material.
  91102. * @param name The name of the material to create
  91103. * @param scene The scene to create the material for
  91104. * @returns The default material
  91105. */
  91106. static DefaultMaterialFactory(scene: Scene): Material;
  91107. /**
  91108. * Factory used to create the a collision coordinator.
  91109. * @returns The collision coordinator
  91110. */
  91111. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91112. /** @hidden */
  91113. readonly _isScene: boolean;
  91114. /**
  91115. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91116. */
  91117. autoClear: boolean;
  91118. /**
  91119. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91120. */
  91121. autoClearDepthAndStencil: boolean;
  91122. /**
  91123. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91124. */
  91125. clearColor: Color4;
  91126. /**
  91127. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91128. */
  91129. ambientColor: Color3;
  91130. /**
  91131. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91132. * It should only be one of the following (if not the default embedded one):
  91133. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91134. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91135. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91136. * The material properties need to be setup according to the type of texture in use.
  91137. */
  91138. environmentBRDFTexture: BaseTexture;
  91139. /** @hidden */
  91140. protected _environmentTexture: Nullable<BaseTexture>;
  91141. /**
  91142. * Texture used in all pbr material as the reflection texture.
  91143. * As in the majority of the scene they are the same (exception for multi room and so on),
  91144. * this is easier to reference from here than from all the materials.
  91145. */
  91146. /**
  91147. * Texture used in all pbr material as the reflection texture.
  91148. * As in the majority of the scene they are the same (exception for multi room and so on),
  91149. * this is easier to set here than in all the materials.
  91150. */
  91151. environmentTexture: Nullable<BaseTexture>;
  91152. /** @hidden */
  91153. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91154. /**
  91155. * Default image processing configuration used either in the rendering
  91156. * Forward main pass or through the imageProcessingPostProcess if present.
  91157. * As in the majority of the scene they are the same (exception for multi camera),
  91158. * this is easier to reference from here than from all the materials and post process.
  91159. *
  91160. * No setter as we it is a shared configuration, you can set the values instead.
  91161. */
  91162. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91163. private _forceWireframe;
  91164. /**
  91165. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91166. */
  91167. forceWireframe: boolean;
  91168. private _forcePointsCloud;
  91169. /**
  91170. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91171. */
  91172. forcePointsCloud: boolean;
  91173. /**
  91174. * Gets or sets the active clipplane 1
  91175. */
  91176. clipPlane: Nullable<Plane>;
  91177. /**
  91178. * Gets or sets the active clipplane 2
  91179. */
  91180. clipPlane2: Nullable<Plane>;
  91181. /**
  91182. * Gets or sets the active clipplane 3
  91183. */
  91184. clipPlane3: Nullable<Plane>;
  91185. /**
  91186. * Gets or sets the active clipplane 4
  91187. */
  91188. clipPlane4: Nullable<Plane>;
  91189. /**
  91190. * Gets or sets a boolean indicating if animations are enabled
  91191. */
  91192. animationsEnabled: boolean;
  91193. private _animationPropertiesOverride;
  91194. /**
  91195. * Gets or sets the animation properties override
  91196. */
  91197. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91198. /**
  91199. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91200. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91201. */
  91202. useConstantAnimationDeltaTime: boolean;
  91203. /**
  91204. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91205. * Please note that it requires to run a ray cast through the scene on every frame
  91206. */
  91207. constantlyUpdateMeshUnderPointer: boolean;
  91208. /**
  91209. * Defines the HTML cursor to use when hovering over interactive elements
  91210. */
  91211. hoverCursor: string;
  91212. /**
  91213. * Defines the HTML default cursor to use (empty by default)
  91214. */
  91215. defaultCursor: string;
  91216. /**
  91217. * This is used to call preventDefault() on pointer down
  91218. * in order to block unwanted artifacts like system double clicks
  91219. */
  91220. preventDefaultOnPointerDown: boolean;
  91221. /**
  91222. * This is used to call preventDefault() on pointer up
  91223. * in order to block unwanted artifacts like system double clicks
  91224. */
  91225. preventDefaultOnPointerUp: boolean;
  91226. /**
  91227. * Gets or sets user defined metadata
  91228. */
  91229. metadata: any;
  91230. /**
  91231. * For internal use only. Please do not use.
  91232. */
  91233. reservedDataStore: any;
  91234. /**
  91235. * Gets the name of the plugin used to load this scene (null by default)
  91236. */
  91237. loadingPluginName: string;
  91238. /**
  91239. * Use this array to add regular expressions used to disable offline support for specific urls
  91240. */
  91241. disableOfflineSupportExceptionRules: RegExp[];
  91242. /**
  91243. * An event triggered when the scene is disposed.
  91244. */
  91245. onDisposeObservable: Observable<Scene>;
  91246. private _onDisposeObserver;
  91247. /** Sets a function to be executed when this scene is disposed. */
  91248. onDispose: () => void;
  91249. /**
  91250. * An event triggered before rendering the scene (right after animations and physics)
  91251. */
  91252. onBeforeRenderObservable: Observable<Scene>;
  91253. private _onBeforeRenderObserver;
  91254. /** Sets a function to be executed before rendering this scene */
  91255. beforeRender: Nullable<() => void>;
  91256. /**
  91257. * An event triggered after rendering the scene
  91258. */
  91259. onAfterRenderObservable: Observable<Scene>;
  91260. private _onAfterRenderObserver;
  91261. /** Sets a function to be executed after rendering this scene */
  91262. afterRender: Nullable<() => void>;
  91263. /**
  91264. * An event triggered before animating the scene
  91265. */
  91266. onBeforeAnimationsObservable: Observable<Scene>;
  91267. /**
  91268. * An event triggered after animations processing
  91269. */
  91270. onAfterAnimationsObservable: Observable<Scene>;
  91271. /**
  91272. * An event triggered before draw calls are ready to be sent
  91273. */
  91274. onBeforeDrawPhaseObservable: Observable<Scene>;
  91275. /**
  91276. * An event triggered after draw calls have been sent
  91277. */
  91278. onAfterDrawPhaseObservable: Observable<Scene>;
  91279. /**
  91280. * An event triggered when the scene is ready
  91281. */
  91282. onReadyObservable: Observable<Scene>;
  91283. /**
  91284. * An event triggered before rendering a camera
  91285. */
  91286. onBeforeCameraRenderObservable: Observable<Camera>;
  91287. private _onBeforeCameraRenderObserver;
  91288. /** Sets a function to be executed before rendering a camera*/
  91289. beforeCameraRender: () => void;
  91290. /**
  91291. * An event triggered after rendering a camera
  91292. */
  91293. onAfterCameraRenderObservable: Observable<Camera>;
  91294. private _onAfterCameraRenderObserver;
  91295. /** Sets a function to be executed after rendering a camera*/
  91296. afterCameraRender: () => void;
  91297. /**
  91298. * An event triggered when active meshes evaluation is about to start
  91299. */
  91300. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  91301. /**
  91302. * An event triggered when active meshes evaluation is done
  91303. */
  91304. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  91305. /**
  91306. * An event triggered when particles rendering is about to start
  91307. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91308. */
  91309. onBeforeParticlesRenderingObservable: Observable<Scene>;
  91310. /**
  91311. * An event triggered when particles rendering is done
  91312. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91313. */
  91314. onAfterParticlesRenderingObservable: Observable<Scene>;
  91315. /**
  91316. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  91317. */
  91318. onDataLoadedObservable: Observable<Scene>;
  91319. /**
  91320. * An event triggered when a camera is created
  91321. */
  91322. onNewCameraAddedObservable: Observable<Camera>;
  91323. /**
  91324. * An event triggered when a camera is removed
  91325. */
  91326. onCameraRemovedObservable: Observable<Camera>;
  91327. /**
  91328. * An event triggered when a light is created
  91329. */
  91330. onNewLightAddedObservable: Observable<Light>;
  91331. /**
  91332. * An event triggered when a light is removed
  91333. */
  91334. onLightRemovedObservable: Observable<Light>;
  91335. /**
  91336. * An event triggered when a geometry is created
  91337. */
  91338. onNewGeometryAddedObservable: Observable<Geometry>;
  91339. /**
  91340. * An event triggered when a geometry is removed
  91341. */
  91342. onGeometryRemovedObservable: Observable<Geometry>;
  91343. /**
  91344. * An event triggered when a transform node is created
  91345. */
  91346. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  91347. /**
  91348. * An event triggered when a transform node is removed
  91349. */
  91350. onTransformNodeRemovedObservable: Observable<TransformNode>;
  91351. /**
  91352. * An event triggered when a mesh is created
  91353. */
  91354. onNewMeshAddedObservable: Observable<AbstractMesh>;
  91355. /**
  91356. * An event triggered when a mesh is removed
  91357. */
  91358. onMeshRemovedObservable: Observable<AbstractMesh>;
  91359. /**
  91360. * An event triggered when a skeleton is created
  91361. */
  91362. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91363. /**
  91364. * An event triggered when a skeleton is removed
  91365. */
  91366. onSkeletonRemovedObservable: Observable<Skeleton>;
  91367. /**
  91368. * An event triggered when a material is created
  91369. */
  91370. onNewMaterialAddedObservable: Observable<Material>;
  91371. /**
  91372. * An event triggered when a material is removed
  91373. */
  91374. onMaterialRemovedObservable: Observable<Material>;
  91375. /**
  91376. * An event triggered when a texture is created
  91377. */
  91378. onNewTextureAddedObservable: Observable<BaseTexture>;
  91379. /**
  91380. * An event triggered when a texture is removed
  91381. */
  91382. onTextureRemovedObservable: Observable<BaseTexture>;
  91383. /**
  91384. * An event triggered when render targets are about to be rendered
  91385. * Can happen multiple times per frame.
  91386. */
  91387. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91388. /**
  91389. * An event triggered when render targets were rendered.
  91390. * Can happen multiple times per frame.
  91391. */
  91392. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91393. /**
  91394. * An event triggered before calculating deterministic simulation step
  91395. */
  91396. onBeforeStepObservable: Observable<Scene>;
  91397. /**
  91398. * An event triggered after calculating deterministic simulation step
  91399. */
  91400. onAfterStepObservable: Observable<Scene>;
  91401. /**
  91402. * An event triggered when the activeCamera property is updated
  91403. */
  91404. onActiveCameraChanged: Observable<Scene>;
  91405. /**
  91406. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91407. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91408. * 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)
  91409. */
  91410. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91411. /**
  91412. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91413. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91414. * 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)
  91415. */
  91416. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91417. /**
  91418. * This Observable will when a mesh has been imported into the scene.
  91419. */
  91420. onMeshImportedObservable: Observable<AbstractMesh>;
  91421. /**
  91422. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91423. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91424. */
  91425. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91426. /** @hidden */
  91427. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91428. /**
  91429. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91430. */
  91431. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91432. /**
  91433. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91434. */
  91435. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91436. /**
  91437. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91438. */
  91439. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91440. private _onPointerMove;
  91441. private _onPointerDown;
  91442. private _onPointerUp;
  91443. /** Callback called when a pointer move is detected */
  91444. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91445. /** Callback called when a pointer down is detected */
  91446. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91447. /** Callback called when a pointer up is detected */
  91448. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91449. /** Callback called when a pointer pick is detected */
  91450. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91451. /**
  91452. * 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).
  91453. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91454. */
  91455. onPrePointerObservable: Observable<PointerInfoPre>;
  91456. /**
  91457. * Observable event triggered each time an input event is received from the rendering canvas
  91458. */
  91459. onPointerObservable: Observable<PointerInfo>;
  91460. /**
  91461. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91462. */
  91463. readonly unTranslatedPointer: Vector2;
  91464. /** The distance in pixel that you have to move to prevent some events */
  91465. static DragMovementThreshold: number;
  91466. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91467. static LongPressDelay: number;
  91468. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91469. static DoubleClickDelay: number;
  91470. /** If you need to check double click without raising a single click at first click, enable this flag */
  91471. static ExclusiveDoubleClickMode: boolean;
  91472. private _initClickEvent;
  91473. private _initActionManager;
  91474. private _delayedSimpleClick;
  91475. private _delayedSimpleClickTimeout;
  91476. private _previousDelayedSimpleClickTimeout;
  91477. private _meshPickProceed;
  91478. private _previousButtonPressed;
  91479. private _currentPickResult;
  91480. private _previousPickResult;
  91481. private _totalPointersPressed;
  91482. private _doubleClickOccured;
  91483. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91484. cameraToUseForPointers: Nullable<Camera>;
  91485. private _pointerX;
  91486. private _pointerY;
  91487. private _unTranslatedPointerX;
  91488. private _unTranslatedPointerY;
  91489. private _startingPointerPosition;
  91490. private _previousStartingPointerPosition;
  91491. private _startingPointerTime;
  91492. private _previousStartingPointerTime;
  91493. private _pointerCaptures;
  91494. private _timeAccumulator;
  91495. private _currentStepId;
  91496. private _currentInternalStep;
  91497. /** @hidden */
  91498. _mirroredCameraPosition: Nullable<Vector3>;
  91499. /**
  91500. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91501. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91502. */
  91503. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91504. /**
  91505. * Observable event triggered each time an keyboard event is received from the hosting window
  91506. */
  91507. onKeyboardObservable: Observable<KeyboardInfo>;
  91508. private _onKeyDown;
  91509. private _onKeyUp;
  91510. private _onCanvasFocusObserver;
  91511. private _onCanvasBlurObserver;
  91512. private _useRightHandedSystem;
  91513. /**
  91514. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91515. */
  91516. useRightHandedSystem: boolean;
  91517. /**
  91518. * Sets the step Id used by deterministic lock step
  91519. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91520. * @param newStepId defines the step Id
  91521. */
  91522. setStepId(newStepId: number): void;
  91523. /**
  91524. * Gets the step Id used by deterministic lock step
  91525. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91526. * @returns the step Id
  91527. */
  91528. getStepId(): number;
  91529. /**
  91530. * Gets the internal step used by deterministic lock step
  91531. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91532. * @returns the internal step
  91533. */
  91534. getInternalStep(): number;
  91535. private _fogEnabled;
  91536. /**
  91537. * Gets or sets a boolean indicating if fog is enabled on this scene
  91538. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91539. * (Default is true)
  91540. */
  91541. fogEnabled: boolean;
  91542. private _fogMode;
  91543. /**
  91544. * Gets or sets the fog mode to use
  91545. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91546. * | mode | value |
  91547. * | --- | --- |
  91548. * | FOGMODE_NONE | 0 |
  91549. * | FOGMODE_EXP | 1 |
  91550. * | FOGMODE_EXP2 | 2 |
  91551. * | FOGMODE_LINEAR | 3 |
  91552. */
  91553. fogMode: number;
  91554. /**
  91555. * Gets or sets the fog color to use
  91556. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91557. * (Default is Color3(0.2, 0.2, 0.3))
  91558. */
  91559. fogColor: Color3;
  91560. /**
  91561. * Gets or sets the fog density to use
  91562. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91563. * (Default is 0.1)
  91564. */
  91565. fogDensity: number;
  91566. /**
  91567. * Gets or sets the fog start distance to use
  91568. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91569. * (Default is 0)
  91570. */
  91571. fogStart: number;
  91572. /**
  91573. * Gets or sets the fog end distance to use
  91574. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91575. * (Default is 1000)
  91576. */
  91577. fogEnd: number;
  91578. private _shadowsEnabled;
  91579. /**
  91580. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91581. */
  91582. shadowsEnabled: boolean;
  91583. private _lightsEnabled;
  91584. /**
  91585. * Gets or sets a boolean indicating if lights are enabled on this scene
  91586. */
  91587. lightsEnabled: boolean;
  91588. /** All of the active cameras added to this scene. */
  91589. activeCameras: Camera[];
  91590. /** @hidden */
  91591. _activeCamera: Nullable<Camera>;
  91592. /** Gets or sets the current active camera */
  91593. activeCamera: Nullable<Camera>;
  91594. private _defaultMaterial;
  91595. /** The default material used on meshes when no material is affected */
  91596. /** The default material used on meshes when no material is affected */
  91597. defaultMaterial: Material;
  91598. private _texturesEnabled;
  91599. /**
  91600. * Gets or sets a boolean indicating if textures are enabled on this scene
  91601. */
  91602. texturesEnabled: boolean;
  91603. /**
  91604. * Gets or sets a boolean indicating if particles are enabled on this scene
  91605. */
  91606. particlesEnabled: boolean;
  91607. /**
  91608. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91609. */
  91610. spritesEnabled: boolean;
  91611. private _skeletonsEnabled;
  91612. /**
  91613. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91614. */
  91615. skeletonsEnabled: boolean;
  91616. /**
  91617. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91618. */
  91619. lensFlaresEnabled: boolean;
  91620. /**
  91621. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91622. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91623. */
  91624. collisionsEnabled: boolean;
  91625. private _collisionCoordinator;
  91626. /** @hidden */
  91627. readonly collisionCoordinator: ICollisionCoordinator;
  91628. /**
  91629. * Defines the gravity applied to this scene (used only for collisions)
  91630. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91631. */
  91632. gravity: Vector3;
  91633. /**
  91634. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91635. */
  91636. postProcessesEnabled: boolean;
  91637. /**
  91638. * The list of postprocesses added to the scene
  91639. */
  91640. postProcesses: PostProcess[];
  91641. /**
  91642. * Gets the current postprocess manager
  91643. */
  91644. postProcessManager: PostProcessManager;
  91645. /**
  91646. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91647. */
  91648. renderTargetsEnabled: boolean;
  91649. /**
  91650. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  91651. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  91652. */
  91653. dumpNextRenderTargets: boolean;
  91654. /**
  91655. * The list of user defined render targets added to the scene
  91656. */
  91657. customRenderTargets: RenderTargetTexture[];
  91658. /**
  91659. * Defines if texture loading must be delayed
  91660. * If true, textures will only be loaded when they need to be rendered
  91661. */
  91662. useDelayedTextureLoading: boolean;
  91663. /**
  91664. * Gets the list of meshes imported to the scene through SceneLoader
  91665. */
  91666. importedMeshesFiles: String[];
  91667. /**
  91668. * Gets or sets a boolean indicating if probes are enabled on this scene
  91669. */
  91670. probesEnabled: boolean;
  91671. /**
  91672. * Gets or sets the current offline provider to use to store scene data
  91673. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  91674. */
  91675. offlineProvider: IOfflineProvider;
  91676. /**
  91677. * Gets or sets the action manager associated with the scene
  91678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91679. */
  91680. actionManager: AbstractActionManager;
  91681. private _meshesForIntersections;
  91682. /**
  91683. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  91684. */
  91685. proceduralTexturesEnabled: boolean;
  91686. private _engine;
  91687. private _totalVertices;
  91688. /** @hidden */
  91689. _activeIndices: PerfCounter;
  91690. /** @hidden */
  91691. _activeParticles: PerfCounter;
  91692. /** @hidden */
  91693. _activeBones: PerfCounter;
  91694. private _animationRatio;
  91695. /** @hidden */
  91696. _animationTimeLast: number;
  91697. /** @hidden */
  91698. _animationTime: number;
  91699. /**
  91700. * Gets or sets a general scale for animation speed
  91701. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  91702. */
  91703. animationTimeScale: number;
  91704. /** @hidden */
  91705. _cachedMaterial: Nullable<Material>;
  91706. /** @hidden */
  91707. _cachedEffect: Nullable<Effect>;
  91708. /** @hidden */
  91709. _cachedVisibility: Nullable<number>;
  91710. private _renderId;
  91711. private _frameId;
  91712. private _executeWhenReadyTimeoutId;
  91713. private _intermediateRendering;
  91714. private _viewUpdateFlag;
  91715. private _projectionUpdateFlag;
  91716. /** @hidden */
  91717. _toBeDisposed: Nullable<IDisposable>[];
  91718. private _activeRequests;
  91719. /** @hidden */
  91720. _pendingData: any[];
  91721. private _isDisposed;
  91722. /**
  91723. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  91724. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  91725. */
  91726. dispatchAllSubMeshesOfActiveMeshes: boolean;
  91727. private _activeMeshes;
  91728. private _processedMaterials;
  91729. private _renderTargets;
  91730. /** @hidden */
  91731. _activeParticleSystems: SmartArray<IParticleSystem>;
  91732. private _activeSkeletons;
  91733. private _softwareSkinnedMeshes;
  91734. private _renderingManager;
  91735. /** @hidden */
  91736. _activeAnimatables: Animatable[];
  91737. private _transformMatrix;
  91738. private _sceneUbo;
  91739. /** @hidden */
  91740. _viewMatrix: Matrix;
  91741. private _projectionMatrix;
  91742. private _wheelEventName;
  91743. /** @hidden */
  91744. _forcedViewPosition: Nullable<Vector3>;
  91745. /** @hidden */
  91746. _frustumPlanes: Plane[];
  91747. /**
  91748. * Gets the list of frustum planes (built from the active camera)
  91749. */
  91750. readonly frustumPlanes: Plane[];
  91751. /**
  91752. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  91753. * This is useful if there are more lights that the maximum simulteanous authorized
  91754. */
  91755. requireLightSorting: boolean;
  91756. /** @hidden */
  91757. readonly useMaterialMeshMap: boolean;
  91758. /** @hidden */
  91759. readonly useClonedMeshhMap: boolean;
  91760. private _pointerOverMesh;
  91761. private _pickedDownMesh;
  91762. private _pickedUpMesh;
  91763. private _externalData;
  91764. private _uid;
  91765. /**
  91766. * @hidden
  91767. * Backing store of defined scene components.
  91768. */
  91769. _components: ISceneComponent[];
  91770. /**
  91771. * @hidden
  91772. * Backing store of defined scene components.
  91773. */
  91774. _serializableComponents: ISceneSerializableComponent[];
  91775. /**
  91776. * List of components to register on the next registration step.
  91777. */
  91778. private _transientComponents;
  91779. /**
  91780. * Registers the transient components if needed.
  91781. */
  91782. private _registerTransientComponents;
  91783. /**
  91784. * @hidden
  91785. * Add a component to the scene.
  91786. * Note that the ccomponent could be registered on th next frame if this is called after
  91787. * the register component stage.
  91788. * @param component Defines the component to add to the scene
  91789. */
  91790. _addComponent(component: ISceneComponent): void;
  91791. /**
  91792. * @hidden
  91793. * Gets a component from the scene.
  91794. * @param name defines the name of the component to retrieve
  91795. * @returns the component or null if not present
  91796. */
  91797. _getComponent(name: string): Nullable<ISceneComponent>;
  91798. /**
  91799. * @hidden
  91800. * Defines the actions happening before camera updates.
  91801. */
  91802. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  91803. /**
  91804. * @hidden
  91805. * Defines the actions happening before clear the canvas.
  91806. */
  91807. _beforeClearStage: Stage<SimpleStageAction>;
  91808. /**
  91809. * @hidden
  91810. * Defines the actions when collecting render targets for the frame.
  91811. */
  91812. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91813. /**
  91814. * @hidden
  91815. * Defines the actions happening for one camera in the frame.
  91816. */
  91817. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91818. /**
  91819. * @hidden
  91820. * Defines the actions happening during the per mesh ready checks.
  91821. */
  91822. _isReadyForMeshStage: Stage<MeshStageAction>;
  91823. /**
  91824. * @hidden
  91825. * Defines the actions happening before evaluate active mesh checks.
  91826. */
  91827. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  91828. /**
  91829. * @hidden
  91830. * Defines the actions happening during the evaluate sub mesh checks.
  91831. */
  91832. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  91833. /**
  91834. * @hidden
  91835. * Defines the actions happening during the active mesh stage.
  91836. */
  91837. _activeMeshStage: Stage<ActiveMeshStageAction>;
  91838. /**
  91839. * @hidden
  91840. * Defines the actions happening during the per camera render target step.
  91841. */
  91842. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  91843. /**
  91844. * @hidden
  91845. * Defines the actions happening just before the active camera is drawing.
  91846. */
  91847. _beforeCameraDrawStage: Stage<CameraStageAction>;
  91848. /**
  91849. * @hidden
  91850. * Defines the actions happening just before a render target is drawing.
  91851. */
  91852. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91853. /**
  91854. * @hidden
  91855. * Defines the actions happening just before a rendering group is drawing.
  91856. */
  91857. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91858. /**
  91859. * @hidden
  91860. * Defines the actions happening just before a mesh is drawing.
  91861. */
  91862. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91863. /**
  91864. * @hidden
  91865. * Defines the actions happening just after a mesh has been drawn.
  91866. */
  91867. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91868. /**
  91869. * @hidden
  91870. * Defines the actions happening just after a rendering group has been drawn.
  91871. */
  91872. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91873. /**
  91874. * @hidden
  91875. * Defines the actions happening just after the active camera has been drawn.
  91876. */
  91877. _afterCameraDrawStage: Stage<CameraStageAction>;
  91878. /**
  91879. * @hidden
  91880. * Defines the actions happening just after a render target has been drawn.
  91881. */
  91882. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91883. /**
  91884. * @hidden
  91885. * Defines the actions happening just after rendering all cameras and computing intersections.
  91886. */
  91887. _afterRenderStage: Stage<SimpleStageAction>;
  91888. /**
  91889. * @hidden
  91890. * Defines the actions happening when a pointer move event happens.
  91891. */
  91892. _pointerMoveStage: Stage<PointerMoveStageAction>;
  91893. /**
  91894. * @hidden
  91895. * Defines the actions happening when a pointer down event happens.
  91896. */
  91897. _pointerDownStage: Stage<PointerUpDownStageAction>;
  91898. /**
  91899. * @hidden
  91900. * Defines the actions happening when a pointer up event happens.
  91901. */
  91902. _pointerUpStage: Stage<PointerUpDownStageAction>;
  91903. /**
  91904. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  91905. */
  91906. private geometriesByUniqueId;
  91907. /**
  91908. * Creates a new Scene
  91909. * @param engine defines the engine to use to render this scene
  91910. * @param options defines the scene options
  91911. */
  91912. constructor(engine: Engine, options?: SceneOptions);
  91913. /**
  91914. * Gets a string idenfifying the name of the class
  91915. * @returns "Scene" string
  91916. */
  91917. getClassName(): string;
  91918. private _defaultMeshCandidates;
  91919. /**
  91920. * @hidden
  91921. */
  91922. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  91923. private _defaultSubMeshCandidates;
  91924. /**
  91925. * @hidden
  91926. */
  91927. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  91928. /**
  91929. * Sets the default candidate providers for the scene.
  91930. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  91931. * and getCollidingSubMeshCandidates to their default function
  91932. */
  91933. setDefaultCandidateProviders(): void;
  91934. /**
  91935. * Gets the mesh that is currently under the pointer
  91936. */
  91937. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91938. /**
  91939. * Gets or sets the current on-screen X position of the pointer
  91940. */
  91941. pointerX: number;
  91942. /**
  91943. * Gets or sets the current on-screen Y position of the pointer
  91944. */
  91945. pointerY: number;
  91946. /**
  91947. * Gets the cached material (ie. the latest rendered one)
  91948. * @returns the cached material
  91949. */
  91950. getCachedMaterial(): Nullable<Material>;
  91951. /**
  91952. * Gets the cached effect (ie. the latest rendered one)
  91953. * @returns the cached effect
  91954. */
  91955. getCachedEffect(): Nullable<Effect>;
  91956. /**
  91957. * Gets the cached visibility state (ie. the latest rendered one)
  91958. * @returns the cached visibility state
  91959. */
  91960. getCachedVisibility(): Nullable<number>;
  91961. /**
  91962. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  91963. * @param material defines the current material
  91964. * @param effect defines the current effect
  91965. * @param visibility defines the current visibility state
  91966. * @returns true if one parameter is not cached
  91967. */
  91968. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  91969. /**
  91970. * Gets the engine associated with the scene
  91971. * @returns an Engine
  91972. */
  91973. getEngine(): Engine;
  91974. /**
  91975. * Gets the total number of vertices rendered per frame
  91976. * @returns the total number of vertices rendered per frame
  91977. */
  91978. getTotalVertices(): number;
  91979. /**
  91980. * Gets the performance counter for total vertices
  91981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91982. */
  91983. readonly totalVerticesPerfCounter: PerfCounter;
  91984. /**
  91985. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  91986. * @returns the total number of active indices rendered per frame
  91987. */
  91988. getActiveIndices(): number;
  91989. /**
  91990. * Gets the performance counter for active indices
  91991. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91992. */
  91993. readonly totalActiveIndicesPerfCounter: PerfCounter;
  91994. /**
  91995. * Gets the total number of active particles rendered per frame
  91996. * @returns the total number of active particles rendered per frame
  91997. */
  91998. getActiveParticles(): number;
  91999. /**
  92000. * Gets the performance counter for active particles
  92001. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92002. */
  92003. readonly activeParticlesPerfCounter: PerfCounter;
  92004. /**
  92005. * Gets the total number of active bones rendered per frame
  92006. * @returns the total number of active bones rendered per frame
  92007. */
  92008. getActiveBones(): number;
  92009. /**
  92010. * Gets the performance counter for active bones
  92011. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92012. */
  92013. readonly activeBonesPerfCounter: PerfCounter;
  92014. /**
  92015. * Gets the array of active meshes
  92016. * @returns an array of AbstractMesh
  92017. */
  92018. getActiveMeshes(): SmartArray<AbstractMesh>;
  92019. /**
  92020. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92021. * @returns a number
  92022. */
  92023. getAnimationRatio(): number;
  92024. /**
  92025. * Gets an unique Id for the current render phase
  92026. * @returns a number
  92027. */
  92028. getRenderId(): number;
  92029. /**
  92030. * Gets an unique Id for the current frame
  92031. * @returns a number
  92032. */
  92033. getFrameId(): number;
  92034. /** Call this function if you want to manually increment the render Id*/
  92035. incrementRenderId(): void;
  92036. private _updatePointerPosition;
  92037. private _createUbo;
  92038. private _setRayOnPointerInfo;
  92039. /**
  92040. * Use this method to simulate a pointer move on a mesh
  92041. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92042. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92043. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92044. * @returns the current scene
  92045. */
  92046. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92047. private _processPointerMove;
  92048. private _checkPrePointerObservable;
  92049. /**
  92050. * Use this method to simulate a pointer down on a mesh
  92051. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92052. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92053. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92054. * @returns the current scene
  92055. */
  92056. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92057. private _processPointerDown;
  92058. /**
  92059. * Use this method to simulate a pointer up on a mesh
  92060. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92061. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92062. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92063. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92064. * @returns the current scene
  92065. */
  92066. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92067. private _processPointerUp;
  92068. /**
  92069. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92070. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92071. * @returns true if the pointer was captured
  92072. */
  92073. isPointerCaptured(pointerId?: number): boolean;
  92074. /** @hidden */
  92075. _isPointerSwiping(): boolean;
  92076. /**
  92077. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92078. * @param attachUp defines if you want to attach events to pointerup
  92079. * @param attachDown defines if you want to attach events to pointerdown
  92080. * @param attachMove defines if you want to attach events to pointermove
  92081. */
  92082. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92083. /** Detaches all event handlers*/
  92084. detachControl(): void;
  92085. /**
  92086. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92087. * Delay loaded resources are not taking in account
  92088. * @return true if all required resources are ready
  92089. */
  92090. isReady(): boolean;
  92091. /** Resets all cached information relative to material (including effect and visibility) */
  92092. resetCachedMaterial(): void;
  92093. /**
  92094. * Registers a function to be called before every frame render
  92095. * @param func defines the function to register
  92096. */
  92097. registerBeforeRender(func: () => void): void;
  92098. /**
  92099. * Unregisters a function called before every frame render
  92100. * @param func defines the function to unregister
  92101. */
  92102. unregisterBeforeRender(func: () => void): void;
  92103. /**
  92104. * Registers a function to be called after every frame render
  92105. * @param func defines the function to register
  92106. */
  92107. registerAfterRender(func: () => void): void;
  92108. /**
  92109. * Unregisters a function called after every frame render
  92110. * @param func defines the function to unregister
  92111. */
  92112. unregisterAfterRender(func: () => void): void;
  92113. private _executeOnceBeforeRender;
  92114. /**
  92115. * The provided function will run before render once and will be disposed afterwards.
  92116. * A timeout delay can be provided so that the function will be executed in N ms.
  92117. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92118. * @param func The function to be executed.
  92119. * @param timeout optional delay in ms
  92120. */
  92121. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92122. /** @hidden */
  92123. _addPendingData(data: any): void;
  92124. /** @hidden */
  92125. _removePendingData(data: any): void;
  92126. /**
  92127. * Returns the number of items waiting to be loaded
  92128. * @returns the number of items waiting to be loaded
  92129. */
  92130. getWaitingItemsCount(): number;
  92131. /**
  92132. * Returns a boolean indicating if the scene is still loading data
  92133. */
  92134. readonly isLoading: boolean;
  92135. /**
  92136. * Registers a function to be executed when the scene is ready
  92137. * @param {Function} func - the function to be executed
  92138. */
  92139. executeWhenReady(func: () => void): void;
  92140. /**
  92141. * Returns a promise that resolves when the scene is ready
  92142. * @returns A promise that resolves when the scene is ready
  92143. */
  92144. whenReadyAsync(): Promise<void>;
  92145. /** @hidden */
  92146. _checkIsReady(): void;
  92147. /**
  92148. * Gets all animatable attached to the scene
  92149. */
  92150. readonly animatables: Animatable[];
  92151. /**
  92152. * Resets the last animation time frame.
  92153. * Useful to override when animations start running when loading a scene for the first time.
  92154. */
  92155. resetLastAnimationTimeFrame(): void;
  92156. /**
  92157. * Gets the current view matrix
  92158. * @returns a Matrix
  92159. */
  92160. getViewMatrix(): Matrix;
  92161. /**
  92162. * Gets the current projection matrix
  92163. * @returns a Matrix
  92164. */
  92165. getProjectionMatrix(): Matrix;
  92166. /**
  92167. * Gets the current transform matrix
  92168. * @returns a Matrix made of View * Projection
  92169. */
  92170. getTransformMatrix(): Matrix;
  92171. /**
  92172. * Sets the current transform matrix
  92173. * @param viewL defines the View matrix to use
  92174. * @param projectionL defines the Projection matrix to use
  92175. * @param viewR defines the right View matrix to use (if provided)
  92176. * @param projectionR defines the right Projection matrix to use (if provided)
  92177. */
  92178. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92179. /**
  92180. * Gets the uniform buffer used to store scene data
  92181. * @returns a UniformBuffer
  92182. */
  92183. getSceneUniformBuffer(): UniformBuffer;
  92184. /**
  92185. * Gets an unique (relatively to the current scene) Id
  92186. * @returns an unique number for the scene
  92187. */
  92188. getUniqueId(): number;
  92189. /**
  92190. * Add a mesh to the list of scene's meshes
  92191. * @param newMesh defines the mesh to add
  92192. * @param recursive if all child meshes should also be added to the scene
  92193. */
  92194. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92195. /**
  92196. * Remove a mesh for the list of scene's meshes
  92197. * @param toRemove defines the mesh to remove
  92198. * @param recursive if all child meshes should also be removed from the scene
  92199. * @returns the index where the mesh was in the mesh list
  92200. */
  92201. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92202. /**
  92203. * Add a transform node to the list of scene's transform nodes
  92204. * @param newTransformNode defines the transform node to add
  92205. */
  92206. addTransformNode(newTransformNode: TransformNode): void;
  92207. /**
  92208. * Remove a transform node for the list of scene's transform nodes
  92209. * @param toRemove defines the transform node to remove
  92210. * @returns the index where the transform node was in the transform node list
  92211. */
  92212. removeTransformNode(toRemove: TransformNode): number;
  92213. /**
  92214. * Remove a skeleton for the list of scene's skeletons
  92215. * @param toRemove defines the skeleton to remove
  92216. * @returns the index where the skeleton was in the skeleton list
  92217. */
  92218. removeSkeleton(toRemove: Skeleton): number;
  92219. /**
  92220. * Remove a morph target for the list of scene's morph targets
  92221. * @param toRemove defines the morph target to remove
  92222. * @returns the index where the morph target was in the morph target list
  92223. */
  92224. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92225. /**
  92226. * Remove a light for the list of scene's lights
  92227. * @param toRemove defines the light to remove
  92228. * @returns the index where the light was in the light list
  92229. */
  92230. removeLight(toRemove: Light): number;
  92231. /**
  92232. * Remove a camera for the list of scene's cameras
  92233. * @param toRemove defines the camera to remove
  92234. * @returns the index where the camera was in the camera list
  92235. */
  92236. removeCamera(toRemove: Camera): number;
  92237. /**
  92238. * Remove a particle system for the list of scene's particle systems
  92239. * @param toRemove defines the particle system to remove
  92240. * @returns the index where the particle system was in the particle system list
  92241. */
  92242. removeParticleSystem(toRemove: IParticleSystem): number;
  92243. /**
  92244. * Remove a animation for the list of scene's animations
  92245. * @param toRemove defines the animation to remove
  92246. * @returns the index where the animation was in the animation list
  92247. */
  92248. removeAnimation(toRemove: Animation): number;
  92249. /**
  92250. * Removes the given animation group from this scene.
  92251. * @param toRemove The animation group to remove
  92252. * @returns The index of the removed animation group
  92253. */
  92254. removeAnimationGroup(toRemove: AnimationGroup): number;
  92255. /**
  92256. * Removes the given multi-material from this scene.
  92257. * @param toRemove The multi-material to remove
  92258. * @returns The index of the removed multi-material
  92259. */
  92260. removeMultiMaterial(toRemove: MultiMaterial): number;
  92261. /**
  92262. * Removes the given material from this scene.
  92263. * @param toRemove The material to remove
  92264. * @returns The index of the removed material
  92265. */
  92266. removeMaterial(toRemove: Material): number;
  92267. /**
  92268. * Removes the given action manager from this scene.
  92269. * @param toRemove The action manager to remove
  92270. * @returns The index of the removed action manager
  92271. */
  92272. removeActionManager(toRemove: AbstractActionManager): number;
  92273. /**
  92274. * Removes the given texture from this scene.
  92275. * @param toRemove The texture to remove
  92276. * @returns The index of the removed texture
  92277. */
  92278. removeTexture(toRemove: BaseTexture): number;
  92279. /**
  92280. * Adds the given light to this scene
  92281. * @param newLight The light to add
  92282. */
  92283. addLight(newLight: Light): void;
  92284. /**
  92285. * Sorts the list list based on light priorities
  92286. */
  92287. sortLightsByPriority(): void;
  92288. /**
  92289. * Adds the given camera to this scene
  92290. * @param newCamera The camera to add
  92291. */
  92292. addCamera(newCamera: Camera): void;
  92293. /**
  92294. * Adds the given skeleton to this scene
  92295. * @param newSkeleton The skeleton to add
  92296. */
  92297. addSkeleton(newSkeleton: Skeleton): void;
  92298. /**
  92299. * Adds the given particle system to this scene
  92300. * @param newParticleSystem The particle system to add
  92301. */
  92302. addParticleSystem(newParticleSystem: IParticleSystem): void;
  92303. /**
  92304. * Adds the given animation to this scene
  92305. * @param newAnimation The animation to add
  92306. */
  92307. addAnimation(newAnimation: Animation): void;
  92308. /**
  92309. * Adds the given animation group to this scene.
  92310. * @param newAnimationGroup The animation group to add
  92311. */
  92312. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  92313. /**
  92314. * Adds the given multi-material to this scene
  92315. * @param newMultiMaterial The multi-material to add
  92316. */
  92317. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  92318. /**
  92319. * Adds the given material to this scene
  92320. * @param newMaterial The material to add
  92321. */
  92322. addMaterial(newMaterial: Material): void;
  92323. /**
  92324. * Adds the given morph target to this scene
  92325. * @param newMorphTargetManager The morph target to add
  92326. */
  92327. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  92328. /**
  92329. * Adds the given geometry to this scene
  92330. * @param newGeometry The geometry to add
  92331. */
  92332. addGeometry(newGeometry: Geometry): void;
  92333. /**
  92334. * Adds the given action manager to this scene
  92335. * @param newActionManager The action manager to add
  92336. */
  92337. addActionManager(newActionManager: AbstractActionManager): void;
  92338. /**
  92339. * Adds the given texture to this scene.
  92340. * @param newTexture The texture to add
  92341. */
  92342. addTexture(newTexture: BaseTexture): void;
  92343. /**
  92344. * Switch active camera
  92345. * @param newCamera defines the new active camera
  92346. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  92347. */
  92348. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92349. /**
  92350. * sets the active camera of the scene using its ID
  92351. * @param id defines the camera's ID
  92352. * @return the new active camera or null if none found.
  92353. */
  92354. setActiveCameraByID(id: string): Nullable<Camera>;
  92355. /**
  92356. * sets the active camera of the scene using its name
  92357. * @param name defines the camera's name
  92358. * @returns the new active camera or null if none found.
  92359. */
  92360. setActiveCameraByName(name: string): Nullable<Camera>;
  92361. /**
  92362. * get an animation group using its name
  92363. * @param name defines the material's name
  92364. * @return the animation group or null if none found.
  92365. */
  92366. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92367. /**
  92368. * Get a material using its unique id
  92369. * @param uniqueId defines the material's unique id
  92370. * @return the material or null if none found.
  92371. */
  92372. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92373. /**
  92374. * get a material using its id
  92375. * @param id defines the material's ID
  92376. * @return the material or null if none found.
  92377. */
  92378. getMaterialByID(id: string): Nullable<Material>;
  92379. /**
  92380. * Gets a material using its name
  92381. * @param name defines the material's name
  92382. * @return the material or null if none found.
  92383. */
  92384. getMaterialByName(name: string): Nullable<Material>;
  92385. /**
  92386. * Gets a camera using its id
  92387. * @param id defines the id to look for
  92388. * @returns the camera or null if not found
  92389. */
  92390. getCameraByID(id: string): Nullable<Camera>;
  92391. /**
  92392. * Gets a camera using its unique id
  92393. * @param uniqueId defines the unique id to look for
  92394. * @returns the camera or null if not found
  92395. */
  92396. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92397. /**
  92398. * Gets a camera using its name
  92399. * @param name defines the camera's name
  92400. * @return the camera or null if none found.
  92401. */
  92402. getCameraByName(name: string): Nullable<Camera>;
  92403. /**
  92404. * Gets a bone using its id
  92405. * @param id defines the bone's id
  92406. * @return the bone or null if not found
  92407. */
  92408. getBoneByID(id: string): Nullable<Bone>;
  92409. /**
  92410. * Gets a bone using its id
  92411. * @param name defines the bone's name
  92412. * @return the bone or null if not found
  92413. */
  92414. getBoneByName(name: string): Nullable<Bone>;
  92415. /**
  92416. * Gets a light node using its name
  92417. * @param name defines the the light's name
  92418. * @return the light or null if none found.
  92419. */
  92420. getLightByName(name: string): Nullable<Light>;
  92421. /**
  92422. * Gets a light node using its id
  92423. * @param id defines the light's id
  92424. * @return the light or null if none found.
  92425. */
  92426. getLightByID(id: string): Nullable<Light>;
  92427. /**
  92428. * Gets a light node using its scene-generated unique ID
  92429. * @param uniqueId defines the light's unique id
  92430. * @return the light or null if none found.
  92431. */
  92432. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92433. /**
  92434. * Gets a particle system by id
  92435. * @param id defines the particle system id
  92436. * @return the corresponding system or null if none found
  92437. */
  92438. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92439. /**
  92440. * Gets a geometry using its ID
  92441. * @param id defines the geometry's id
  92442. * @return the geometry or null if none found.
  92443. */
  92444. getGeometryByID(id: string): Nullable<Geometry>;
  92445. private _getGeometryByUniqueID;
  92446. /**
  92447. * Add a new geometry to this scene
  92448. * @param geometry defines the geometry to be added to the scene.
  92449. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92450. * @return a boolean defining if the geometry was added or not
  92451. */
  92452. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92453. /**
  92454. * Removes an existing geometry
  92455. * @param geometry defines the geometry to be removed from the scene
  92456. * @return a boolean defining if the geometry was removed or not
  92457. */
  92458. removeGeometry(geometry: Geometry): boolean;
  92459. /**
  92460. * Gets the list of geometries attached to the scene
  92461. * @returns an array of Geometry
  92462. */
  92463. getGeometries(): Geometry[];
  92464. /**
  92465. * Gets the first added mesh found of a given ID
  92466. * @param id defines the id to search for
  92467. * @return the mesh found or null if not found at all
  92468. */
  92469. getMeshByID(id: string): Nullable<AbstractMesh>;
  92470. /**
  92471. * Gets a list of meshes using their id
  92472. * @param id defines the id to search for
  92473. * @returns a list of meshes
  92474. */
  92475. getMeshesByID(id: string): Array<AbstractMesh>;
  92476. /**
  92477. * Gets the first added transform node found of a given ID
  92478. * @param id defines the id to search for
  92479. * @return the found transform node or null if not found at all.
  92480. */
  92481. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92482. /**
  92483. * Gets a transform node with its auto-generated unique id
  92484. * @param uniqueId efines the unique id to search for
  92485. * @return the found transform node or null if not found at all.
  92486. */
  92487. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92488. /**
  92489. * Gets a list of transform nodes using their id
  92490. * @param id defines the id to search for
  92491. * @returns a list of transform nodes
  92492. */
  92493. getTransformNodesByID(id: string): Array<TransformNode>;
  92494. /**
  92495. * Gets a mesh with its auto-generated unique id
  92496. * @param uniqueId defines the unique id to search for
  92497. * @return the found mesh or null if not found at all.
  92498. */
  92499. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92500. /**
  92501. * Gets a the last added mesh using a given id
  92502. * @param id defines the id to search for
  92503. * @return the found mesh or null if not found at all.
  92504. */
  92505. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92506. /**
  92507. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92508. * @param id defines the id to search for
  92509. * @return the found node or null if not found at all
  92510. */
  92511. getLastEntryByID(id: string): Nullable<Node>;
  92512. /**
  92513. * Gets a node (Mesh, Camera, Light) using a given id
  92514. * @param id defines the id to search for
  92515. * @return the found node or null if not found at all
  92516. */
  92517. getNodeByID(id: string): Nullable<Node>;
  92518. /**
  92519. * Gets a node (Mesh, Camera, Light) using a given name
  92520. * @param name defines the name to search for
  92521. * @return the found node or null if not found at all.
  92522. */
  92523. getNodeByName(name: string): Nullable<Node>;
  92524. /**
  92525. * Gets a mesh using a given name
  92526. * @param name defines the name to search for
  92527. * @return the found mesh or null if not found at all.
  92528. */
  92529. getMeshByName(name: string): Nullable<AbstractMesh>;
  92530. /**
  92531. * Gets a transform node using a given name
  92532. * @param name defines the name to search for
  92533. * @return the found transform node or null if not found at all.
  92534. */
  92535. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92536. /**
  92537. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92538. * @param id defines the id to search for
  92539. * @return the found skeleton or null if not found at all.
  92540. */
  92541. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92542. /**
  92543. * Gets a skeleton using a given auto generated unique id
  92544. * @param uniqueId defines the unique id to search for
  92545. * @return the found skeleton or null if not found at all.
  92546. */
  92547. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92548. /**
  92549. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92550. * @param id defines the id to search for
  92551. * @return the found skeleton or null if not found at all.
  92552. */
  92553. getSkeletonById(id: string): Nullable<Skeleton>;
  92554. /**
  92555. * Gets a skeleton using a given name
  92556. * @param name defines the name to search for
  92557. * @return the found skeleton or null if not found at all.
  92558. */
  92559. getSkeletonByName(name: string): Nullable<Skeleton>;
  92560. /**
  92561. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92562. * @param id defines the id to search for
  92563. * @return the found morph target manager or null if not found at all.
  92564. */
  92565. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92566. /**
  92567. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92568. * @param id defines the id to search for
  92569. * @return the found morph target or null if not found at all.
  92570. */
  92571. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92572. /**
  92573. * Gets a boolean indicating if the given mesh is active
  92574. * @param mesh defines the mesh to look for
  92575. * @returns true if the mesh is in the active list
  92576. */
  92577. isActiveMesh(mesh: AbstractMesh): boolean;
  92578. /**
  92579. * Return a unique id as a string which can serve as an identifier for the scene
  92580. */
  92581. readonly uid: string;
  92582. /**
  92583. * Add an externaly attached data from its key.
  92584. * This method call will fail and return false, if such key already exists.
  92585. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92586. * @param key the unique key that identifies the data
  92587. * @param data the data object to associate to the key for this Engine instance
  92588. * @return true if no such key were already present and the data was added successfully, false otherwise
  92589. */
  92590. addExternalData<T>(key: string, data: T): boolean;
  92591. /**
  92592. * Get an externaly attached data from its key
  92593. * @param key the unique key that identifies the data
  92594. * @return the associated data, if present (can be null), or undefined if not present
  92595. */
  92596. getExternalData<T>(key: string): Nullable<T>;
  92597. /**
  92598. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92599. * @param key the unique key that identifies the data
  92600. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92601. * @return the associated data, can be null if the factory returned null.
  92602. */
  92603. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92604. /**
  92605. * Remove an externaly attached data from the Engine instance
  92606. * @param key the unique key that identifies the data
  92607. * @return true if the data was successfully removed, false if it doesn't exist
  92608. */
  92609. removeExternalData(key: string): boolean;
  92610. private _evaluateSubMesh;
  92611. /**
  92612. * Clear the processed materials smart array preventing retention point in material dispose.
  92613. */
  92614. freeProcessedMaterials(): void;
  92615. private _preventFreeActiveMeshesAndRenderingGroups;
  92616. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92617. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92618. * when disposing several meshes in a row or a hierarchy of meshes.
  92619. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92620. */
  92621. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92622. /**
  92623. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92624. */
  92625. freeActiveMeshes(): void;
  92626. /**
  92627. * Clear the info related to rendering groups preventing retention points during dispose.
  92628. */
  92629. freeRenderingGroups(): void;
  92630. /** @hidden */
  92631. _isInIntermediateRendering(): boolean;
  92632. /**
  92633. * Lambda returning the list of potentially active meshes.
  92634. */
  92635. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92636. /**
  92637. * Lambda returning the list of potentially active sub meshes.
  92638. */
  92639. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92640. /**
  92641. * Lambda returning the list of potentially intersecting sub meshes.
  92642. */
  92643. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92644. /**
  92645. * Lambda returning the list of potentially colliding sub meshes.
  92646. */
  92647. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92648. private _activeMeshesFrozen;
  92649. /**
  92650. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  92651. * @returns the current scene
  92652. */
  92653. freezeActiveMeshes(): Scene;
  92654. /**
  92655. * Use this function to restart evaluating active meshes on every frame
  92656. * @returns the current scene
  92657. */
  92658. unfreezeActiveMeshes(): Scene;
  92659. private _evaluateActiveMeshes;
  92660. private _activeMesh;
  92661. /**
  92662. * Update the transform matrix to update from the current active camera
  92663. * @param force defines a boolean used to force the update even if cache is up to date
  92664. */
  92665. updateTransformMatrix(force?: boolean): void;
  92666. private _bindFrameBuffer;
  92667. /** @hidden */
  92668. _allowPostProcessClearColor: boolean;
  92669. /** @hidden */
  92670. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  92671. private _processSubCameras;
  92672. private _checkIntersections;
  92673. /** @hidden */
  92674. _advancePhysicsEngineStep(step: number): void;
  92675. /**
  92676. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  92677. */
  92678. getDeterministicFrameTime: () => number;
  92679. /** @hidden */
  92680. _animate(): void;
  92681. /** Execute all animations (for a frame) */
  92682. animate(): void;
  92683. /**
  92684. * Render the scene
  92685. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  92686. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  92687. */
  92688. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  92689. /**
  92690. * Freeze all materials
  92691. * A frozen material will not be updatable but should be faster to render
  92692. */
  92693. freezeMaterials(): void;
  92694. /**
  92695. * Unfreeze all materials
  92696. * A frozen material will not be updatable but should be faster to render
  92697. */
  92698. unfreezeMaterials(): void;
  92699. /**
  92700. * Releases all held ressources
  92701. */
  92702. dispose(): void;
  92703. /**
  92704. * Gets if the scene is already disposed
  92705. */
  92706. readonly isDisposed: boolean;
  92707. /**
  92708. * Call this function to reduce memory footprint of the scene.
  92709. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  92710. */
  92711. clearCachedVertexData(): void;
  92712. /**
  92713. * This function will remove the local cached buffer data from texture.
  92714. * It will save memory but will prevent the texture from being rebuilt
  92715. */
  92716. cleanCachedTextureBuffer(): void;
  92717. /**
  92718. * Get the world extend vectors with an optional filter
  92719. *
  92720. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  92721. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  92722. */
  92723. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  92724. min: Vector3;
  92725. max: Vector3;
  92726. };
  92727. /**
  92728. * Creates a ray that can be used to pick in the scene
  92729. * @param x defines the x coordinate of the origin (on-screen)
  92730. * @param y defines the y coordinate of the origin (on-screen)
  92731. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92732. * @param camera defines the camera to use for the picking
  92733. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92734. * @returns a Ray
  92735. */
  92736. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  92737. /**
  92738. * Creates a ray that can be used to pick in the scene
  92739. * @param x defines the x coordinate of the origin (on-screen)
  92740. * @param y defines the y coordinate of the origin (on-screen)
  92741. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92742. * @param result defines the ray where to store the picking ray
  92743. * @param camera defines the camera to use for the picking
  92744. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92745. * @returns the current scene
  92746. */
  92747. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  92748. /**
  92749. * Creates a ray that can be used to pick in the scene
  92750. * @param x defines the x coordinate of the origin (on-screen)
  92751. * @param y defines the y coordinate of the origin (on-screen)
  92752. * @param camera defines the camera to use for the picking
  92753. * @returns a Ray
  92754. */
  92755. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  92756. /**
  92757. * Creates a ray that can be used to pick in the scene
  92758. * @param x defines the x coordinate of the origin (on-screen)
  92759. * @param y defines the y coordinate of the origin (on-screen)
  92760. * @param result defines the ray where to store the picking ray
  92761. * @param camera defines the camera to use for the picking
  92762. * @returns the current scene
  92763. */
  92764. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  92765. /** Launch a ray to try to pick a mesh in the scene
  92766. * @param x position on screen
  92767. * @param y position on screen
  92768. * @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
  92769. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  92770. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92771. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92772. * @returns a PickingInfo
  92773. */
  92774. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  92775. /** Use the given ray to pick a mesh in the scene
  92776. * @param ray The ray to use to pick meshes
  92777. * @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
  92778. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  92779. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92780. * @returns a PickingInfo
  92781. */
  92782. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92783. /**
  92784. * Launch a ray to try to pick a mesh in the scene
  92785. * @param x X position on screen
  92786. * @param y Y position on screen
  92787. * @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
  92788. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92789. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92790. * @returns an array of PickingInfo
  92791. */
  92792. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92793. /**
  92794. * Launch a ray to try to pick a mesh in the scene
  92795. * @param ray Ray to use
  92796. * @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
  92797. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92798. * @returns an array of PickingInfo
  92799. */
  92800. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92801. /**
  92802. * Force the value of meshUnderPointer
  92803. * @param mesh defines the mesh to use
  92804. */
  92805. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  92806. /**
  92807. * Gets the mesh under the pointer
  92808. * @returns a Mesh or null if no mesh is under the pointer
  92809. */
  92810. getPointerOverMesh(): Nullable<AbstractMesh>;
  92811. /** @hidden */
  92812. _rebuildGeometries(): void;
  92813. /** @hidden */
  92814. _rebuildTextures(): void;
  92815. private _getByTags;
  92816. /**
  92817. * Get a list of meshes by tags
  92818. * @param tagsQuery defines the tags query to use
  92819. * @param forEach defines a predicate used to filter results
  92820. * @returns an array of Mesh
  92821. */
  92822. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  92823. /**
  92824. * Get a list of cameras by tags
  92825. * @param tagsQuery defines the tags query to use
  92826. * @param forEach defines a predicate used to filter results
  92827. * @returns an array of Camera
  92828. */
  92829. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  92830. /**
  92831. * Get a list of lights by tags
  92832. * @param tagsQuery defines the tags query to use
  92833. * @param forEach defines a predicate used to filter results
  92834. * @returns an array of Light
  92835. */
  92836. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  92837. /**
  92838. * Get a list of materials by tags
  92839. * @param tagsQuery defines the tags query to use
  92840. * @param forEach defines a predicate used to filter results
  92841. * @returns an array of Material
  92842. */
  92843. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  92844. /**
  92845. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92846. * This allowed control for front to back rendering or reversly depending of the special needs.
  92847. *
  92848. * @param renderingGroupId The rendering group id corresponding to its index
  92849. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92850. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92851. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92852. */
  92853. 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;
  92854. /**
  92855. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92856. *
  92857. * @param renderingGroupId The rendering group id corresponding to its index
  92858. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92859. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92860. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92861. */
  92862. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92863. /**
  92864. * Gets the current auto clear configuration for one rendering group of the rendering
  92865. * manager.
  92866. * @param index the rendering group index to get the information for
  92867. * @returns The auto clear setup for the requested rendering group
  92868. */
  92869. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92870. private _blockMaterialDirtyMechanism;
  92871. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  92872. blockMaterialDirtyMechanism: boolean;
  92873. /**
  92874. * Will flag all materials as dirty to trigger new shader compilation
  92875. * @param flag defines the flag used to specify which material part must be marked as dirty
  92876. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  92877. */
  92878. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92879. /** @hidden */
  92880. _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;
  92881. /** @hidden */
  92882. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92883. }
  92884. }
  92885. declare module BABYLON {
  92886. /**
  92887. * Set of assets to keep when moving a scene into an asset container.
  92888. */
  92889. export class KeepAssets extends AbstractScene {
  92890. }
  92891. /**
  92892. * Container with a set of assets that can be added or removed from a scene.
  92893. */
  92894. export class AssetContainer extends AbstractScene {
  92895. /**
  92896. * The scene the AssetContainer belongs to.
  92897. */
  92898. scene: Scene;
  92899. /**
  92900. * Instantiates an AssetContainer.
  92901. * @param scene The scene the AssetContainer belongs to.
  92902. */
  92903. constructor(scene: Scene);
  92904. /**
  92905. * Adds all the assets from the container to the scene.
  92906. */
  92907. addAllToScene(): void;
  92908. /**
  92909. * Removes all the assets in the container from the scene
  92910. */
  92911. removeAllFromScene(): void;
  92912. /**
  92913. * Disposes all the assets in the container
  92914. */
  92915. dispose(): void;
  92916. private _moveAssets;
  92917. /**
  92918. * Removes all the assets contained in the scene and adds them to the container.
  92919. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  92920. */
  92921. moveAllFromScene(keepAssets?: KeepAssets): void;
  92922. /**
  92923. * 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.
  92924. * @returns the root mesh
  92925. */
  92926. createRootMesh(): Mesh;
  92927. }
  92928. }
  92929. declare module BABYLON {
  92930. /**
  92931. * Defines how the parser contract is defined.
  92932. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  92933. */
  92934. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  92935. /**
  92936. * Defines how the individual parser contract is defined.
  92937. * These parser can parse an individual asset
  92938. */
  92939. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  92940. /**
  92941. * Base class of the scene acting as a container for the different elements composing a scene.
  92942. * This class is dynamically extended by the different components of the scene increasing
  92943. * flexibility and reducing coupling
  92944. */
  92945. export abstract class AbstractScene {
  92946. /**
  92947. * Stores the list of available parsers in the application.
  92948. */
  92949. private static _BabylonFileParsers;
  92950. /**
  92951. * Stores the list of available individual parsers in the application.
  92952. */
  92953. private static _IndividualBabylonFileParsers;
  92954. /**
  92955. * Adds a parser in the list of available ones
  92956. * @param name Defines the name of the parser
  92957. * @param parser Defines the parser to add
  92958. */
  92959. static AddParser(name: string, parser: BabylonFileParser): void;
  92960. /**
  92961. * Gets a general parser from the list of avaialble ones
  92962. * @param name Defines the name of the parser
  92963. * @returns the requested parser or null
  92964. */
  92965. static GetParser(name: string): Nullable<BabylonFileParser>;
  92966. /**
  92967. * Adds n individual parser in the list of available ones
  92968. * @param name Defines the name of the parser
  92969. * @param parser Defines the parser to add
  92970. */
  92971. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  92972. /**
  92973. * Gets an individual parser from the list of avaialble ones
  92974. * @param name Defines the name of the parser
  92975. * @returns the requested parser or null
  92976. */
  92977. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  92978. /**
  92979. * Parser json data and populate both a scene and its associated container object
  92980. * @param jsonData Defines the data to parse
  92981. * @param scene Defines the scene to parse the data for
  92982. * @param container Defines the container attached to the parsing sequence
  92983. * @param rootUrl Defines the root url of the data
  92984. */
  92985. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  92986. /**
  92987. * Gets the list of root nodes (ie. nodes with no parent)
  92988. */
  92989. rootNodes: Node[];
  92990. /** All of the cameras added to this scene
  92991. * @see http://doc.babylonjs.com/babylon101/cameras
  92992. */
  92993. cameras: Camera[];
  92994. /**
  92995. * All of the lights added to this scene
  92996. * @see http://doc.babylonjs.com/babylon101/lights
  92997. */
  92998. lights: Light[];
  92999. /**
  93000. * All of the (abstract) meshes added to this scene
  93001. */
  93002. meshes: AbstractMesh[];
  93003. /**
  93004. * The list of skeletons added to the scene
  93005. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93006. */
  93007. skeletons: Skeleton[];
  93008. /**
  93009. * All of the particle systems added to this scene
  93010. * @see http://doc.babylonjs.com/babylon101/particles
  93011. */
  93012. particleSystems: IParticleSystem[];
  93013. /**
  93014. * Gets a list of Animations associated with the scene
  93015. */
  93016. animations: Animation[];
  93017. /**
  93018. * All of the animation groups added to this scene
  93019. * @see http://doc.babylonjs.com/how_to/group
  93020. */
  93021. animationGroups: AnimationGroup[];
  93022. /**
  93023. * All of the multi-materials added to this scene
  93024. * @see http://doc.babylonjs.com/how_to/multi_materials
  93025. */
  93026. multiMaterials: MultiMaterial[];
  93027. /**
  93028. * All of the materials added to this scene
  93029. * In the context of a Scene, it is not supposed to be modified manually.
  93030. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93031. * Note also that the order of the Material wihin the array is not significant and might change.
  93032. * @see http://doc.babylonjs.com/babylon101/materials
  93033. */
  93034. materials: Material[];
  93035. /**
  93036. * The list of morph target managers added to the scene
  93037. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93038. */
  93039. morphTargetManagers: MorphTargetManager[];
  93040. /**
  93041. * The list of geometries used in the scene.
  93042. */
  93043. geometries: Geometry[];
  93044. /**
  93045. * All of the tranform nodes added to this scene
  93046. * In the context of a Scene, it is not supposed to be modified manually.
  93047. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93048. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93049. * @see http://doc.babylonjs.com/how_to/transformnode
  93050. */
  93051. transformNodes: TransformNode[];
  93052. /**
  93053. * ActionManagers available on the scene.
  93054. */
  93055. actionManagers: AbstractActionManager[];
  93056. /**
  93057. * Textures to keep.
  93058. */
  93059. textures: BaseTexture[];
  93060. /**
  93061. * Environment texture for the scene
  93062. */
  93063. environmentTexture: Nullable<BaseTexture>;
  93064. }
  93065. }
  93066. declare module BABYLON {
  93067. /**
  93068. * Defines a sound that can be played in the application.
  93069. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93071. */
  93072. export class Sound {
  93073. /**
  93074. * The name of the sound in the scene.
  93075. */
  93076. name: string;
  93077. /**
  93078. * Does the sound autoplay once loaded.
  93079. */
  93080. autoplay: boolean;
  93081. /**
  93082. * Does the sound loop after it finishes playing once.
  93083. */
  93084. loop: boolean;
  93085. /**
  93086. * Does the sound use a custom attenuation curve to simulate the falloff
  93087. * happening when the source gets further away from the camera.
  93088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93089. */
  93090. useCustomAttenuation: boolean;
  93091. /**
  93092. * The sound track id this sound belongs to.
  93093. */
  93094. soundTrackId: number;
  93095. /**
  93096. * Is this sound currently played.
  93097. */
  93098. isPlaying: boolean;
  93099. /**
  93100. * Is this sound currently paused.
  93101. */
  93102. isPaused: boolean;
  93103. /**
  93104. * Does this sound enables spatial sound.
  93105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93106. */
  93107. spatialSound: boolean;
  93108. /**
  93109. * Define the reference distance the sound should be heard perfectly.
  93110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93111. */
  93112. refDistance: number;
  93113. /**
  93114. * Define the roll off factor of spatial sounds.
  93115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93116. */
  93117. rolloffFactor: number;
  93118. /**
  93119. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93121. */
  93122. maxDistance: number;
  93123. /**
  93124. * Define the distance attenuation model the sound will follow.
  93125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93126. */
  93127. distanceModel: string;
  93128. /**
  93129. * @hidden
  93130. * Back Compat
  93131. **/
  93132. onended: () => any;
  93133. /**
  93134. * Observable event when the current playing sound finishes.
  93135. */
  93136. onEndedObservable: Observable<Sound>;
  93137. private _panningModel;
  93138. private _playbackRate;
  93139. private _streaming;
  93140. private _startTime;
  93141. private _startOffset;
  93142. private _position;
  93143. /** @hidden */
  93144. _positionInEmitterSpace: boolean;
  93145. private _localDirection;
  93146. private _volume;
  93147. private _isReadyToPlay;
  93148. private _isDirectional;
  93149. private _readyToPlayCallback;
  93150. private _audioBuffer;
  93151. private _soundSource;
  93152. private _streamingSource;
  93153. private _soundPanner;
  93154. private _soundGain;
  93155. private _inputAudioNode;
  93156. private _outputAudioNode;
  93157. private _coneInnerAngle;
  93158. private _coneOuterAngle;
  93159. private _coneOuterGain;
  93160. private _scene;
  93161. private _connectedTransformNode;
  93162. private _customAttenuationFunction;
  93163. private _registerFunc;
  93164. private _isOutputConnected;
  93165. private _htmlAudioElement;
  93166. private _urlType;
  93167. /** @hidden */
  93168. static _SceneComponentInitialization: (scene: Scene) => void;
  93169. /**
  93170. * Create a sound and attach it to a scene
  93171. * @param name Name of your sound
  93172. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93173. * @param scene defines the scene the sound belongs to
  93174. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93175. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93176. */
  93177. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93178. /**
  93179. * Release the sound and its associated resources
  93180. */
  93181. dispose(): void;
  93182. /**
  93183. * Gets if the sounds is ready to be played or not.
  93184. * @returns true if ready, otherwise false
  93185. */
  93186. isReady(): boolean;
  93187. private _soundLoaded;
  93188. /**
  93189. * Sets the data of the sound from an audiobuffer
  93190. * @param audioBuffer The audioBuffer containing the data
  93191. */
  93192. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93193. /**
  93194. * Updates the current sounds options such as maxdistance, loop...
  93195. * @param options A JSON object containing values named as the object properties
  93196. */
  93197. updateOptions(options: any): void;
  93198. private _createSpatialParameters;
  93199. private _updateSpatialParameters;
  93200. /**
  93201. * Switch the panning model to HRTF:
  93202. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93204. */
  93205. switchPanningModelToHRTF(): void;
  93206. /**
  93207. * Switch the panning model to Equal Power:
  93208. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93210. */
  93211. switchPanningModelToEqualPower(): void;
  93212. private _switchPanningModel;
  93213. /**
  93214. * Connect this sound to a sound track audio node like gain...
  93215. * @param soundTrackAudioNode the sound track audio node to connect to
  93216. */
  93217. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93218. /**
  93219. * Transform this sound into a directional source
  93220. * @param coneInnerAngle Size of the inner cone in degree
  93221. * @param coneOuterAngle Size of the outer cone in degree
  93222. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93223. */
  93224. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93225. /**
  93226. * Gets or sets the inner angle for the directional cone.
  93227. */
  93228. /**
  93229. * Gets or sets the inner angle for the directional cone.
  93230. */
  93231. directionalConeInnerAngle: number;
  93232. /**
  93233. * Gets or sets the outer angle for the directional cone.
  93234. */
  93235. /**
  93236. * Gets or sets the outer angle for the directional cone.
  93237. */
  93238. directionalConeOuterAngle: number;
  93239. /**
  93240. * Sets the position of the emitter if spatial sound is enabled
  93241. * @param newPosition Defines the new posisiton
  93242. */
  93243. setPosition(newPosition: Vector3): void;
  93244. /**
  93245. * Sets the local direction of the emitter if spatial sound is enabled
  93246. * @param newLocalDirection Defines the new local direction
  93247. */
  93248. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93249. private _updateDirection;
  93250. /** @hidden */
  93251. updateDistanceFromListener(): void;
  93252. /**
  93253. * Sets a new custom attenuation function for the sound.
  93254. * @param callback Defines the function used for the attenuation
  93255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93256. */
  93257. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93258. /**
  93259. * Play the sound
  93260. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93261. * @param offset (optional) Start the sound setting it at a specific time
  93262. */
  93263. play(time?: number, offset?: number): void;
  93264. private _onended;
  93265. /**
  93266. * Stop the sound
  93267. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93268. */
  93269. stop(time?: number): void;
  93270. /**
  93271. * Put the sound in pause
  93272. */
  93273. pause(): void;
  93274. /**
  93275. * Sets a dedicated volume for this sounds
  93276. * @param newVolume Define the new volume of the sound
  93277. * @param time Define in how long the sound should be at this value
  93278. */
  93279. setVolume(newVolume: number, time?: number): void;
  93280. /**
  93281. * Set the sound play back rate
  93282. * @param newPlaybackRate Define the playback rate the sound should be played at
  93283. */
  93284. setPlaybackRate(newPlaybackRate: number): void;
  93285. /**
  93286. * Gets the volume of the sound.
  93287. * @returns the volume of the sound
  93288. */
  93289. getVolume(): number;
  93290. /**
  93291. * Attach the sound to a dedicated mesh
  93292. * @param transformNode The transform node to connect the sound with
  93293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93294. */
  93295. attachToMesh(transformNode: TransformNode): void;
  93296. /**
  93297. * Detach the sound from the previously attached mesh
  93298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93299. */
  93300. detachFromMesh(): void;
  93301. private _onRegisterAfterWorldMatrixUpdate;
  93302. /**
  93303. * Clone the current sound in the scene.
  93304. * @returns the new sound clone
  93305. */
  93306. clone(): Nullable<Sound>;
  93307. /**
  93308. * Gets the current underlying audio buffer containing the data
  93309. * @returns the audio buffer
  93310. */
  93311. getAudioBuffer(): Nullable<AudioBuffer>;
  93312. /**
  93313. * Serializes the Sound in a JSON representation
  93314. * @returns the JSON representation of the sound
  93315. */
  93316. serialize(): any;
  93317. /**
  93318. * Parse a JSON representation of a sound to innstantiate in a given scene
  93319. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  93320. * @param scene Define the scene the new parsed sound should be created in
  93321. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  93322. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  93323. * @returns the newly parsed sound
  93324. */
  93325. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  93326. }
  93327. }
  93328. declare module BABYLON {
  93329. /**
  93330. * This defines an action helpful to play a defined sound on a triggered action.
  93331. */
  93332. export class PlaySoundAction extends Action {
  93333. private _sound;
  93334. /**
  93335. * Instantiate the action
  93336. * @param triggerOptions defines the trigger options
  93337. * @param sound defines the sound to play
  93338. * @param condition defines the trigger related conditions
  93339. */
  93340. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93341. /** @hidden */
  93342. _prepare(): void;
  93343. /**
  93344. * Execute the action and play the sound.
  93345. */
  93346. execute(): void;
  93347. /**
  93348. * Serializes the actions and its related information.
  93349. * @param parent defines the object to serialize in
  93350. * @returns the serialized object
  93351. */
  93352. serialize(parent: any): any;
  93353. }
  93354. /**
  93355. * This defines an action helpful to stop a defined sound on a triggered action.
  93356. */
  93357. export class StopSoundAction extends Action {
  93358. private _sound;
  93359. /**
  93360. * Instantiate the action
  93361. * @param triggerOptions defines the trigger options
  93362. * @param sound defines the sound to stop
  93363. * @param condition defines the trigger related conditions
  93364. */
  93365. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93366. /** @hidden */
  93367. _prepare(): void;
  93368. /**
  93369. * Execute the action and stop the sound.
  93370. */
  93371. execute(): void;
  93372. /**
  93373. * Serializes the actions and its related information.
  93374. * @param parent defines the object to serialize in
  93375. * @returns the serialized object
  93376. */
  93377. serialize(parent: any): any;
  93378. }
  93379. }
  93380. declare module BABYLON {
  93381. /**
  93382. * This defines an action responsible to change the value of a property
  93383. * by interpolating between its current value and the newly set one once triggered.
  93384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93385. */
  93386. export class InterpolateValueAction extends Action {
  93387. /**
  93388. * Defines the path of the property where the value should be interpolated
  93389. */
  93390. propertyPath: string;
  93391. /**
  93392. * Defines the target value at the end of the interpolation.
  93393. */
  93394. value: any;
  93395. /**
  93396. * Defines the time it will take for the property to interpolate to the value.
  93397. */
  93398. duration: number;
  93399. /**
  93400. * Defines if the other scene animations should be stopped when the action has been triggered
  93401. */
  93402. stopOtherAnimations?: boolean;
  93403. /**
  93404. * Defines a callback raised once the interpolation animation has been done.
  93405. */
  93406. onInterpolationDone?: () => void;
  93407. /**
  93408. * Observable triggered once the interpolation animation has been done.
  93409. */
  93410. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93411. private _target;
  93412. private _effectiveTarget;
  93413. private _property;
  93414. /**
  93415. * Instantiate the action
  93416. * @param triggerOptions defines the trigger options
  93417. * @param target defines the object containing the value to interpolate
  93418. * @param propertyPath defines the path to the property in the target object
  93419. * @param value defines the target value at the end of the interpolation
  93420. * @param duration deines the time it will take for the property to interpolate to the value.
  93421. * @param condition defines the trigger related conditions
  93422. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93423. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93424. */
  93425. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93426. /** @hidden */
  93427. _prepare(): void;
  93428. /**
  93429. * Execute the action starts the value interpolation.
  93430. */
  93431. execute(): void;
  93432. /**
  93433. * Serializes the actions and its related information.
  93434. * @param parent defines the object to serialize in
  93435. * @returns the serialized object
  93436. */
  93437. serialize(parent: any): any;
  93438. }
  93439. }
  93440. declare module BABYLON {
  93441. /**
  93442. * Options allowed during the creation of a sound track.
  93443. */
  93444. export interface ISoundTrackOptions {
  93445. /**
  93446. * The volume the sound track should take during creation
  93447. */
  93448. volume?: number;
  93449. /**
  93450. * Define if the sound track is the main sound track of the scene
  93451. */
  93452. mainTrack?: boolean;
  93453. }
  93454. /**
  93455. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93456. * It will be also used in a future release to apply effects on a specific track.
  93457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93458. */
  93459. export class SoundTrack {
  93460. /**
  93461. * The unique identifier of the sound track in the scene.
  93462. */
  93463. id: number;
  93464. /**
  93465. * The list of sounds included in the sound track.
  93466. */
  93467. soundCollection: Array<Sound>;
  93468. private _outputAudioNode;
  93469. private _scene;
  93470. private _isMainTrack;
  93471. private _connectedAnalyser;
  93472. private _options;
  93473. private _isInitialized;
  93474. /**
  93475. * Creates a new sound track.
  93476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93477. * @param scene Define the scene the sound track belongs to
  93478. * @param options
  93479. */
  93480. constructor(scene: Scene, options?: ISoundTrackOptions);
  93481. private _initializeSoundTrackAudioGraph;
  93482. /**
  93483. * Release the sound track and its associated resources
  93484. */
  93485. dispose(): void;
  93486. /**
  93487. * Adds a sound to this sound track
  93488. * @param sound define the cound to add
  93489. * @ignoreNaming
  93490. */
  93491. AddSound(sound: Sound): void;
  93492. /**
  93493. * Removes a sound to this sound track
  93494. * @param sound define the cound to remove
  93495. * @ignoreNaming
  93496. */
  93497. RemoveSound(sound: Sound): void;
  93498. /**
  93499. * Set a global volume for the full sound track.
  93500. * @param newVolume Define the new volume of the sound track
  93501. */
  93502. setVolume(newVolume: number): void;
  93503. /**
  93504. * Switch the panning model to HRTF:
  93505. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93507. */
  93508. switchPanningModelToHRTF(): void;
  93509. /**
  93510. * Switch the panning model to Equal Power:
  93511. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93513. */
  93514. switchPanningModelToEqualPower(): void;
  93515. /**
  93516. * Connect the sound track to an audio analyser allowing some amazing
  93517. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93519. * @param analyser The analyser to connect to the engine
  93520. */
  93521. connectToAnalyser(analyser: Analyser): void;
  93522. }
  93523. }
  93524. declare module BABYLON {
  93525. interface AbstractScene {
  93526. /**
  93527. * The list of sounds used in the scene.
  93528. */
  93529. sounds: Nullable<Array<Sound>>;
  93530. }
  93531. interface Scene {
  93532. /**
  93533. * @hidden
  93534. * Backing field
  93535. */
  93536. _mainSoundTrack: SoundTrack;
  93537. /**
  93538. * The main sound track played by the scene.
  93539. * It cotains your primary collection of sounds.
  93540. */
  93541. mainSoundTrack: SoundTrack;
  93542. /**
  93543. * The list of sound tracks added to the scene
  93544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93545. */
  93546. soundTracks: Nullable<Array<SoundTrack>>;
  93547. /**
  93548. * Gets a sound using a given name
  93549. * @param name defines the name to search for
  93550. * @return the found sound or null if not found at all.
  93551. */
  93552. getSoundByName(name: string): Nullable<Sound>;
  93553. /**
  93554. * Gets or sets if audio support is enabled
  93555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93556. */
  93557. audioEnabled: boolean;
  93558. /**
  93559. * Gets or sets if audio will be output to headphones
  93560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93561. */
  93562. headphone: boolean;
  93563. }
  93564. /**
  93565. * Defines the sound scene component responsible to manage any sounds
  93566. * in a given scene.
  93567. */
  93568. export class AudioSceneComponent implements ISceneSerializableComponent {
  93569. /**
  93570. * The component name helpfull to identify the component in the list of scene components.
  93571. */
  93572. readonly name: string;
  93573. /**
  93574. * The scene the component belongs to.
  93575. */
  93576. scene: Scene;
  93577. private _audioEnabled;
  93578. /**
  93579. * Gets whether audio is enabled or not.
  93580. * Please use related enable/disable method to switch state.
  93581. */
  93582. readonly audioEnabled: boolean;
  93583. private _headphone;
  93584. /**
  93585. * Gets whether audio is outputing to headphone or not.
  93586. * Please use the according Switch methods to change output.
  93587. */
  93588. readonly headphone: boolean;
  93589. /**
  93590. * Creates a new instance of the component for the given scene
  93591. * @param scene Defines the scene to register the component in
  93592. */
  93593. constructor(scene: Scene);
  93594. /**
  93595. * Registers the component in a given scene
  93596. */
  93597. register(): void;
  93598. /**
  93599. * Rebuilds the elements related to this component in case of
  93600. * context lost for instance.
  93601. */
  93602. rebuild(): void;
  93603. /**
  93604. * Serializes the component data to the specified json object
  93605. * @param serializationObject The object to serialize to
  93606. */
  93607. serialize(serializationObject: any): void;
  93608. /**
  93609. * Adds all the element from the container to the scene
  93610. * @param container the container holding the elements
  93611. */
  93612. addFromContainer(container: AbstractScene): void;
  93613. /**
  93614. * Removes all the elements in the container from the scene
  93615. * @param container contains the elements to remove
  93616. * @param dispose if the removed element should be disposed (default: false)
  93617. */
  93618. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93619. /**
  93620. * Disposes the component and the associated ressources.
  93621. */
  93622. dispose(): void;
  93623. /**
  93624. * Disables audio in the associated scene.
  93625. */
  93626. disableAudio(): void;
  93627. /**
  93628. * Enables audio in the associated scene.
  93629. */
  93630. enableAudio(): void;
  93631. /**
  93632. * Switch audio to headphone output.
  93633. */
  93634. switchAudioModeForHeadphones(): void;
  93635. /**
  93636. * Switch audio to normal speakers.
  93637. */
  93638. switchAudioModeForNormalSpeakers(): void;
  93639. private _afterRender;
  93640. }
  93641. }
  93642. declare module BABYLON {
  93643. /**
  93644. * Wraps one or more Sound objects and selects one with random weight for playback.
  93645. */
  93646. export class WeightedSound {
  93647. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93648. loop: boolean;
  93649. private _coneInnerAngle;
  93650. private _coneOuterAngle;
  93651. private _volume;
  93652. /** A Sound is currently playing. */
  93653. isPlaying: boolean;
  93654. /** A Sound is currently paused. */
  93655. isPaused: boolean;
  93656. private _sounds;
  93657. private _weights;
  93658. private _currentIndex?;
  93659. /**
  93660. * Creates a new WeightedSound from the list of sounds given.
  93661. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  93662. * @param sounds Array of Sounds that will be selected from.
  93663. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  93664. */
  93665. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  93666. /**
  93667. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  93668. */
  93669. /**
  93670. * The size of cone in degress for a directional sound in which there will be no attenuation.
  93671. */
  93672. directionalConeInnerAngle: number;
  93673. /**
  93674. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93675. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93676. */
  93677. /**
  93678. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93679. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93680. */
  93681. directionalConeOuterAngle: number;
  93682. /**
  93683. * Playback volume.
  93684. */
  93685. /**
  93686. * Playback volume.
  93687. */
  93688. volume: number;
  93689. private _onended;
  93690. /**
  93691. * Suspend playback
  93692. */
  93693. pause(): void;
  93694. /**
  93695. * Stop playback
  93696. */
  93697. stop(): void;
  93698. /**
  93699. * Start playback.
  93700. * @param startOffset Position the clip head at a specific time in seconds.
  93701. */
  93702. play(startOffset?: number): void;
  93703. }
  93704. }
  93705. declare module BABYLON {
  93706. /**
  93707. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  93708. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93709. */
  93710. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  93711. /**
  93712. * Gets the name of the behavior.
  93713. */
  93714. readonly name: string;
  93715. /**
  93716. * The easing function used by animations
  93717. */
  93718. static EasingFunction: BackEase;
  93719. /**
  93720. * The easing mode used by animations
  93721. */
  93722. static EasingMode: number;
  93723. /**
  93724. * The duration of the animation, in milliseconds
  93725. */
  93726. transitionDuration: number;
  93727. /**
  93728. * Length of the distance animated by the transition when lower radius is reached
  93729. */
  93730. lowerRadiusTransitionRange: number;
  93731. /**
  93732. * Length of the distance animated by the transition when upper radius is reached
  93733. */
  93734. upperRadiusTransitionRange: number;
  93735. private _autoTransitionRange;
  93736. /**
  93737. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93738. */
  93739. /**
  93740. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93741. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  93742. */
  93743. autoTransitionRange: boolean;
  93744. private _attachedCamera;
  93745. private _onAfterCheckInputsObserver;
  93746. private _onMeshTargetChangedObserver;
  93747. /**
  93748. * Initializes the behavior.
  93749. */
  93750. init(): void;
  93751. /**
  93752. * Attaches the behavior to its arc rotate camera.
  93753. * @param camera Defines the camera to attach the behavior to
  93754. */
  93755. attach(camera: ArcRotateCamera): void;
  93756. /**
  93757. * Detaches the behavior from its current arc rotate camera.
  93758. */
  93759. detach(): void;
  93760. private _radiusIsAnimating;
  93761. private _radiusBounceTransition;
  93762. private _animatables;
  93763. private _cachedWheelPrecision;
  93764. /**
  93765. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  93766. * @param radiusLimit The limit to check against.
  93767. * @return Bool to indicate if at limit.
  93768. */
  93769. private _isRadiusAtLimit;
  93770. /**
  93771. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  93772. * @param radiusDelta The delta by which to animate to. Can be negative.
  93773. */
  93774. private _applyBoundRadiusAnimation;
  93775. /**
  93776. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  93777. */
  93778. protected _clearAnimationLocks(): void;
  93779. /**
  93780. * Stops and removes all animations that have been applied to the camera
  93781. */
  93782. stopAllAnimations(): void;
  93783. }
  93784. }
  93785. declare module BABYLON {
  93786. /**
  93787. * 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.
  93788. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93789. */
  93790. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93791. /**
  93792. * Gets the name of the behavior.
  93793. */
  93794. readonly name: string;
  93795. private _mode;
  93796. private _radiusScale;
  93797. private _positionScale;
  93798. private _defaultElevation;
  93799. private _elevationReturnTime;
  93800. private _elevationReturnWaitTime;
  93801. private _zoomStopsAnimation;
  93802. private _framingTime;
  93803. /**
  93804. * The easing function used by animations
  93805. */
  93806. static EasingFunction: ExponentialEase;
  93807. /**
  93808. * The easing mode used by animations
  93809. */
  93810. static EasingMode: number;
  93811. /**
  93812. * Sets the current mode used by the behavior
  93813. */
  93814. /**
  93815. * Gets current mode used by the behavior.
  93816. */
  93817. mode: number;
  93818. /**
  93819. * Sets the scale applied to the radius (1 by default)
  93820. */
  93821. /**
  93822. * Gets the scale applied to the radius
  93823. */
  93824. radiusScale: number;
  93825. /**
  93826. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93827. */
  93828. /**
  93829. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93830. */
  93831. positionScale: number;
  93832. /**
  93833. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93834. * behaviour is triggered, in radians.
  93835. */
  93836. /**
  93837. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93838. * behaviour is triggered, in radians.
  93839. */
  93840. defaultElevation: number;
  93841. /**
  93842. * Sets the time (in milliseconds) taken to return to the default beta position.
  93843. * Negative value indicates camera should not return to default.
  93844. */
  93845. /**
  93846. * Gets the time (in milliseconds) taken to return to the default beta position.
  93847. * Negative value indicates camera should not return to default.
  93848. */
  93849. elevationReturnTime: number;
  93850. /**
  93851. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93852. */
  93853. /**
  93854. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93855. */
  93856. elevationReturnWaitTime: number;
  93857. /**
  93858. * Sets the flag that indicates if user zooming should stop animation.
  93859. */
  93860. /**
  93861. * Gets the flag that indicates if user zooming should stop animation.
  93862. */
  93863. zoomStopsAnimation: boolean;
  93864. /**
  93865. * Sets the transition time when framing the mesh, in milliseconds
  93866. */
  93867. /**
  93868. * Gets the transition time when framing the mesh, in milliseconds
  93869. */
  93870. framingTime: number;
  93871. /**
  93872. * Define if the behavior should automatically change the configured
  93873. * camera limits and sensibilities.
  93874. */
  93875. autoCorrectCameraLimitsAndSensibility: boolean;
  93876. private _onPrePointerObservableObserver;
  93877. private _onAfterCheckInputsObserver;
  93878. private _onMeshTargetChangedObserver;
  93879. private _attachedCamera;
  93880. private _isPointerDown;
  93881. private _lastInteractionTime;
  93882. /**
  93883. * Initializes the behavior.
  93884. */
  93885. init(): void;
  93886. /**
  93887. * Attaches the behavior to its arc rotate camera.
  93888. * @param camera Defines the camera to attach the behavior to
  93889. */
  93890. attach(camera: ArcRotateCamera): void;
  93891. /**
  93892. * Detaches the behavior from its current arc rotate camera.
  93893. */
  93894. detach(): void;
  93895. private _animatables;
  93896. private _betaIsAnimating;
  93897. private _betaTransition;
  93898. private _radiusTransition;
  93899. private _vectorTransition;
  93900. /**
  93901. * Targets the given mesh and updates zoom level accordingly.
  93902. * @param mesh The mesh to target.
  93903. * @param radius Optional. If a cached radius position already exists, overrides default.
  93904. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93905. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93906. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93907. */
  93908. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93909. /**
  93910. * Targets the given mesh with its children and updates zoom level accordingly.
  93911. * @param mesh The mesh to target.
  93912. * @param radius Optional. If a cached radius position already exists, overrides default.
  93913. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93914. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93915. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93916. */
  93917. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93918. /**
  93919. * Targets the given meshes with their children and updates zoom level accordingly.
  93920. * @param meshes The mesh to target.
  93921. * @param radius Optional. If a cached radius position already exists, overrides default.
  93922. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93923. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93924. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93925. */
  93926. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93927. /**
  93928. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  93929. * @param minimumWorld Determines the smaller position of the bounding box extend
  93930. * @param maximumWorld Determines the bigger position of the bounding box extend
  93931. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93932. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93933. */
  93934. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93935. /**
  93936. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  93937. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  93938. * frustum width.
  93939. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  93940. * to fully enclose the mesh in the viewing frustum.
  93941. */
  93942. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  93943. /**
  93944. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  93945. * is automatically returned to its default position (expected to be above ground plane).
  93946. */
  93947. private _maintainCameraAboveGround;
  93948. /**
  93949. * Returns the frustum slope based on the canvas ratio and camera FOV
  93950. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  93951. */
  93952. private _getFrustumSlope;
  93953. /**
  93954. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  93955. */
  93956. private _clearAnimationLocks;
  93957. /**
  93958. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93959. */
  93960. private _applyUserInteraction;
  93961. /**
  93962. * Stops and removes all animations that have been applied to the camera
  93963. */
  93964. stopAllAnimations(): void;
  93965. /**
  93966. * Gets a value indicating if the user is moving the camera
  93967. */
  93968. readonly isUserIsMoving: boolean;
  93969. /**
  93970. * The camera can move all the way towards the mesh.
  93971. */
  93972. static IgnoreBoundsSizeMode: number;
  93973. /**
  93974. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  93975. */
  93976. static FitFrustumSidesMode: number;
  93977. }
  93978. }
  93979. declare module BABYLON {
  93980. /**
  93981. * Base class for Camera Pointer Inputs.
  93982. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  93983. * for example usage.
  93984. */
  93985. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  93986. /**
  93987. * Defines the camera the input is attached to.
  93988. */
  93989. abstract camera: Camera;
  93990. /**
  93991. * Whether keyboard modifier keys are pressed at time of last mouse event.
  93992. */
  93993. protected _altKey: boolean;
  93994. protected _ctrlKey: boolean;
  93995. protected _metaKey: boolean;
  93996. protected _shiftKey: boolean;
  93997. /**
  93998. * Which mouse buttons were pressed at time of last mouse event.
  93999. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94000. */
  94001. protected _buttonsPressed: number;
  94002. /**
  94003. * Defines the buttons associated with the input to handle camera move.
  94004. */
  94005. buttons: number[];
  94006. /**
  94007. * Attach the input controls to a specific dom element to get the input from.
  94008. * @param element Defines the element the controls should be listened from
  94009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94010. */
  94011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94012. /**
  94013. * Detach the current controls from the specified dom element.
  94014. * @param element Defines the element to stop listening the inputs from
  94015. */
  94016. detachControl(element: Nullable<HTMLElement>): void;
  94017. /**
  94018. * Gets the class name of the current input.
  94019. * @returns the class name
  94020. */
  94021. getClassName(): string;
  94022. /**
  94023. * Get the friendly name associated with the input class.
  94024. * @returns the input friendly name
  94025. */
  94026. getSimpleName(): string;
  94027. /**
  94028. * Called on pointer POINTERDOUBLETAP event.
  94029. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94030. */
  94031. protected onDoubleTap(type: string): void;
  94032. /**
  94033. * Called on pointer POINTERMOVE event if only a single touch is active.
  94034. * Override this method to provide functionality.
  94035. */
  94036. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94037. /**
  94038. * Called on pointer POINTERMOVE event if multiple touches are active.
  94039. * Override this method to provide functionality.
  94040. */
  94041. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94042. /**
  94043. * Called on JS contextmenu event.
  94044. * Override this method to provide functionality.
  94045. */
  94046. protected onContextMenu(evt: PointerEvent): void;
  94047. /**
  94048. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94049. * press.
  94050. * Override this method to provide functionality.
  94051. */
  94052. protected onButtonDown(evt: PointerEvent): void;
  94053. /**
  94054. * Called each time a new POINTERUP event occurs. Ie, for each button
  94055. * release.
  94056. * Override this method to provide functionality.
  94057. */
  94058. protected onButtonUp(evt: PointerEvent): void;
  94059. /**
  94060. * Called when window becomes inactive.
  94061. * Override this method to provide functionality.
  94062. */
  94063. protected onLostFocus(): void;
  94064. private _pointerInput;
  94065. private _observer;
  94066. private _onLostFocus;
  94067. private pointA;
  94068. private pointB;
  94069. }
  94070. }
  94071. declare module BABYLON {
  94072. /**
  94073. * Manage the pointers inputs to control an arc rotate camera.
  94074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94075. */
  94076. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94077. /**
  94078. * Defines the camera the input is attached to.
  94079. */
  94080. camera: ArcRotateCamera;
  94081. /**
  94082. * Gets the class name of the current input.
  94083. * @returns the class name
  94084. */
  94085. getClassName(): string;
  94086. /**
  94087. * Defines the buttons associated with the input to handle camera move.
  94088. */
  94089. buttons: number[];
  94090. /**
  94091. * Defines the pointer angular sensibility along the X axis or how fast is
  94092. * the camera rotating.
  94093. */
  94094. angularSensibilityX: number;
  94095. /**
  94096. * Defines the pointer angular sensibility along the Y axis or how fast is
  94097. * the camera rotating.
  94098. */
  94099. angularSensibilityY: number;
  94100. /**
  94101. * Defines the pointer pinch precision or how fast is the camera zooming.
  94102. */
  94103. pinchPrecision: number;
  94104. /**
  94105. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94106. * from 0.
  94107. * It defines the percentage of current camera.radius to use as delta when
  94108. * pinch zoom is used.
  94109. */
  94110. pinchDeltaPercentage: number;
  94111. /**
  94112. * Defines the pointer panning sensibility or how fast is the camera moving.
  94113. */
  94114. panningSensibility: number;
  94115. /**
  94116. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94117. */
  94118. multiTouchPanning: boolean;
  94119. /**
  94120. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94121. * zoom (pinch) through multitouch.
  94122. */
  94123. multiTouchPanAndZoom: boolean;
  94124. /**
  94125. * Revers pinch action direction.
  94126. */
  94127. pinchInwards: boolean;
  94128. private _isPanClick;
  94129. private _twoFingerActivityCount;
  94130. private _isPinching;
  94131. /**
  94132. * Called on pointer POINTERMOVE event if only a single touch is active.
  94133. */
  94134. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94135. /**
  94136. * Called on pointer POINTERDOUBLETAP event.
  94137. */
  94138. protected onDoubleTap(type: string): void;
  94139. /**
  94140. * Called on pointer POINTERMOVE event if multiple touches are active.
  94141. */
  94142. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94143. /**
  94144. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94145. * press.
  94146. */
  94147. protected onButtonDown(evt: PointerEvent): void;
  94148. /**
  94149. * Called each time a new POINTERUP event occurs. Ie, for each button
  94150. * release.
  94151. */
  94152. protected onButtonUp(evt: PointerEvent): void;
  94153. /**
  94154. * Called when window becomes inactive.
  94155. */
  94156. protected onLostFocus(): void;
  94157. }
  94158. }
  94159. declare module BABYLON {
  94160. /**
  94161. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94163. */
  94164. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94165. /**
  94166. * Defines the camera the input is attached to.
  94167. */
  94168. camera: ArcRotateCamera;
  94169. /**
  94170. * Defines the list of key codes associated with the up action (increase alpha)
  94171. */
  94172. keysUp: number[];
  94173. /**
  94174. * Defines the list of key codes associated with the down action (decrease alpha)
  94175. */
  94176. keysDown: number[];
  94177. /**
  94178. * Defines the list of key codes associated with the left action (increase beta)
  94179. */
  94180. keysLeft: number[];
  94181. /**
  94182. * Defines the list of key codes associated with the right action (decrease beta)
  94183. */
  94184. keysRight: number[];
  94185. /**
  94186. * Defines the list of key codes associated with the reset action.
  94187. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94188. */
  94189. keysReset: number[];
  94190. /**
  94191. * Defines the panning sensibility of the inputs.
  94192. * (How fast is the camera paning)
  94193. */
  94194. panningSensibility: number;
  94195. /**
  94196. * Defines the zooming sensibility of the inputs.
  94197. * (How fast is the camera zooming)
  94198. */
  94199. zoomingSensibility: number;
  94200. /**
  94201. * Defines wether maintaining the alt key down switch the movement mode from
  94202. * orientation to zoom.
  94203. */
  94204. useAltToZoom: boolean;
  94205. /**
  94206. * Rotation speed of the camera
  94207. */
  94208. angularSpeed: number;
  94209. private _keys;
  94210. private _ctrlPressed;
  94211. private _altPressed;
  94212. private _onCanvasBlurObserver;
  94213. private _onKeyboardObserver;
  94214. private _engine;
  94215. private _scene;
  94216. /**
  94217. * Attach the input controls to a specific dom element to get the input from.
  94218. * @param element Defines the element the controls should be listened from
  94219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94220. */
  94221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94222. /**
  94223. * Detach the current controls from the specified dom element.
  94224. * @param element Defines the element to stop listening the inputs from
  94225. */
  94226. detachControl(element: Nullable<HTMLElement>): void;
  94227. /**
  94228. * Update the current camera state depending on the inputs that have been used this frame.
  94229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94230. */
  94231. checkInputs(): void;
  94232. /**
  94233. * Gets the class name of the current intput.
  94234. * @returns the class name
  94235. */
  94236. getClassName(): string;
  94237. /**
  94238. * Get the friendly name associated with the input class.
  94239. * @returns the input friendly name
  94240. */
  94241. getSimpleName(): string;
  94242. }
  94243. }
  94244. declare module BABYLON {
  94245. /**
  94246. * Manage the mouse wheel inputs to control an arc rotate camera.
  94247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94248. */
  94249. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94250. /**
  94251. * Defines the camera the input is attached to.
  94252. */
  94253. camera: ArcRotateCamera;
  94254. /**
  94255. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94256. */
  94257. wheelPrecision: number;
  94258. /**
  94259. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94260. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94261. */
  94262. wheelDeltaPercentage: number;
  94263. private _wheel;
  94264. private _observer;
  94265. /**
  94266. * Attach the input controls to a specific dom element to get the input from.
  94267. * @param element Defines the element the controls should be listened from
  94268. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94269. */
  94270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94271. /**
  94272. * Detach the current controls from the specified dom element.
  94273. * @param element Defines the element to stop listening the inputs from
  94274. */
  94275. detachControl(element: Nullable<HTMLElement>): void;
  94276. /**
  94277. * Gets the class name of the current intput.
  94278. * @returns the class name
  94279. */
  94280. getClassName(): string;
  94281. /**
  94282. * Get the friendly name associated with the input class.
  94283. * @returns the input friendly name
  94284. */
  94285. getSimpleName(): string;
  94286. }
  94287. }
  94288. declare module BABYLON {
  94289. /**
  94290. * Default Inputs manager for the ArcRotateCamera.
  94291. * It groups all the default supported inputs for ease of use.
  94292. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94293. */
  94294. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94295. /**
  94296. * Instantiates a new ArcRotateCameraInputsManager.
  94297. * @param camera Defines the camera the inputs belong to
  94298. */
  94299. constructor(camera: ArcRotateCamera);
  94300. /**
  94301. * Add mouse wheel input support to the input manager.
  94302. * @returns the current input manager
  94303. */
  94304. addMouseWheel(): ArcRotateCameraInputsManager;
  94305. /**
  94306. * Add pointers input support to the input manager.
  94307. * @returns the current input manager
  94308. */
  94309. addPointers(): ArcRotateCameraInputsManager;
  94310. /**
  94311. * Add keyboard input support to the input manager.
  94312. * @returns the current input manager
  94313. */
  94314. addKeyboard(): ArcRotateCameraInputsManager;
  94315. }
  94316. }
  94317. declare module BABYLON {
  94318. /**
  94319. * This represents an orbital type of camera.
  94320. *
  94321. * 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.
  94322. * 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.
  94323. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  94324. */
  94325. export class ArcRotateCamera extends TargetCamera {
  94326. /**
  94327. * Defines the rotation angle of the camera along the longitudinal axis.
  94328. */
  94329. alpha: number;
  94330. /**
  94331. * Defines the rotation angle of the camera along the latitudinal axis.
  94332. */
  94333. beta: number;
  94334. /**
  94335. * Defines the radius of the camera from it s target point.
  94336. */
  94337. radius: number;
  94338. protected _target: Vector3;
  94339. protected _targetHost: Nullable<AbstractMesh>;
  94340. /**
  94341. * Defines the target point of the camera.
  94342. * The camera looks towards it form the radius distance.
  94343. */
  94344. target: Vector3;
  94345. /**
  94346. * Define the current local position of the camera in the scene
  94347. */
  94348. position: Vector3;
  94349. protected _upVector: Vector3;
  94350. protected _upToYMatrix: Matrix;
  94351. protected _YToUpMatrix: Matrix;
  94352. /**
  94353. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  94354. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  94355. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  94356. */
  94357. upVector: Vector3;
  94358. /**
  94359. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  94360. */
  94361. setMatUp(): void;
  94362. /**
  94363. * Current inertia value on the longitudinal axis.
  94364. * The bigger this number the longer it will take for the camera to stop.
  94365. */
  94366. inertialAlphaOffset: number;
  94367. /**
  94368. * Current inertia value on the latitudinal axis.
  94369. * The bigger this number the longer it will take for the camera to stop.
  94370. */
  94371. inertialBetaOffset: number;
  94372. /**
  94373. * Current inertia value on the radius axis.
  94374. * The bigger this number the longer it will take for the camera to stop.
  94375. */
  94376. inertialRadiusOffset: number;
  94377. /**
  94378. * Minimum allowed angle on the longitudinal axis.
  94379. * This can help limiting how the Camera is able to move in the scene.
  94380. */
  94381. lowerAlphaLimit: Nullable<number>;
  94382. /**
  94383. * Maximum allowed angle on the longitudinal axis.
  94384. * This can help limiting how the Camera is able to move in the scene.
  94385. */
  94386. upperAlphaLimit: Nullable<number>;
  94387. /**
  94388. * Minimum allowed angle on the latitudinal axis.
  94389. * This can help limiting how the Camera is able to move in the scene.
  94390. */
  94391. lowerBetaLimit: number;
  94392. /**
  94393. * Maximum allowed angle on the latitudinal axis.
  94394. * This can help limiting how the Camera is able to move in the scene.
  94395. */
  94396. upperBetaLimit: number;
  94397. /**
  94398. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94399. * This can help limiting how the Camera is able to move in the scene.
  94400. */
  94401. lowerRadiusLimit: Nullable<number>;
  94402. /**
  94403. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94404. * This can help limiting how the Camera is able to move in the scene.
  94405. */
  94406. upperRadiusLimit: Nullable<number>;
  94407. /**
  94408. * Defines the current inertia value used during panning of the camera along the X axis.
  94409. */
  94410. inertialPanningX: number;
  94411. /**
  94412. * Defines the current inertia value used during panning of the camera along the Y axis.
  94413. */
  94414. inertialPanningY: number;
  94415. /**
  94416. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94417. * Basically if your fingers moves away from more than this distance you will be considered
  94418. * in pinch mode.
  94419. */
  94420. pinchToPanMaxDistance: number;
  94421. /**
  94422. * Defines the maximum distance the camera can pan.
  94423. * This could help keeping the cammera always in your scene.
  94424. */
  94425. panningDistanceLimit: Nullable<number>;
  94426. /**
  94427. * Defines the target of the camera before paning.
  94428. */
  94429. panningOriginTarget: Vector3;
  94430. /**
  94431. * Defines the value of the inertia used during panning.
  94432. * 0 would mean stop inertia and one would mean no decelleration at all.
  94433. */
  94434. panningInertia: number;
  94435. /**
  94436. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94437. */
  94438. angularSensibilityX: number;
  94439. /**
  94440. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94441. */
  94442. angularSensibilityY: number;
  94443. /**
  94444. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94445. */
  94446. pinchPrecision: number;
  94447. /**
  94448. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94449. * It will be used instead of pinchDeltaPrecision if different from 0.
  94450. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94451. */
  94452. pinchDeltaPercentage: number;
  94453. /**
  94454. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94455. */
  94456. panningSensibility: number;
  94457. /**
  94458. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94459. */
  94460. keysUp: number[];
  94461. /**
  94462. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94463. */
  94464. keysDown: number[];
  94465. /**
  94466. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94467. */
  94468. keysLeft: number[];
  94469. /**
  94470. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94471. */
  94472. keysRight: number[];
  94473. /**
  94474. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94475. */
  94476. wheelPrecision: number;
  94477. /**
  94478. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94479. * It will be used instead of pinchDeltaPrecision if different from 0.
  94480. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94481. */
  94482. wheelDeltaPercentage: number;
  94483. /**
  94484. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94485. */
  94486. zoomOnFactor: number;
  94487. /**
  94488. * Defines a screen offset for the camera position.
  94489. */
  94490. targetScreenOffset: Vector2;
  94491. /**
  94492. * Allows the camera to be completely reversed.
  94493. * If false the camera can not arrive upside down.
  94494. */
  94495. allowUpsideDown: boolean;
  94496. /**
  94497. * Define if double tap/click is used to restore the previously saved state of the camera.
  94498. */
  94499. useInputToRestoreState: boolean;
  94500. /** @hidden */
  94501. _viewMatrix: Matrix;
  94502. /** @hidden */
  94503. _useCtrlForPanning: boolean;
  94504. /** @hidden */
  94505. _panningMouseButton: number;
  94506. /**
  94507. * Defines the input associated to the camera.
  94508. */
  94509. inputs: ArcRotateCameraInputsManager;
  94510. /** @hidden */
  94511. _reset: () => void;
  94512. /**
  94513. * Defines the allowed panning axis.
  94514. */
  94515. panningAxis: Vector3;
  94516. protected _localDirection: Vector3;
  94517. protected _transformedDirection: Vector3;
  94518. private _bouncingBehavior;
  94519. /**
  94520. * Gets the bouncing behavior of the camera if it has been enabled.
  94521. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94522. */
  94523. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94524. /**
  94525. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94526. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94527. */
  94528. useBouncingBehavior: boolean;
  94529. private _framingBehavior;
  94530. /**
  94531. * Gets the framing behavior of the camera if it has been enabled.
  94532. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94533. */
  94534. readonly framingBehavior: Nullable<FramingBehavior>;
  94535. /**
  94536. * Defines if the framing behavior of the camera is enabled on the camera.
  94537. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94538. */
  94539. useFramingBehavior: boolean;
  94540. private _autoRotationBehavior;
  94541. /**
  94542. * Gets the auto rotation behavior of the camera if it has been enabled.
  94543. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94544. */
  94545. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94546. /**
  94547. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94548. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94549. */
  94550. useAutoRotationBehavior: boolean;
  94551. /**
  94552. * Observable triggered when the mesh target has been changed on the camera.
  94553. */
  94554. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94555. /**
  94556. * Event raised when the camera is colliding with a mesh.
  94557. */
  94558. onCollide: (collidedMesh: AbstractMesh) => void;
  94559. /**
  94560. * Defines whether the camera should check collision with the objects oh the scene.
  94561. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94562. */
  94563. checkCollisions: boolean;
  94564. /**
  94565. * Defines the collision radius of the camera.
  94566. * This simulates a sphere around the camera.
  94567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94568. */
  94569. collisionRadius: Vector3;
  94570. protected _collider: Collider;
  94571. protected _previousPosition: Vector3;
  94572. protected _collisionVelocity: Vector3;
  94573. protected _newPosition: Vector3;
  94574. protected _previousAlpha: number;
  94575. protected _previousBeta: number;
  94576. protected _previousRadius: number;
  94577. protected _collisionTriggered: boolean;
  94578. protected _targetBoundingCenter: Nullable<Vector3>;
  94579. private _computationVector;
  94580. /**
  94581. * Instantiates a new ArcRotateCamera in a given scene
  94582. * @param name Defines the name of the camera
  94583. * @param alpha Defines the camera rotation along the logitudinal axis
  94584. * @param beta Defines the camera rotation along the latitudinal axis
  94585. * @param radius Defines the camera distance from its target
  94586. * @param target Defines the camera target
  94587. * @param scene Defines the scene the camera belongs to
  94588. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94589. */
  94590. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94591. /** @hidden */
  94592. _initCache(): void;
  94593. /** @hidden */
  94594. _updateCache(ignoreParentClass?: boolean): void;
  94595. protected _getTargetPosition(): Vector3;
  94596. private _storedAlpha;
  94597. private _storedBeta;
  94598. private _storedRadius;
  94599. private _storedTarget;
  94600. /**
  94601. * Stores the current state of the camera (alpha, beta, radius and target)
  94602. * @returns the camera itself
  94603. */
  94604. storeState(): Camera;
  94605. /**
  94606. * @hidden
  94607. * Restored camera state. You must call storeState() first
  94608. */
  94609. _restoreStateValues(): boolean;
  94610. /** @hidden */
  94611. _isSynchronizedViewMatrix(): boolean;
  94612. /**
  94613. * Attached controls to the current camera.
  94614. * @param element Defines the element the controls should be listened from
  94615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94616. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94617. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94618. */
  94619. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94620. /**
  94621. * Detach the current controls from the camera.
  94622. * The camera will stop reacting to inputs.
  94623. * @param element Defines the element to stop listening the inputs from
  94624. */
  94625. detachControl(element: HTMLElement): void;
  94626. /** @hidden */
  94627. _checkInputs(): void;
  94628. protected _checkLimits(): void;
  94629. /**
  94630. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94631. */
  94632. rebuildAnglesAndRadius(): void;
  94633. /**
  94634. * Use a position to define the current camera related information like aplha, beta and radius
  94635. * @param position Defines the position to set the camera at
  94636. */
  94637. setPosition(position: Vector3): void;
  94638. /**
  94639. * Defines the target the camera should look at.
  94640. * This will automatically adapt alpha beta and radius to fit within the new target.
  94641. * @param target Defines the new target as a Vector or a mesh
  94642. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94643. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94644. */
  94645. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94646. /** @hidden */
  94647. _getViewMatrix(): Matrix;
  94648. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94649. /**
  94650. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  94651. * @param meshes Defines the mesh to zoom on
  94652. * @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)
  94653. */
  94654. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  94655. /**
  94656. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  94657. * The target will be changed but the radius
  94658. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  94659. * @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)
  94660. */
  94661. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  94662. min: Vector3;
  94663. max: Vector3;
  94664. distance: number;
  94665. }, doNotUpdateMaxZ?: boolean): void;
  94666. /**
  94667. * @override
  94668. * Override Camera.createRigCamera
  94669. */
  94670. createRigCamera(name: string, cameraIndex: number): Camera;
  94671. /**
  94672. * @hidden
  94673. * @override
  94674. * Override Camera._updateRigCameras
  94675. */
  94676. _updateRigCameras(): void;
  94677. /**
  94678. * Destroy the camera and release the current resources hold by it.
  94679. */
  94680. dispose(): void;
  94681. /**
  94682. * Gets the current object class name.
  94683. * @return the class name
  94684. */
  94685. getClassName(): string;
  94686. }
  94687. }
  94688. declare module BABYLON {
  94689. /**
  94690. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  94691. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94692. */
  94693. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  94694. /**
  94695. * Gets the name of the behavior.
  94696. */
  94697. readonly name: string;
  94698. private _zoomStopsAnimation;
  94699. private _idleRotationSpeed;
  94700. private _idleRotationWaitTime;
  94701. private _idleRotationSpinupTime;
  94702. /**
  94703. * Sets the flag that indicates if user zooming should stop animation.
  94704. */
  94705. /**
  94706. * Gets the flag that indicates if user zooming should stop animation.
  94707. */
  94708. zoomStopsAnimation: boolean;
  94709. /**
  94710. * Sets the default speed at which the camera rotates around the model.
  94711. */
  94712. /**
  94713. * Gets the default speed at which the camera rotates around the model.
  94714. */
  94715. idleRotationSpeed: number;
  94716. /**
  94717. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  94718. */
  94719. /**
  94720. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  94721. */
  94722. idleRotationWaitTime: number;
  94723. /**
  94724. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94725. */
  94726. /**
  94727. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94728. */
  94729. idleRotationSpinupTime: number;
  94730. /**
  94731. * Gets a value indicating if the camera is currently rotating because of this behavior
  94732. */
  94733. readonly rotationInProgress: boolean;
  94734. private _onPrePointerObservableObserver;
  94735. private _onAfterCheckInputsObserver;
  94736. private _attachedCamera;
  94737. private _isPointerDown;
  94738. private _lastFrameTime;
  94739. private _lastInteractionTime;
  94740. private _cameraRotationSpeed;
  94741. /**
  94742. * Initializes the behavior.
  94743. */
  94744. init(): void;
  94745. /**
  94746. * Attaches the behavior to its arc rotate camera.
  94747. * @param camera Defines the camera to attach the behavior to
  94748. */
  94749. attach(camera: ArcRotateCamera): void;
  94750. /**
  94751. * Detaches the behavior from its current arc rotate camera.
  94752. */
  94753. detach(): void;
  94754. /**
  94755. * Returns true if user is scrolling.
  94756. * @return true if user is scrolling.
  94757. */
  94758. private _userIsZooming;
  94759. private _lastFrameRadius;
  94760. private _shouldAnimationStopForInteraction;
  94761. /**
  94762. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94763. */
  94764. private _applyUserInteraction;
  94765. private _userIsMoving;
  94766. }
  94767. }
  94768. declare module BABYLON {
  94769. /**
  94770. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  94771. */
  94772. export class AttachToBoxBehavior implements Behavior<Mesh> {
  94773. private ui;
  94774. /**
  94775. * The name of the behavior
  94776. */
  94777. name: string;
  94778. /**
  94779. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  94780. */
  94781. distanceAwayFromFace: number;
  94782. /**
  94783. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  94784. */
  94785. distanceAwayFromBottomOfFace: number;
  94786. private _faceVectors;
  94787. private _target;
  94788. private _scene;
  94789. private _onRenderObserver;
  94790. private _tmpMatrix;
  94791. private _tmpVector;
  94792. /**
  94793. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94794. * @param ui The transform node that should be attched to the mesh
  94795. */
  94796. constructor(ui: TransformNode);
  94797. /**
  94798. * Initializes the behavior
  94799. */
  94800. init(): void;
  94801. private _closestFace;
  94802. private _zeroVector;
  94803. private _lookAtTmpMatrix;
  94804. private _lookAtToRef;
  94805. /**
  94806. * Attaches the AttachToBoxBehavior to the passed in mesh
  94807. * @param target The mesh that the specified node will be attached to
  94808. */
  94809. attach(target: Mesh): void;
  94810. /**
  94811. * Detaches the behavior from the mesh
  94812. */
  94813. detach(): void;
  94814. }
  94815. }
  94816. declare module BABYLON {
  94817. /**
  94818. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  94819. */
  94820. export class FadeInOutBehavior implements Behavior<Mesh> {
  94821. /**
  94822. * Time in milliseconds to delay before fading in (Default: 0)
  94823. */
  94824. delay: number;
  94825. /**
  94826. * Time in milliseconds for the mesh to fade in (Default: 300)
  94827. */
  94828. fadeInTime: number;
  94829. private _millisecondsPerFrame;
  94830. private _hovered;
  94831. private _hoverValue;
  94832. private _ownerNode;
  94833. /**
  94834. * Instatiates the FadeInOutBehavior
  94835. */
  94836. constructor();
  94837. /**
  94838. * The name of the behavior
  94839. */
  94840. readonly name: string;
  94841. /**
  94842. * Initializes the behavior
  94843. */
  94844. init(): void;
  94845. /**
  94846. * Attaches the fade behavior on the passed in mesh
  94847. * @param ownerNode The mesh that will be faded in/out once attached
  94848. */
  94849. attach(ownerNode: Mesh): void;
  94850. /**
  94851. * Detaches the behavior from the mesh
  94852. */
  94853. detach(): void;
  94854. /**
  94855. * Triggers the mesh to begin fading in or out
  94856. * @param value if the object should fade in or out (true to fade in)
  94857. */
  94858. fadeIn(value: boolean): void;
  94859. private _update;
  94860. private _setAllVisibility;
  94861. }
  94862. }
  94863. declare module BABYLON {
  94864. /**
  94865. * Class containing a set of static utilities functions for managing Pivots
  94866. * @hidden
  94867. */
  94868. export class PivotTools {
  94869. private static _PivotCached;
  94870. private static _OldPivotPoint;
  94871. private static _PivotTranslation;
  94872. private static _PivotTmpVector;
  94873. /** @hidden */
  94874. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  94875. /** @hidden */
  94876. static _RestorePivotPoint(mesh: AbstractMesh): void;
  94877. }
  94878. }
  94879. declare module BABYLON {
  94880. /**
  94881. * Class containing static functions to help procedurally build meshes
  94882. */
  94883. export class PlaneBuilder {
  94884. /**
  94885. * Creates a plane mesh
  94886. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94887. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94888. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94892. * @param name defines the name of the mesh
  94893. * @param options defines the options used to create the mesh
  94894. * @param scene defines the hosting scene
  94895. * @returns the plane mesh
  94896. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94897. */
  94898. static CreatePlane(name: string, options: {
  94899. size?: number;
  94900. width?: number;
  94901. height?: number;
  94902. sideOrientation?: number;
  94903. frontUVs?: Vector4;
  94904. backUVs?: Vector4;
  94905. updatable?: boolean;
  94906. sourcePlane?: Plane;
  94907. }, scene?: Nullable<Scene>): Mesh;
  94908. }
  94909. }
  94910. declare module BABYLON {
  94911. /**
  94912. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  94913. */
  94914. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  94915. private static _AnyMouseID;
  94916. private _attachedNode;
  94917. private _dragPlane;
  94918. private _scene;
  94919. private _pointerObserver;
  94920. private _beforeRenderObserver;
  94921. private static _planeScene;
  94922. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  94923. /**
  94924. * 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)
  94925. */
  94926. maxDragAngle: number;
  94927. /**
  94928. * @hidden
  94929. */
  94930. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  94931. /**
  94932. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94933. */
  94934. currentDraggingPointerID: number;
  94935. /**
  94936. * The last position where the pointer hit the drag plane in world space
  94937. */
  94938. lastDragPosition: Vector3;
  94939. /**
  94940. * If the behavior is currently in a dragging state
  94941. */
  94942. dragging: boolean;
  94943. /**
  94944. * 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)
  94945. */
  94946. dragDeltaRatio: number;
  94947. /**
  94948. * If the drag plane orientation should be updated during the dragging (Default: true)
  94949. */
  94950. updateDragPlane: boolean;
  94951. private _debugMode;
  94952. private _moving;
  94953. /**
  94954. * Fires each time the attached mesh is dragged with the pointer
  94955. * * delta between last drag position and current drag position in world space
  94956. * * dragDistance along the drag axis
  94957. * * dragPlaneNormal normal of the current drag plane used during the drag
  94958. * * dragPlanePoint in world space where the drag intersects the drag plane
  94959. */
  94960. onDragObservable: Observable<{
  94961. delta: Vector3;
  94962. dragPlanePoint: Vector3;
  94963. dragPlaneNormal: Vector3;
  94964. dragDistance: number;
  94965. pointerId: number;
  94966. }>;
  94967. /**
  94968. * Fires each time a drag begins (eg. mouse down on mesh)
  94969. */
  94970. onDragStartObservable: Observable<{
  94971. dragPlanePoint: Vector3;
  94972. pointerId: number;
  94973. }>;
  94974. /**
  94975. * Fires each time a drag ends (eg. mouse release after drag)
  94976. */
  94977. onDragEndObservable: Observable<{
  94978. dragPlanePoint: Vector3;
  94979. pointerId: number;
  94980. }>;
  94981. /**
  94982. * If the attached mesh should be moved when dragged
  94983. */
  94984. moveAttached: boolean;
  94985. /**
  94986. * If the drag behavior will react to drag events (Default: true)
  94987. */
  94988. enabled: boolean;
  94989. /**
  94990. * If camera controls should be detached during the drag
  94991. */
  94992. detachCameraControls: boolean;
  94993. /**
  94994. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  94995. */
  94996. useObjectOrienationForDragging: boolean;
  94997. private _options;
  94998. /**
  94999. * Creates a pointer drag behavior that can be attached to a mesh
  95000. * @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)
  95001. */
  95002. constructor(options?: {
  95003. dragAxis?: Vector3;
  95004. dragPlaneNormal?: Vector3;
  95005. });
  95006. /**
  95007. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95008. */
  95009. validateDrag: (targetPosition: Vector3) => boolean;
  95010. /**
  95011. * The name of the behavior
  95012. */
  95013. readonly name: string;
  95014. /**
  95015. * Initializes the behavior
  95016. */
  95017. init(): void;
  95018. private _tmpVector;
  95019. private _alternatePickedPoint;
  95020. private _worldDragAxis;
  95021. private _targetPosition;
  95022. private _attachedElement;
  95023. /**
  95024. * Attaches the drag behavior the passed in mesh
  95025. * @param ownerNode The mesh that will be dragged around once attached
  95026. */
  95027. attach(ownerNode: AbstractMesh): void;
  95028. /**
  95029. * Force relase the drag action by code.
  95030. */
  95031. releaseDrag(): void;
  95032. private _startDragRay;
  95033. private _lastPointerRay;
  95034. /**
  95035. * Simulates the start of a pointer drag event on the behavior
  95036. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95037. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95038. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95039. */
  95040. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95041. private _startDrag;
  95042. private _dragDelta;
  95043. private _moveDrag;
  95044. private _pickWithRayOnDragPlane;
  95045. private _pointA;
  95046. private _pointB;
  95047. private _pointC;
  95048. private _lineA;
  95049. private _lineB;
  95050. private _localAxis;
  95051. private _lookAt;
  95052. private _updateDragPlanePosition;
  95053. /**
  95054. * Detaches the behavior from the mesh
  95055. */
  95056. detach(): void;
  95057. }
  95058. }
  95059. declare module BABYLON {
  95060. /**
  95061. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95062. */
  95063. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95064. private _dragBehaviorA;
  95065. private _dragBehaviorB;
  95066. private _startDistance;
  95067. private _initialScale;
  95068. private _targetScale;
  95069. private _ownerNode;
  95070. private _sceneRenderObserver;
  95071. /**
  95072. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95073. */
  95074. constructor();
  95075. /**
  95076. * The name of the behavior
  95077. */
  95078. readonly name: string;
  95079. /**
  95080. * Initializes the behavior
  95081. */
  95082. init(): void;
  95083. private _getCurrentDistance;
  95084. /**
  95085. * Attaches the scale behavior the passed in mesh
  95086. * @param ownerNode The mesh that will be scaled around once attached
  95087. */
  95088. attach(ownerNode: Mesh): void;
  95089. /**
  95090. * Detaches the behavior from the mesh
  95091. */
  95092. detach(): void;
  95093. }
  95094. }
  95095. declare module BABYLON {
  95096. /**
  95097. * 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
  95098. */
  95099. export class SixDofDragBehavior implements Behavior<Mesh> {
  95100. private static _virtualScene;
  95101. private _ownerNode;
  95102. private _sceneRenderObserver;
  95103. private _scene;
  95104. private _targetPosition;
  95105. private _virtualOriginMesh;
  95106. private _virtualDragMesh;
  95107. private _pointerObserver;
  95108. private _moving;
  95109. private _startingOrientation;
  95110. /**
  95111. * 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)
  95112. */
  95113. private zDragFactor;
  95114. /**
  95115. * If the object should rotate to face the drag origin
  95116. */
  95117. rotateDraggedObject: boolean;
  95118. /**
  95119. * If the behavior is currently in a dragging state
  95120. */
  95121. dragging: boolean;
  95122. /**
  95123. * 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)
  95124. */
  95125. dragDeltaRatio: number;
  95126. /**
  95127. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95128. */
  95129. currentDraggingPointerID: number;
  95130. /**
  95131. * If camera controls should be detached during the drag
  95132. */
  95133. detachCameraControls: boolean;
  95134. /**
  95135. * Fires each time a drag starts
  95136. */
  95137. onDragStartObservable: Observable<{}>;
  95138. /**
  95139. * Fires each time a drag ends (eg. mouse release after drag)
  95140. */
  95141. onDragEndObservable: Observable<{}>;
  95142. /**
  95143. * 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
  95144. */
  95145. constructor();
  95146. /**
  95147. * The name of the behavior
  95148. */
  95149. readonly name: string;
  95150. /**
  95151. * Initializes the behavior
  95152. */
  95153. init(): void;
  95154. /**
  95155. * Attaches the scale behavior the passed in mesh
  95156. * @param ownerNode The mesh that will be scaled around once attached
  95157. */
  95158. attach(ownerNode: Mesh): void;
  95159. /**
  95160. * Detaches the behavior from the mesh
  95161. */
  95162. detach(): void;
  95163. }
  95164. }
  95165. declare module BABYLON {
  95166. /**
  95167. * Class used to apply inverse kinematics to bones
  95168. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95169. */
  95170. export class BoneIKController {
  95171. private static _tmpVecs;
  95172. private static _tmpQuat;
  95173. private static _tmpMats;
  95174. /**
  95175. * Gets or sets the target mesh
  95176. */
  95177. targetMesh: AbstractMesh;
  95178. /** Gets or sets the mesh used as pole */
  95179. poleTargetMesh: AbstractMesh;
  95180. /**
  95181. * Gets or sets the bone used as pole
  95182. */
  95183. poleTargetBone: Nullable<Bone>;
  95184. /**
  95185. * Gets or sets the target position
  95186. */
  95187. targetPosition: Vector3;
  95188. /**
  95189. * Gets or sets the pole target position
  95190. */
  95191. poleTargetPosition: Vector3;
  95192. /**
  95193. * Gets or sets the pole target local offset
  95194. */
  95195. poleTargetLocalOffset: Vector3;
  95196. /**
  95197. * Gets or sets the pole angle
  95198. */
  95199. poleAngle: number;
  95200. /**
  95201. * Gets or sets the mesh associated with the controller
  95202. */
  95203. mesh: AbstractMesh;
  95204. /**
  95205. * 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)
  95206. */
  95207. slerpAmount: number;
  95208. private _bone1Quat;
  95209. private _bone1Mat;
  95210. private _bone2Ang;
  95211. private _bone1;
  95212. private _bone2;
  95213. private _bone1Length;
  95214. private _bone2Length;
  95215. private _maxAngle;
  95216. private _maxReach;
  95217. private _rightHandedSystem;
  95218. private _bendAxis;
  95219. private _slerping;
  95220. private _adjustRoll;
  95221. /**
  95222. * Gets or sets maximum allowed angle
  95223. */
  95224. maxAngle: number;
  95225. /**
  95226. * Creates a new BoneIKController
  95227. * @param mesh defines the mesh to control
  95228. * @param bone defines the bone to control
  95229. * @param options defines options to set up the controller
  95230. */
  95231. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95232. targetMesh?: AbstractMesh;
  95233. poleTargetMesh?: AbstractMesh;
  95234. poleTargetBone?: Bone;
  95235. poleTargetLocalOffset?: Vector3;
  95236. poleAngle?: number;
  95237. bendAxis?: Vector3;
  95238. maxAngle?: number;
  95239. slerpAmount?: number;
  95240. });
  95241. private _setMaxAngle;
  95242. /**
  95243. * Force the controller to update the bones
  95244. */
  95245. update(): void;
  95246. }
  95247. }
  95248. declare module BABYLON {
  95249. /**
  95250. * Class used to make a bone look toward a point in space
  95251. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95252. */
  95253. export class BoneLookController {
  95254. private static _tmpVecs;
  95255. private static _tmpQuat;
  95256. private static _tmpMats;
  95257. /**
  95258. * The target Vector3 that the bone will look at
  95259. */
  95260. target: Vector3;
  95261. /**
  95262. * The mesh that the bone is attached to
  95263. */
  95264. mesh: AbstractMesh;
  95265. /**
  95266. * The bone that will be looking to the target
  95267. */
  95268. bone: Bone;
  95269. /**
  95270. * The up axis of the coordinate system that is used when the bone is rotated
  95271. */
  95272. upAxis: Vector3;
  95273. /**
  95274. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95275. */
  95276. upAxisSpace: Space;
  95277. /**
  95278. * Used to make an adjustment to the yaw of the bone
  95279. */
  95280. adjustYaw: number;
  95281. /**
  95282. * Used to make an adjustment to the pitch of the bone
  95283. */
  95284. adjustPitch: number;
  95285. /**
  95286. * Used to make an adjustment to the roll of the bone
  95287. */
  95288. adjustRoll: number;
  95289. /**
  95290. * 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)
  95291. */
  95292. slerpAmount: number;
  95293. private _minYaw;
  95294. private _maxYaw;
  95295. private _minPitch;
  95296. private _maxPitch;
  95297. private _minYawSin;
  95298. private _minYawCos;
  95299. private _maxYawSin;
  95300. private _maxYawCos;
  95301. private _midYawConstraint;
  95302. private _minPitchTan;
  95303. private _maxPitchTan;
  95304. private _boneQuat;
  95305. private _slerping;
  95306. private _transformYawPitch;
  95307. private _transformYawPitchInv;
  95308. private _firstFrameSkipped;
  95309. private _yawRange;
  95310. private _fowardAxis;
  95311. /**
  95312. * Gets or sets the minimum yaw angle that the bone can look to
  95313. */
  95314. minYaw: number;
  95315. /**
  95316. * Gets or sets the maximum yaw angle that the bone can look to
  95317. */
  95318. maxYaw: number;
  95319. /**
  95320. * Gets or sets the minimum pitch angle that the bone can look to
  95321. */
  95322. minPitch: number;
  95323. /**
  95324. * Gets or sets the maximum pitch angle that the bone can look to
  95325. */
  95326. maxPitch: number;
  95327. /**
  95328. * Create a BoneLookController
  95329. * @param mesh the mesh that the bone belongs to
  95330. * @param bone the bone that will be looking to the target
  95331. * @param target the target Vector3 to look at
  95332. * @param options optional settings:
  95333. * * maxYaw: the maximum angle the bone will yaw to
  95334. * * minYaw: the minimum angle the bone will yaw to
  95335. * * maxPitch: the maximum angle the bone will pitch to
  95336. * * minPitch: the minimum angle the bone will yaw to
  95337. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  95338. * * upAxis: the up axis of the coordinate system
  95339. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  95340. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  95341. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  95342. * * adjustYaw: used to make an adjustment to the yaw of the bone
  95343. * * adjustPitch: used to make an adjustment to the pitch of the bone
  95344. * * adjustRoll: used to make an adjustment to the roll of the bone
  95345. **/
  95346. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  95347. maxYaw?: number;
  95348. minYaw?: number;
  95349. maxPitch?: number;
  95350. minPitch?: number;
  95351. slerpAmount?: number;
  95352. upAxis?: Vector3;
  95353. upAxisSpace?: Space;
  95354. yawAxis?: Vector3;
  95355. pitchAxis?: Vector3;
  95356. adjustYaw?: number;
  95357. adjustPitch?: number;
  95358. adjustRoll?: number;
  95359. });
  95360. /**
  95361. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  95362. */
  95363. update(): void;
  95364. private _getAngleDiff;
  95365. private _getAngleBetween;
  95366. private _isAngleBetween;
  95367. }
  95368. }
  95369. declare module BABYLON {
  95370. /**
  95371. * Manage the gamepad inputs to control an arc rotate camera.
  95372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95373. */
  95374. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95375. /**
  95376. * Defines the camera the input is attached to.
  95377. */
  95378. camera: ArcRotateCamera;
  95379. /**
  95380. * Defines the gamepad the input is gathering event from.
  95381. */
  95382. gamepad: Nullable<Gamepad>;
  95383. /**
  95384. * Defines the gamepad rotation sensiblity.
  95385. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95386. */
  95387. gamepadRotationSensibility: number;
  95388. /**
  95389. * Defines the gamepad move sensiblity.
  95390. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95391. */
  95392. gamepadMoveSensibility: number;
  95393. private _onGamepadConnectedObserver;
  95394. private _onGamepadDisconnectedObserver;
  95395. /**
  95396. * Attach the input controls to a specific dom element to get the input from.
  95397. * @param element Defines the element the controls should be listened from
  95398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95399. */
  95400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95401. /**
  95402. * Detach the current controls from the specified dom element.
  95403. * @param element Defines the element to stop listening the inputs from
  95404. */
  95405. detachControl(element: Nullable<HTMLElement>): void;
  95406. /**
  95407. * Update the current camera state depending on the inputs that have been used this frame.
  95408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95409. */
  95410. checkInputs(): void;
  95411. /**
  95412. * Gets the class name of the current intput.
  95413. * @returns the class name
  95414. */
  95415. getClassName(): string;
  95416. /**
  95417. * Get the friendly name associated with the input class.
  95418. * @returns the input friendly name
  95419. */
  95420. getSimpleName(): string;
  95421. }
  95422. }
  95423. declare module BABYLON {
  95424. interface ArcRotateCameraInputsManager {
  95425. /**
  95426. * Add orientation input support to the input manager.
  95427. * @returns the current input manager
  95428. */
  95429. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95430. }
  95431. /**
  95432. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95434. */
  95435. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95436. /**
  95437. * Defines the camera the input is attached to.
  95438. */
  95439. camera: ArcRotateCamera;
  95440. /**
  95441. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95442. */
  95443. alphaCorrection: number;
  95444. /**
  95445. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95446. */
  95447. gammaCorrection: number;
  95448. private _alpha;
  95449. private _gamma;
  95450. private _dirty;
  95451. private _deviceOrientationHandler;
  95452. /**
  95453. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95454. */
  95455. constructor();
  95456. /**
  95457. * Attach the input controls to a specific dom element to get the input from.
  95458. * @param element Defines the element the controls should be listened from
  95459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95460. */
  95461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95462. /** @hidden */
  95463. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95464. /**
  95465. * Update the current camera state depending on the inputs that have been used this frame.
  95466. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95467. */
  95468. checkInputs(): void;
  95469. /**
  95470. * Detach the current controls from the specified dom element.
  95471. * @param element Defines the element to stop listening the inputs from
  95472. */
  95473. detachControl(element: Nullable<HTMLElement>): void;
  95474. /**
  95475. * Gets the class name of the current intput.
  95476. * @returns the class name
  95477. */
  95478. getClassName(): string;
  95479. /**
  95480. * Get the friendly name associated with the input class.
  95481. * @returns the input friendly name
  95482. */
  95483. getSimpleName(): string;
  95484. }
  95485. }
  95486. declare module BABYLON {
  95487. /**
  95488. * Listen to mouse events to control the camera.
  95489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95490. */
  95491. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95492. /**
  95493. * Defines the camera the input is attached to.
  95494. */
  95495. camera: FlyCamera;
  95496. /**
  95497. * Defines if touch is enabled. (Default is true.)
  95498. */
  95499. touchEnabled: boolean;
  95500. /**
  95501. * Defines the buttons associated with the input to handle camera rotation.
  95502. */
  95503. buttons: number[];
  95504. /**
  95505. * Assign buttons for Yaw control.
  95506. */
  95507. buttonsYaw: number[];
  95508. /**
  95509. * Assign buttons for Pitch control.
  95510. */
  95511. buttonsPitch: number[];
  95512. /**
  95513. * Assign buttons for Roll control.
  95514. */
  95515. buttonsRoll: number[];
  95516. /**
  95517. * Detect if any button is being pressed while mouse is moved.
  95518. * -1 = Mouse locked.
  95519. * 0 = Left button.
  95520. * 1 = Middle Button.
  95521. * 2 = Right Button.
  95522. */
  95523. activeButton: number;
  95524. /**
  95525. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95526. * Higher values reduce its sensitivity.
  95527. */
  95528. angularSensibility: number;
  95529. private _mousemoveCallback;
  95530. private _observer;
  95531. private _rollObserver;
  95532. private previousPosition;
  95533. private noPreventDefault;
  95534. private element;
  95535. /**
  95536. * Listen to mouse events to control the camera.
  95537. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95539. */
  95540. constructor(touchEnabled?: boolean);
  95541. /**
  95542. * Attach the mouse control to the HTML DOM element.
  95543. * @param element Defines the element that listens to the input events.
  95544. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95545. */
  95546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95547. /**
  95548. * Detach the current controls from the specified dom element.
  95549. * @param element Defines the element to stop listening the inputs from
  95550. */
  95551. detachControl(element: Nullable<HTMLElement>): void;
  95552. /**
  95553. * Gets the class name of the current input.
  95554. * @returns the class name.
  95555. */
  95556. getClassName(): string;
  95557. /**
  95558. * Get the friendly name associated with the input class.
  95559. * @returns the input's friendly name.
  95560. */
  95561. getSimpleName(): string;
  95562. private _pointerInput;
  95563. private _onMouseMove;
  95564. /**
  95565. * Rotate camera by mouse offset.
  95566. */
  95567. private rotateCamera;
  95568. }
  95569. }
  95570. declare module BABYLON {
  95571. /**
  95572. * Default Inputs manager for the FlyCamera.
  95573. * It groups all the default supported inputs for ease of use.
  95574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95575. */
  95576. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95577. /**
  95578. * Instantiates a new FlyCameraInputsManager.
  95579. * @param camera Defines the camera the inputs belong to.
  95580. */
  95581. constructor(camera: FlyCamera);
  95582. /**
  95583. * Add keyboard input support to the input manager.
  95584. * @returns the new FlyCameraKeyboardMoveInput().
  95585. */
  95586. addKeyboard(): FlyCameraInputsManager;
  95587. /**
  95588. * Add mouse input support to the input manager.
  95589. * @param touchEnabled Enable touch screen support.
  95590. * @returns the new FlyCameraMouseInput().
  95591. */
  95592. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95593. }
  95594. }
  95595. declare module BABYLON {
  95596. /**
  95597. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95598. * such as in a 3D Space Shooter or a Flight Simulator.
  95599. */
  95600. export class FlyCamera extends TargetCamera {
  95601. /**
  95602. * Define the collision ellipsoid of the camera.
  95603. * This is helpful for simulating a camera body, like a player's body.
  95604. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95605. */
  95606. ellipsoid: Vector3;
  95607. /**
  95608. * Define an offset for the position of the ellipsoid around the camera.
  95609. * This can be helpful if the camera is attached away from the player's body center,
  95610. * such as at its head.
  95611. */
  95612. ellipsoidOffset: Vector3;
  95613. /**
  95614. * Enable or disable collisions of the camera with the rest of the scene objects.
  95615. */
  95616. checkCollisions: boolean;
  95617. /**
  95618. * Enable or disable gravity on the camera.
  95619. */
  95620. applyGravity: boolean;
  95621. /**
  95622. * Define the current direction the camera is moving to.
  95623. */
  95624. cameraDirection: Vector3;
  95625. /**
  95626. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95627. * This overrides and empties cameraRotation.
  95628. */
  95629. rotationQuaternion: Quaternion;
  95630. /**
  95631. * Track Roll to maintain the wanted Rolling when looking around.
  95632. */
  95633. _trackRoll: number;
  95634. /**
  95635. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95636. */
  95637. rollCorrect: number;
  95638. /**
  95639. * Mimic a banked turn, Rolling the camera when Yawing.
  95640. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95641. */
  95642. bankedTurn: boolean;
  95643. /**
  95644. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95645. */
  95646. bankedTurnLimit: number;
  95647. /**
  95648. * Value of 0 disables the banked Roll.
  95649. * Value of 1 is equal to the Yaw angle in radians.
  95650. */
  95651. bankedTurnMultiplier: number;
  95652. /**
  95653. * The inputs manager loads all the input sources, such as keyboard and mouse.
  95654. */
  95655. inputs: FlyCameraInputsManager;
  95656. /**
  95657. * Gets the input sensibility for mouse input.
  95658. * Higher values reduce sensitivity.
  95659. */
  95660. /**
  95661. * Sets the input sensibility for a mouse input.
  95662. * Higher values reduce sensitivity.
  95663. */
  95664. angularSensibility: number;
  95665. /**
  95666. * Get the keys for camera movement forward.
  95667. */
  95668. /**
  95669. * Set the keys for camera movement forward.
  95670. */
  95671. keysForward: number[];
  95672. /**
  95673. * Get the keys for camera movement backward.
  95674. */
  95675. keysBackward: number[];
  95676. /**
  95677. * Get the keys for camera movement up.
  95678. */
  95679. /**
  95680. * Set the keys for camera movement up.
  95681. */
  95682. keysUp: number[];
  95683. /**
  95684. * Get the keys for camera movement down.
  95685. */
  95686. /**
  95687. * Set the keys for camera movement down.
  95688. */
  95689. keysDown: number[];
  95690. /**
  95691. * Get the keys for camera movement left.
  95692. */
  95693. /**
  95694. * Set the keys for camera movement left.
  95695. */
  95696. keysLeft: number[];
  95697. /**
  95698. * Set the keys for camera movement right.
  95699. */
  95700. /**
  95701. * Set the keys for camera movement right.
  95702. */
  95703. keysRight: number[];
  95704. /**
  95705. * Event raised when the camera collides with a mesh in the scene.
  95706. */
  95707. onCollide: (collidedMesh: AbstractMesh) => void;
  95708. private _collider;
  95709. private _needMoveForGravity;
  95710. private _oldPosition;
  95711. private _diffPosition;
  95712. private _newPosition;
  95713. /** @hidden */
  95714. _localDirection: Vector3;
  95715. /** @hidden */
  95716. _transformedDirection: Vector3;
  95717. /**
  95718. * Instantiates a FlyCamera.
  95719. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95720. * such as in a 3D Space Shooter or a Flight Simulator.
  95721. * @param name Define the name of the camera in the scene.
  95722. * @param position Define the starting position of the camera in the scene.
  95723. * @param scene Define the scene the camera belongs to.
  95724. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  95725. */
  95726. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95727. /**
  95728. * Attach a control to the HTML DOM element.
  95729. * @param element Defines the element that listens to the input events.
  95730. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  95731. */
  95732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95733. /**
  95734. * Detach a control from the HTML DOM element.
  95735. * The camera will stop reacting to that input.
  95736. * @param element Defines the element that listens to the input events.
  95737. */
  95738. detachControl(element: HTMLElement): void;
  95739. private _collisionMask;
  95740. /**
  95741. * Get the mask that the camera ignores in collision events.
  95742. */
  95743. /**
  95744. * Set the mask that the camera ignores in collision events.
  95745. */
  95746. collisionMask: number;
  95747. /** @hidden */
  95748. _collideWithWorld(displacement: Vector3): void;
  95749. /** @hidden */
  95750. private _onCollisionPositionChange;
  95751. /** @hidden */
  95752. _checkInputs(): void;
  95753. /** @hidden */
  95754. _decideIfNeedsToMove(): boolean;
  95755. /** @hidden */
  95756. _updatePosition(): void;
  95757. /**
  95758. * Restore the Roll to its target value at the rate specified.
  95759. * @param rate - Higher means slower restoring.
  95760. * @hidden
  95761. */
  95762. restoreRoll(rate: number): void;
  95763. /**
  95764. * Destroy the camera and release the current resources held by it.
  95765. */
  95766. dispose(): void;
  95767. /**
  95768. * Get the current object class name.
  95769. * @returns the class name.
  95770. */
  95771. getClassName(): string;
  95772. }
  95773. }
  95774. declare module BABYLON {
  95775. /**
  95776. * Listen to keyboard events to control the camera.
  95777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95778. */
  95779. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  95780. /**
  95781. * Defines the camera the input is attached to.
  95782. */
  95783. camera: FlyCamera;
  95784. /**
  95785. * The list of keyboard keys used to control the forward move of the camera.
  95786. */
  95787. keysForward: number[];
  95788. /**
  95789. * The list of keyboard keys used to control the backward move of the camera.
  95790. */
  95791. keysBackward: number[];
  95792. /**
  95793. * The list of keyboard keys used to control the forward move of the camera.
  95794. */
  95795. keysUp: number[];
  95796. /**
  95797. * The list of keyboard keys used to control the backward move of the camera.
  95798. */
  95799. keysDown: number[];
  95800. /**
  95801. * The list of keyboard keys used to control the right strafe move of the camera.
  95802. */
  95803. keysRight: number[];
  95804. /**
  95805. * The list of keyboard keys used to control the left strafe move of the camera.
  95806. */
  95807. keysLeft: number[];
  95808. private _keys;
  95809. private _onCanvasBlurObserver;
  95810. private _onKeyboardObserver;
  95811. private _engine;
  95812. private _scene;
  95813. /**
  95814. * Attach the input controls to a specific dom element to get the input from.
  95815. * @param element Defines the element the controls should be listened from
  95816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95817. */
  95818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95819. /**
  95820. * Detach the current controls from the specified dom element.
  95821. * @param element Defines the element to stop listening the inputs from
  95822. */
  95823. detachControl(element: Nullable<HTMLElement>): void;
  95824. /**
  95825. * Gets the class name of the current intput.
  95826. * @returns the class name
  95827. */
  95828. getClassName(): string;
  95829. /** @hidden */
  95830. _onLostFocus(e: FocusEvent): void;
  95831. /**
  95832. * Get the friendly name associated with the input class.
  95833. * @returns the input friendly name
  95834. */
  95835. getSimpleName(): string;
  95836. /**
  95837. * Update the current camera state depending on the inputs that have been used this frame.
  95838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95839. */
  95840. checkInputs(): void;
  95841. }
  95842. }
  95843. declare module BABYLON {
  95844. /**
  95845. * Manage the mouse wheel inputs to control a follow camera.
  95846. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95847. */
  95848. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  95849. /**
  95850. * Defines the camera the input is attached to.
  95851. */
  95852. camera: FollowCamera;
  95853. /**
  95854. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  95855. */
  95856. axisControlRadius: boolean;
  95857. /**
  95858. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  95859. */
  95860. axisControlHeight: boolean;
  95861. /**
  95862. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  95863. */
  95864. axisControlRotation: boolean;
  95865. /**
  95866. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  95867. * relation to mouseWheel events.
  95868. */
  95869. wheelPrecision: number;
  95870. /**
  95871. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95872. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95873. */
  95874. wheelDeltaPercentage: number;
  95875. private _wheel;
  95876. private _observer;
  95877. /**
  95878. * Attach the input controls to a specific dom element to get the input from.
  95879. * @param element Defines the element the controls should be listened from
  95880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95881. */
  95882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95883. /**
  95884. * Detach the current controls from the specified dom element.
  95885. * @param element Defines the element to stop listening the inputs from
  95886. */
  95887. detachControl(element: Nullable<HTMLElement>): void;
  95888. /**
  95889. * Gets the class name of the current intput.
  95890. * @returns the class name
  95891. */
  95892. getClassName(): string;
  95893. /**
  95894. * Get the friendly name associated with the input class.
  95895. * @returns the input friendly name
  95896. */
  95897. getSimpleName(): string;
  95898. }
  95899. }
  95900. declare module BABYLON {
  95901. /**
  95902. * Manage the pointers inputs to control an follow camera.
  95903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95904. */
  95905. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  95906. /**
  95907. * Defines the camera the input is attached to.
  95908. */
  95909. camera: FollowCamera;
  95910. /**
  95911. * Gets the class name of the current input.
  95912. * @returns the class name
  95913. */
  95914. getClassName(): string;
  95915. /**
  95916. * Defines the pointer angular sensibility along the X axis or how fast is
  95917. * the camera rotating.
  95918. * A negative number will reverse the axis direction.
  95919. */
  95920. angularSensibilityX: number;
  95921. /**
  95922. * Defines the pointer angular sensibility along the Y axis or how fast is
  95923. * the camera rotating.
  95924. * A negative number will reverse the axis direction.
  95925. */
  95926. angularSensibilityY: number;
  95927. /**
  95928. * Defines the pointer pinch precision or how fast is the camera zooming.
  95929. * A negative number will reverse the axis direction.
  95930. */
  95931. pinchPrecision: number;
  95932. /**
  95933. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  95934. * from 0.
  95935. * It defines the percentage of current camera.radius to use as delta when
  95936. * pinch zoom is used.
  95937. */
  95938. pinchDeltaPercentage: number;
  95939. /**
  95940. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  95941. */
  95942. axisXControlRadius: boolean;
  95943. /**
  95944. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  95945. */
  95946. axisXControlHeight: boolean;
  95947. /**
  95948. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  95949. */
  95950. axisXControlRotation: boolean;
  95951. /**
  95952. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  95953. */
  95954. axisYControlRadius: boolean;
  95955. /**
  95956. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  95957. */
  95958. axisYControlHeight: boolean;
  95959. /**
  95960. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  95961. */
  95962. axisYControlRotation: boolean;
  95963. /**
  95964. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  95965. */
  95966. axisPinchControlRadius: boolean;
  95967. /**
  95968. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  95969. */
  95970. axisPinchControlHeight: boolean;
  95971. /**
  95972. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  95973. */
  95974. axisPinchControlRotation: boolean;
  95975. /**
  95976. * Log error messages if basic misconfiguration has occurred.
  95977. */
  95978. warningEnable: boolean;
  95979. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95980. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95981. private _warningCounter;
  95982. private _warning;
  95983. }
  95984. }
  95985. declare module BABYLON {
  95986. /**
  95987. * Default Inputs manager for the FollowCamera.
  95988. * It groups all the default supported inputs for ease of use.
  95989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95990. */
  95991. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  95992. /**
  95993. * Instantiates a new FollowCameraInputsManager.
  95994. * @param camera Defines the camera the inputs belong to
  95995. */
  95996. constructor(camera: FollowCamera);
  95997. /**
  95998. * Add keyboard input support to the input manager.
  95999. * @returns the current input manager
  96000. */
  96001. addKeyboard(): FollowCameraInputsManager;
  96002. /**
  96003. * Add mouse wheel input support to the input manager.
  96004. * @returns the current input manager
  96005. */
  96006. addMouseWheel(): FollowCameraInputsManager;
  96007. /**
  96008. * Add pointers input support to the input manager.
  96009. * @returns the current input manager
  96010. */
  96011. addPointers(): FollowCameraInputsManager;
  96012. /**
  96013. * Add orientation input support to the input manager.
  96014. * @returns the current input manager
  96015. */
  96016. addVRDeviceOrientation(): FollowCameraInputsManager;
  96017. }
  96018. }
  96019. declare module BABYLON {
  96020. /**
  96021. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96022. * an arc rotate version arcFollowCamera are available.
  96023. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96024. */
  96025. export class FollowCamera extends TargetCamera {
  96026. /**
  96027. * Distance the follow camera should follow an object at
  96028. */
  96029. radius: number;
  96030. /**
  96031. * Minimum allowed distance of the camera to the axis of rotation
  96032. * (The camera can not get closer).
  96033. * This can help limiting how the Camera is able to move in the scene.
  96034. */
  96035. lowerRadiusLimit: Nullable<number>;
  96036. /**
  96037. * Maximum allowed distance of the camera to the axis of rotation
  96038. * (The camera can not get further).
  96039. * This can help limiting how the Camera is able to move in the scene.
  96040. */
  96041. upperRadiusLimit: Nullable<number>;
  96042. /**
  96043. * Define a rotation offset between the camera and the object it follows
  96044. */
  96045. rotationOffset: number;
  96046. /**
  96047. * Minimum allowed angle to camera position relative to target object.
  96048. * This can help limiting how the Camera is able to move in the scene.
  96049. */
  96050. lowerRotationOffsetLimit: Nullable<number>;
  96051. /**
  96052. * Maximum allowed angle to camera position relative to target object.
  96053. * This can help limiting how the Camera is able to move in the scene.
  96054. */
  96055. upperRotationOffsetLimit: Nullable<number>;
  96056. /**
  96057. * Define a height offset between the camera and the object it follows.
  96058. * It can help following an object from the top (like a car chaing a plane)
  96059. */
  96060. heightOffset: number;
  96061. /**
  96062. * Minimum allowed height of camera position relative to target object.
  96063. * This can help limiting how the Camera is able to move in the scene.
  96064. */
  96065. lowerHeightOffsetLimit: Nullable<number>;
  96066. /**
  96067. * Maximum allowed height of camera position relative to target object.
  96068. * This can help limiting how the Camera is able to move in the scene.
  96069. */
  96070. upperHeightOffsetLimit: Nullable<number>;
  96071. /**
  96072. * Define how fast the camera can accelerate to follow it s target.
  96073. */
  96074. cameraAcceleration: number;
  96075. /**
  96076. * Define the speed limit of the camera following an object.
  96077. */
  96078. maxCameraSpeed: number;
  96079. /**
  96080. * Define the target of the camera.
  96081. */
  96082. lockedTarget: Nullable<AbstractMesh>;
  96083. /**
  96084. * Defines the input associated with the camera.
  96085. */
  96086. inputs: FollowCameraInputsManager;
  96087. /**
  96088. * Instantiates the follow camera.
  96089. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96090. * @param name Define the name of the camera in the scene
  96091. * @param position Define the position of the camera
  96092. * @param scene Define the scene the camera belong to
  96093. * @param lockedTarget Define the target of the camera
  96094. */
  96095. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96096. private _follow;
  96097. /**
  96098. * Attached controls to the current camera.
  96099. * @param element Defines the element the controls should be listened from
  96100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96101. */
  96102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96103. /**
  96104. * Detach the current controls from the camera.
  96105. * The camera will stop reacting to inputs.
  96106. * @param element Defines the element to stop listening the inputs from
  96107. */
  96108. detachControl(element: HTMLElement): void;
  96109. /** @hidden */
  96110. _checkInputs(): void;
  96111. private _checkLimits;
  96112. /**
  96113. * Gets the camera class name.
  96114. * @returns the class name
  96115. */
  96116. getClassName(): string;
  96117. }
  96118. /**
  96119. * Arc Rotate version of the follow camera.
  96120. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96121. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96122. */
  96123. export class ArcFollowCamera extends TargetCamera {
  96124. /** The longitudinal angle of the camera */
  96125. alpha: number;
  96126. /** The latitudinal angle of the camera */
  96127. beta: number;
  96128. /** The radius of the camera from its target */
  96129. radius: number;
  96130. /** Define the camera target (the messh it should follow) */
  96131. target: Nullable<AbstractMesh>;
  96132. private _cartesianCoordinates;
  96133. /**
  96134. * Instantiates a new ArcFollowCamera
  96135. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96136. * @param name Define the name of the camera
  96137. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96138. * @param beta Define the rotation angle of the camera around the elevation axis
  96139. * @param radius Define the radius of the camera from its target point
  96140. * @param target Define the target of the camera
  96141. * @param scene Define the scene the camera belongs to
  96142. */
  96143. constructor(name: string,
  96144. /** The longitudinal angle of the camera */
  96145. alpha: number,
  96146. /** The latitudinal angle of the camera */
  96147. beta: number,
  96148. /** The radius of the camera from its target */
  96149. radius: number,
  96150. /** Define the camera target (the messh it should follow) */
  96151. target: Nullable<AbstractMesh>, scene: Scene);
  96152. private _follow;
  96153. /** @hidden */
  96154. _checkInputs(): void;
  96155. /**
  96156. * Returns the class name of the object.
  96157. * It is mostly used internally for serialization purposes.
  96158. */
  96159. getClassName(): string;
  96160. }
  96161. }
  96162. declare module BABYLON {
  96163. /**
  96164. * Manage the keyboard inputs to control the movement of a follow camera.
  96165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96166. */
  96167. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96168. /**
  96169. * Defines the camera the input is attached to.
  96170. */
  96171. camera: FollowCamera;
  96172. /**
  96173. * Defines the list of key codes associated with the up action (increase heightOffset)
  96174. */
  96175. keysHeightOffsetIncr: number[];
  96176. /**
  96177. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96178. */
  96179. keysHeightOffsetDecr: number[];
  96180. /**
  96181. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96182. */
  96183. keysHeightOffsetModifierAlt: boolean;
  96184. /**
  96185. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96186. */
  96187. keysHeightOffsetModifierCtrl: boolean;
  96188. /**
  96189. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96190. */
  96191. keysHeightOffsetModifierShift: boolean;
  96192. /**
  96193. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96194. */
  96195. keysRotationOffsetIncr: number[];
  96196. /**
  96197. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96198. */
  96199. keysRotationOffsetDecr: number[];
  96200. /**
  96201. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96202. */
  96203. keysRotationOffsetModifierAlt: boolean;
  96204. /**
  96205. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96206. */
  96207. keysRotationOffsetModifierCtrl: boolean;
  96208. /**
  96209. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96210. */
  96211. keysRotationOffsetModifierShift: boolean;
  96212. /**
  96213. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96214. */
  96215. keysRadiusIncr: number[];
  96216. /**
  96217. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96218. */
  96219. keysRadiusDecr: number[];
  96220. /**
  96221. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96222. */
  96223. keysRadiusModifierAlt: boolean;
  96224. /**
  96225. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96226. */
  96227. keysRadiusModifierCtrl: boolean;
  96228. /**
  96229. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96230. */
  96231. keysRadiusModifierShift: boolean;
  96232. /**
  96233. * Defines the rate of change of heightOffset.
  96234. */
  96235. heightSensibility: number;
  96236. /**
  96237. * Defines the rate of change of rotationOffset.
  96238. */
  96239. rotationSensibility: number;
  96240. /**
  96241. * Defines the rate of change of radius.
  96242. */
  96243. radiusSensibility: number;
  96244. private _keys;
  96245. private _ctrlPressed;
  96246. private _altPressed;
  96247. private _shiftPressed;
  96248. private _onCanvasBlurObserver;
  96249. private _onKeyboardObserver;
  96250. private _engine;
  96251. private _scene;
  96252. /**
  96253. * Attach the input controls to a specific dom element to get the input from.
  96254. * @param element Defines the element the controls should be listened from
  96255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96256. */
  96257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96258. /**
  96259. * Detach the current controls from the specified dom element.
  96260. * @param element Defines the element to stop listening the inputs from
  96261. */
  96262. detachControl(element: Nullable<HTMLElement>): void;
  96263. /**
  96264. * Update the current camera state depending on the inputs that have been used this frame.
  96265. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96266. */
  96267. checkInputs(): void;
  96268. /**
  96269. * Gets the class name of the current input.
  96270. * @returns the class name
  96271. */
  96272. getClassName(): string;
  96273. /**
  96274. * Get the friendly name associated with the input class.
  96275. * @returns the input friendly name
  96276. */
  96277. getSimpleName(): string;
  96278. /**
  96279. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96280. * allow modification of the heightOffset value.
  96281. */
  96282. private _modifierHeightOffset;
  96283. /**
  96284. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96285. * allow modification of the rotationOffset value.
  96286. */
  96287. private _modifierRotationOffset;
  96288. /**
  96289. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96290. * allow modification of the radius value.
  96291. */
  96292. private _modifierRadius;
  96293. }
  96294. }
  96295. declare module BABYLON {
  96296. interface FreeCameraInputsManager {
  96297. /**
  96298. * @hidden
  96299. */
  96300. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  96301. /**
  96302. * Add orientation input support to the input manager.
  96303. * @returns the current input manager
  96304. */
  96305. addDeviceOrientation(): FreeCameraInputsManager;
  96306. }
  96307. /**
  96308. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  96309. * Screen rotation is taken into account.
  96310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96311. */
  96312. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  96313. private _camera;
  96314. private _screenOrientationAngle;
  96315. private _constantTranform;
  96316. private _screenQuaternion;
  96317. private _alpha;
  96318. private _beta;
  96319. private _gamma;
  96320. /**
  96321. * @hidden
  96322. */
  96323. _onDeviceOrientationChangedObservable: Observable<void>;
  96324. /**
  96325. * Instantiates a new input
  96326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96327. */
  96328. constructor();
  96329. /**
  96330. * Define the camera controlled by the input.
  96331. */
  96332. camera: FreeCamera;
  96333. /**
  96334. * Attach the input controls to a specific dom element to get the input from.
  96335. * @param element Defines the element the controls should be listened from
  96336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96337. */
  96338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96339. private _orientationChanged;
  96340. private _deviceOrientation;
  96341. /**
  96342. * Detach the current controls from the specified dom element.
  96343. * @param element Defines the element to stop listening the inputs from
  96344. */
  96345. detachControl(element: Nullable<HTMLElement>): void;
  96346. /**
  96347. * Update the current camera state depending on the inputs that have been used this frame.
  96348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96349. */
  96350. checkInputs(): void;
  96351. /**
  96352. * Gets the class name of the current intput.
  96353. * @returns the class name
  96354. */
  96355. getClassName(): string;
  96356. /**
  96357. * Get the friendly name associated with the input class.
  96358. * @returns the input friendly name
  96359. */
  96360. getSimpleName(): string;
  96361. }
  96362. }
  96363. declare module BABYLON {
  96364. /**
  96365. * Manage the gamepad inputs to control a free camera.
  96366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96367. */
  96368. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  96369. /**
  96370. * Define the camera the input is attached to.
  96371. */
  96372. camera: FreeCamera;
  96373. /**
  96374. * Define the Gamepad controlling the input
  96375. */
  96376. gamepad: Nullable<Gamepad>;
  96377. /**
  96378. * Defines the gamepad rotation sensiblity.
  96379. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96380. */
  96381. gamepadAngularSensibility: number;
  96382. /**
  96383. * Defines the gamepad move sensiblity.
  96384. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96385. */
  96386. gamepadMoveSensibility: number;
  96387. private _onGamepadConnectedObserver;
  96388. private _onGamepadDisconnectedObserver;
  96389. private _cameraTransform;
  96390. private _deltaTransform;
  96391. private _vector3;
  96392. private _vector2;
  96393. /**
  96394. * Attach the input controls to a specific dom element to get the input from.
  96395. * @param element Defines the element the controls should be listened from
  96396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96397. */
  96398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96399. /**
  96400. * Detach the current controls from the specified dom element.
  96401. * @param element Defines the element to stop listening the inputs from
  96402. */
  96403. detachControl(element: Nullable<HTMLElement>): void;
  96404. /**
  96405. * Update the current camera state depending on the inputs that have been used this frame.
  96406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96407. */
  96408. checkInputs(): void;
  96409. /**
  96410. * Gets the class name of the current intput.
  96411. * @returns the class name
  96412. */
  96413. getClassName(): string;
  96414. /**
  96415. * Get the friendly name associated with the input class.
  96416. * @returns the input friendly name
  96417. */
  96418. getSimpleName(): string;
  96419. }
  96420. }
  96421. declare module BABYLON {
  96422. /**
  96423. * Defines the potential axis of a Joystick
  96424. */
  96425. export enum JoystickAxis {
  96426. /** X axis */
  96427. X = 0,
  96428. /** Y axis */
  96429. Y = 1,
  96430. /** Z axis */
  96431. Z = 2
  96432. }
  96433. /**
  96434. * Class used to define virtual joystick (used in touch mode)
  96435. */
  96436. export class VirtualJoystick {
  96437. /**
  96438. * Gets or sets a boolean indicating that left and right values must be inverted
  96439. */
  96440. reverseLeftRight: boolean;
  96441. /**
  96442. * Gets or sets a boolean indicating that up and down values must be inverted
  96443. */
  96444. reverseUpDown: boolean;
  96445. /**
  96446. * Gets the offset value for the position (ie. the change of the position value)
  96447. */
  96448. deltaPosition: Vector3;
  96449. /**
  96450. * Gets a boolean indicating if the virtual joystick was pressed
  96451. */
  96452. pressed: boolean;
  96453. /**
  96454. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96455. */
  96456. static Canvas: Nullable<HTMLCanvasElement>;
  96457. private static _globalJoystickIndex;
  96458. private static vjCanvasContext;
  96459. private static vjCanvasWidth;
  96460. private static vjCanvasHeight;
  96461. private static halfWidth;
  96462. private _action;
  96463. private _axisTargetedByLeftAndRight;
  96464. private _axisTargetedByUpAndDown;
  96465. private _joystickSensibility;
  96466. private _inversedSensibility;
  96467. private _joystickPointerID;
  96468. private _joystickColor;
  96469. private _joystickPointerPos;
  96470. private _joystickPreviousPointerPos;
  96471. private _joystickPointerStartPos;
  96472. private _deltaJoystickVector;
  96473. private _leftJoystick;
  96474. private _touches;
  96475. private _onPointerDownHandlerRef;
  96476. private _onPointerMoveHandlerRef;
  96477. private _onPointerUpHandlerRef;
  96478. private _onResize;
  96479. /**
  96480. * Creates a new virtual joystick
  96481. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96482. */
  96483. constructor(leftJoystick?: boolean);
  96484. /**
  96485. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96486. * @param newJoystickSensibility defines the new sensibility
  96487. */
  96488. setJoystickSensibility(newJoystickSensibility: number): void;
  96489. private _onPointerDown;
  96490. private _onPointerMove;
  96491. private _onPointerUp;
  96492. /**
  96493. * Change the color of the virtual joystick
  96494. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96495. */
  96496. setJoystickColor(newColor: string): void;
  96497. /**
  96498. * Defines a callback to call when the joystick is touched
  96499. * @param action defines the callback
  96500. */
  96501. setActionOnTouch(action: () => any): void;
  96502. /**
  96503. * Defines which axis you'd like to control for left & right
  96504. * @param axis defines the axis to use
  96505. */
  96506. setAxisForLeftRight(axis: JoystickAxis): void;
  96507. /**
  96508. * Defines which axis you'd like to control for up & down
  96509. * @param axis defines the axis to use
  96510. */
  96511. setAxisForUpDown(axis: JoystickAxis): void;
  96512. private _drawVirtualJoystick;
  96513. /**
  96514. * Release internal HTML canvas
  96515. */
  96516. releaseCanvas(): void;
  96517. }
  96518. }
  96519. declare module BABYLON {
  96520. interface FreeCameraInputsManager {
  96521. /**
  96522. * Add virtual joystick input support to the input manager.
  96523. * @returns the current input manager
  96524. */
  96525. addVirtualJoystick(): FreeCameraInputsManager;
  96526. }
  96527. /**
  96528. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96530. */
  96531. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96532. /**
  96533. * Defines the camera the input is attached to.
  96534. */
  96535. camera: FreeCamera;
  96536. private _leftjoystick;
  96537. private _rightjoystick;
  96538. /**
  96539. * Gets the left stick of the virtual joystick.
  96540. * @returns The virtual Joystick
  96541. */
  96542. getLeftJoystick(): VirtualJoystick;
  96543. /**
  96544. * Gets the right stick of the virtual joystick.
  96545. * @returns The virtual Joystick
  96546. */
  96547. getRightJoystick(): VirtualJoystick;
  96548. /**
  96549. * Update the current camera state depending on the inputs that have been used this frame.
  96550. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96551. */
  96552. checkInputs(): void;
  96553. /**
  96554. * Attach the input controls to a specific dom element to get the input from.
  96555. * @param element Defines the element the controls should be listened from
  96556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96557. */
  96558. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96559. /**
  96560. * Detach the current controls from the specified dom element.
  96561. * @param element Defines the element to stop listening the inputs from
  96562. */
  96563. detachControl(element: Nullable<HTMLElement>): void;
  96564. /**
  96565. * Gets the class name of the current intput.
  96566. * @returns the class name
  96567. */
  96568. getClassName(): string;
  96569. /**
  96570. * Get the friendly name associated with the input class.
  96571. * @returns the input friendly name
  96572. */
  96573. getSimpleName(): string;
  96574. }
  96575. }
  96576. declare module BABYLON {
  96577. /**
  96578. * This represents a FPS type of camera controlled by touch.
  96579. * This is like a universal camera minus the Gamepad controls.
  96580. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96581. */
  96582. export class TouchCamera extends FreeCamera {
  96583. /**
  96584. * Defines the touch sensibility for rotation.
  96585. * The higher the faster.
  96586. */
  96587. touchAngularSensibility: number;
  96588. /**
  96589. * Defines the touch sensibility for move.
  96590. * The higher the faster.
  96591. */
  96592. touchMoveSensibility: number;
  96593. /**
  96594. * Instantiates a new touch camera.
  96595. * This represents a FPS type of camera controlled by touch.
  96596. * This is like a universal camera minus the Gamepad controls.
  96597. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96598. * @param name Define the name of the camera in the scene
  96599. * @param position Define the start position of the camera in the scene
  96600. * @param scene Define the scene the camera belongs to
  96601. */
  96602. constructor(name: string, position: Vector3, scene: Scene);
  96603. /**
  96604. * Gets the current object class name.
  96605. * @return the class name
  96606. */
  96607. getClassName(): string;
  96608. /** @hidden */
  96609. _setupInputs(): void;
  96610. }
  96611. }
  96612. declare module BABYLON {
  96613. /**
  96614. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96615. * being tilted forward or back and left or right.
  96616. */
  96617. export class DeviceOrientationCamera extends FreeCamera {
  96618. private _initialQuaternion;
  96619. private _quaternionCache;
  96620. private _tmpDragQuaternion;
  96621. /**
  96622. * Creates a new device orientation camera
  96623. * @param name The name of the camera
  96624. * @param position The start position camera
  96625. * @param scene The scene the camera belongs to
  96626. */
  96627. constructor(name: string, position: Vector3, scene: Scene);
  96628. /**
  96629. * Disabled pointer input on first orientation sensor update (Default: true)
  96630. */
  96631. disablePointerInputWhenUsingDeviceOrientation: boolean;
  96632. private _dragFactor;
  96633. /**
  96634. * Enabled turning on the y axis when the orientation sensor is active
  96635. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96636. */
  96637. enableHorizontalDragging(dragFactor?: number): void;
  96638. /**
  96639. * Gets the current instance class name ("DeviceOrientationCamera").
  96640. * This helps avoiding instanceof at run time.
  96641. * @returns the class name
  96642. */
  96643. getClassName(): string;
  96644. /**
  96645. * @hidden
  96646. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96647. */
  96648. _checkInputs(): void;
  96649. /**
  96650. * Reset the camera to its default orientation on the specified axis only.
  96651. * @param axis The axis to reset
  96652. */
  96653. resetToCurrentRotation(axis?: Axis): void;
  96654. }
  96655. }
  96656. declare module BABYLON {
  96657. /**
  96658. * 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,
  96659. * which still works and will still be found in many Playgrounds.
  96660. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96661. */
  96662. export class UniversalCamera extends TouchCamera {
  96663. /**
  96664. * Defines the gamepad rotation sensiblity.
  96665. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96666. */
  96667. gamepadAngularSensibility: number;
  96668. /**
  96669. * Defines the gamepad move sensiblity.
  96670. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96671. */
  96672. gamepadMoveSensibility: number;
  96673. /**
  96674. * 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,
  96675. * which still works and will still be found in many Playgrounds.
  96676. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96677. * @param name Define the name of the camera in the scene
  96678. * @param position Define the start position of the camera in the scene
  96679. * @param scene Define the scene the camera belongs to
  96680. */
  96681. constructor(name: string, position: Vector3, scene: Scene);
  96682. /**
  96683. * Gets the current object class name.
  96684. * @return the class name
  96685. */
  96686. getClassName(): string;
  96687. }
  96688. }
  96689. declare module BABYLON {
  96690. /**
  96691. * This represents a FPS type of camera. This is only here for back compat purpose.
  96692. * Please use the UniversalCamera instead as both are identical.
  96693. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96694. */
  96695. export class GamepadCamera extends UniversalCamera {
  96696. /**
  96697. * Instantiates a new Gamepad Camera
  96698. * This represents a FPS type of camera. This is only here for back compat purpose.
  96699. * Please use the UniversalCamera instead as both are identical.
  96700. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96701. * @param name Define the name of the camera in the scene
  96702. * @param position Define the start position of the camera in the scene
  96703. * @param scene Define the scene the camera belongs to
  96704. */
  96705. constructor(name: string, position: Vector3, scene: Scene);
  96706. /**
  96707. * Gets the current object class name.
  96708. * @return the class name
  96709. */
  96710. getClassName(): string;
  96711. }
  96712. }
  96713. declare module BABYLON {
  96714. /** @hidden */
  96715. export var passPixelShader: {
  96716. name: string;
  96717. shader: string;
  96718. };
  96719. }
  96720. declare module BABYLON {
  96721. /** @hidden */
  96722. export var passCubePixelShader: {
  96723. name: string;
  96724. shader: string;
  96725. };
  96726. }
  96727. declare module BABYLON {
  96728. /**
  96729. * PassPostProcess which produces an output the same as it's input
  96730. */
  96731. export class PassPostProcess extends PostProcess {
  96732. /**
  96733. * Creates the PassPostProcess
  96734. * @param name The name of the effect.
  96735. * @param options The required width/height ratio to downsize to before computing the render pass.
  96736. * @param camera The camera to apply the render pass to.
  96737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96738. * @param engine The engine which the post process will be applied. (default: current engine)
  96739. * @param reusable If the post process can be reused on the same frame. (default: false)
  96740. * @param textureType The type of texture to be used when performing the post processing.
  96741. * @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)
  96742. */
  96743. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96744. }
  96745. /**
  96746. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  96747. */
  96748. export class PassCubePostProcess extends PostProcess {
  96749. private _face;
  96750. /**
  96751. * Gets or sets the cube face to display.
  96752. * * 0 is +X
  96753. * * 1 is -X
  96754. * * 2 is +Y
  96755. * * 3 is -Y
  96756. * * 4 is +Z
  96757. * * 5 is -Z
  96758. */
  96759. face: number;
  96760. /**
  96761. * Creates the PassCubePostProcess
  96762. * @param name The name of the effect.
  96763. * @param options The required width/height ratio to downsize to before computing the render pass.
  96764. * @param camera The camera to apply the render pass to.
  96765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96766. * @param engine The engine which the post process will be applied. (default: current engine)
  96767. * @param reusable If the post process can be reused on the same frame. (default: false)
  96768. * @param textureType The type of texture to be used when performing the post processing.
  96769. * @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)
  96770. */
  96771. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96772. }
  96773. }
  96774. declare module BABYLON {
  96775. /** @hidden */
  96776. export var anaglyphPixelShader: {
  96777. name: string;
  96778. shader: string;
  96779. };
  96780. }
  96781. declare module BABYLON {
  96782. /**
  96783. * Postprocess used to generate anaglyphic rendering
  96784. */
  96785. export class AnaglyphPostProcess extends PostProcess {
  96786. private _passedProcess;
  96787. /**
  96788. * Creates a new AnaglyphPostProcess
  96789. * @param name defines postprocess name
  96790. * @param options defines creation options or target ratio scale
  96791. * @param rigCameras defines cameras using this postprocess
  96792. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  96793. * @param engine defines hosting engine
  96794. * @param reusable defines if the postprocess will be reused multiple times per frame
  96795. */
  96796. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  96797. }
  96798. }
  96799. declare module BABYLON {
  96800. /**
  96801. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  96802. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96803. */
  96804. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  96805. /**
  96806. * Creates a new AnaglyphArcRotateCamera
  96807. * @param name defines camera name
  96808. * @param alpha defines alpha angle (in radians)
  96809. * @param beta defines beta angle (in radians)
  96810. * @param radius defines radius
  96811. * @param target defines camera target
  96812. * @param interaxialDistance defines distance between each color axis
  96813. * @param scene defines the hosting scene
  96814. */
  96815. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  96816. /**
  96817. * Gets camera class name
  96818. * @returns AnaglyphArcRotateCamera
  96819. */
  96820. getClassName(): string;
  96821. }
  96822. }
  96823. declare module BABYLON {
  96824. /**
  96825. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  96826. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96827. */
  96828. export class AnaglyphFreeCamera extends FreeCamera {
  96829. /**
  96830. * Creates a new AnaglyphFreeCamera
  96831. * @param name defines camera name
  96832. * @param position defines initial position
  96833. * @param interaxialDistance defines distance between each color axis
  96834. * @param scene defines the hosting scene
  96835. */
  96836. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96837. /**
  96838. * Gets camera class name
  96839. * @returns AnaglyphFreeCamera
  96840. */
  96841. getClassName(): string;
  96842. }
  96843. }
  96844. declare module BABYLON {
  96845. /**
  96846. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  96847. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96848. */
  96849. export class AnaglyphGamepadCamera extends GamepadCamera {
  96850. /**
  96851. * Creates a new AnaglyphGamepadCamera
  96852. * @param name defines camera name
  96853. * @param position defines initial position
  96854. * @param interaxialDistance defines distance between each color axis
  96855. * @param scene defines the hosting scene
  96856. */
  96857. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96858. /**
  96859. * Gets camera class name
  96860. * @returns AnaglyphGamepadCamera
  96861. */
  96862. getClassName(): string;
  96863. }
  96864. }
  96865. declare module BABYLON {
  96866. /**
  96867. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  96868. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96869. */
  96870. export class AnaglyphUniversalCamera extends UniversalCamera {
  96871. /**
  96872. * Creates a new AnaglyphUniversalCamera
  96873. * @param name defines camera name
  96874. * @param position defines initial position
  96875. * @param interaxialDistance defines distance between each color axis
  96876. * @param scene defines the hosting scene
  96877. */
  96878. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96879. /**
  96880. * Gets camera class name
  96881. * @returns AnaglyphUniversalCamera
  96882. */
  96883. getClassName(): string;
  96884. }
  96885. }
  96886. declare module BABYLON {
  96887. /** @hidden */
  96888. export var stereoscopicInterlacePixelShader: {
  96889. name: string;
  96890. shader: string;
  96891. };
  96892. }
  96893. declare module BABYLON {
  96894. /**
  96895. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  96896. */
  96897. export class StereoscopicInterlacePostProcess extends PostProcess {
  96898. private _stepSize;
  96899. private _passedProcess;
  96900. /**
  96901. * Initializes a StereoscopicInterlacePostProcess
  96902. * @param name The name of the effect.
  96903. * @param rigCameras The rig cameras to be appled to the post process
  96904. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  96905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96906. * @param engine The engine which the post process will be applied. (default: current engine)
  96907. * @param reusable If the post process can be reused on the same frame. (default: false)
  96908. */
  96909. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  96910. }
  96911. }
  96912. declare module BABYLON {
  96913. /**
  96914. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  96915. * @see http://doc.babylonjs.com/features/cameras
  96916. */
  96917. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  96918. /**
  96919. * Creates a new StereoscopicArcRotateCamera
  96920. * @param name defines camera name
  96921. * @param alpha defines alpha angle (in radians)
  96922. * @param beta defines beta angle (in radians)
  96923. * @param radius defines radius
  96924. * @param target defines camera target
  96925. * @param interaxialDistance defines distance between each color axis
  96926. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96927. * @param scene defines the hosting scene
  96928. */
  96929. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96930. /**
  96931. * Gets camera class name
  96932. * @returns StereoscopicArcRotateCamera
  96933. */
  96934. getClassName(): string;
  96935. }
  96936. }
  96937. declare module BABYLON {
  96938. /**
  96939. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  96940. * @see http://doc.babylonjs.com/features/cameras
  96941. */
  96942. export class StereoscopicFreeCamera extends FreeCamera {
  96943. /**
  96944. * Creates a new StereoscopicFreeCamera
  96945. * @param name defines camera name
  96946. * @param position defines initial position
  96947. * @param interaxialDistance defines distance between each color axis
  96948. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96949. * @param scene defines the hosting scene
  96950. */
  96951. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96952. /**
  96953. * Gets camera class name
  96954. * @returns StereoscopicFreeCamera
  96955. */
  96956. getClassName(): string;
  96957. }
  96958. }
  96959. declare module BABYLON {
  96960. /**
  96961. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  96962. * @see http://doc.babylonjs.com/features/cameras
  96963. */
  96964. export class StereoscopicGamepadCamera extends GamepadCamera {
  96965. /**
  96966. * Creates a new StereoscopicGamepadCamera
  96967. * @param name defines camera name
  96968. * @param position defines initial position
  96969. * @param interaxialDistance defines distance between each color axis
  96970. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96971. * @param scene defines the hosting scene
  96972. */
  96973. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96974. /**
  96975. * Gets camera class name
  96976. * @returns StereoscopicGamepadCamera
  96977. */
  96978. getClassName(): string;
  96979. }
  96980. }
  96981. declare module BABYLON {
  96982. /**
  96983. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  96984. * @see http://doc.babylonjs.com/features/cameras
  96985. */
  96986. export class StereoscopicUniversalCamera extends UniversalCamera {
  96987. /**
  96988. * Creates a new StereoscopicUniversalCamera
  96989. * @param name defines camera name
  96990. * @param position defines initial position
  96991. * @param interaxialDistance defines distance between each color axis
  96992. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96993. * @param scene defines the hosting scene
  96994. */
  96995. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96996. /**
  96997. * Gets camera class name
  96998. * @returns StereoscopicUniversalCamera
  96999. */
  97000. getClassName(): string;
  97001. }
  97002. }
  97003. declare module BABYLON {
  97004. /**
  97005. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97006. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97007. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97008. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97009. */
  97010. export class VirtualJoysticksCamera extends FreeCamera {
  97011. /**
  97012. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97013. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97014. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97015. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97016. * @param name Define the name of the camera in the scene
  97017. * @param position Define the start position of the camera in the scene
  97018. * @param scene Define the scene the camera belongs to
  97019. */
  97020. constructor(name: string, position: Vector3, scene: Scene);
  97021. /**
  97022. * Gets the current object class name.
  97023. * @return the class name
  97024. */
  97025. getClassName(): string;
  97026. }
  97027. }
  97028. declare module BABYLON {
  97029. /**
  97030. * This represents all the required metrics to create a VR camera.
  97031. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97032. */
  97033. export class VRCameraMetrics {
  97034. /**
  97035. * Define the horizontal resolution off the screen.
  97036. */
  97037. hResolution: number;
  97038. /**
  97039. * Define the vertical resolution off the screen.
  97040. */
  97041. vResolution: number;
  97042. /**
  97043. * Define the horizontal screen size.
  97044. */
  97045. hScreenSize: number;
  97046. /**
  97047. * Define the vertical screen size.
  97048. */
  97049. vScreenSize: number;
  97050. /**
  97051. * Define the vertical screen center position.
  97052. */
  97053. vScreenCenter: number;
  97054. /**
  97055. * Define the distance of the eyes to the screen.
  97056. */
  97057. eyeToScreenDistance: number;
  97058. /**
  97059. * Define the distance between both lenses
  97060. */
  97061. lensSeparationDistance: number;
  97062. /**
  97063. * Define the distance between both viewer's eyes.
  97064. */
  97065. interpupillaryDistance: number;
  97066. /**
  97067. * Define the distortion factor of the VR postprocess.
  97068. * Please, touch with care.
  97069. */
  97070. distortionK: number[];
  97071. /**
  97072. * Define the chromatic aberration correction factors for the VR post process.
  97073. */
  97074. chromaAbCorrection: number[];
  97075. /**
  97076. * Define the scale factor of the post process.
  97077. * The smaller the better but the slower.
  97078. */
  97079. postProcessScaleFactor: number;
  97080. /**
  97081. * Define an offset for the lens center.
  97082. */
  97083. lensCenterOffset: number;
  97084. /**
  97085. * Define if the current vr camera should compensate the distortion of the lense or not.
  97086. */
  97087. compensateDistortion: boolean;
  97088. /**
  97089. * Defines if multiview should be enabled when rendering (Default: false)
  97090. */
  97091. multiviewEnabled: boolean;
  97092. /**
  97093. * Gets the rendering aspect ratio based on the provided resolutions.
  97094. */
  97095. readonly aspectRatio: number;
  97096. /**
  97097. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97098. */
  97099. readonly aspectRatioFov: number;
  97100. /**
  97101. * @hidden
  97102. */
  97103. readonly leftHMatrix: Matrix;
  97104. /**
  97105. * @hidden
  97106. */
  97107. readonly rightHMatrix: Matrix;
  97108. /**
  97109. * @hidden
  97110. */
  97111. readonly leftPreViewMatrix: Matrix;
  97112. /**
  97113. * @hidden
  97114. */
  97115. readonly rightPreViewMatrix: Matrix;
  97116. /**
  97117. * Get the default VRMetrics based on the most generic setup.
  97118. * @returns the default vr metrics
  97119. */
  97120. static GetDefault(): VRCameraMetrics;
  97121. }
  97122. }
  97123. declare module BABYLON {
  97124. /** @hidden */
  97125. export var vrDistortionCorrectionPixelShader: {
  97126. name: string;
  97127. shader: string;
  97128. };
  97129. }
  97130. declare module BABYLON {
  97131. /**
  97132. * VRDistortionCorrectionPostProcess used for mobile VR
  97133. */
  97134. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97135. private _isRightEye;
  97136. private _distortionFactors;
  97137. private _postProcessScaleFactor;
  97138. private _lensCenterOffset;
  97139. private _scaleIn;
  97140. private _scaleFactor;
  97141. private _lensCenter;
  97142. /**
  97143. * Initializes the VRDistortionCorrectionPostProcess
  97144. * @param name The name of the effect.
  97145. * @param camera The camera to apply the render pass to.
  97146. * @param isRightEye If this is for the right eye distortion
  97147. * @param vrMetrics All the required metrics for the VR camera
  97148. */
  97149. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97150. }
  97151. }
  97152. declare module BABYLON {
  97153. /**
  97154. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97155. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97156. */
  97157. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97158. /**
  97159. * Creates a new VRDeviceOrientationArcRotateCamera
  97160. * @param name defines camera name
  97161. * @param alpha defines the camera rotation along the logitudinal axis
  97162. * @param beta defines the camera rotation along the latitudinal axis
  97163. * @param radius defines the camera distance from its target
  97164. * @param target defines the camera target
  97165. * @param scene defines the scene the camera belongs to
  97166. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97167. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97168. */
  97169. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97170. /**
  97171. * Gets camera class name
  97172. * @returns VRDeviceOrientationArcRotateCamera
  97173. */
  97174. getClassName(): string;
  97175. }
  97176. }
  97177. declare module BABYLON {
  97178. /**
  97179. * Camera used to simulate VR rendering (based on FreeCamera)
  97180. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97181. */
  97182. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97183. /**
  97184. * Creates a new VRDeviceOrientationFreeCamera
  97185. * @param name defines camera name
  97186. * @param position defines the start position of the camera
  97187. * @param scene defines the scene the camera belongs to
  97188. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97189. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97190. */
  97191. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97192. /**
  97193. * Gets camera class name
  97194. * @returns VRDeviceOrientationFreeCamera
  97195. */
  97196. getClassName(): string;
  97197. }
  97198. }
  97199. declare module BABYLON {
  97200. /**
  97201. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97202. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97203. */
  97204. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97205. /**
  97206. * Creates a new VRDeviceOrientationGamepadCamera
  97207. * @param name defines camera name
  97208. * @param position defines the start position of the camera
  97209. * @param scene defines the scene the camera belongs to
  97210. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97211. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97212. */
  97213. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97214. /**
  97215. * Gets camera class name
  97216. * @returns VRDeviceOrientationGamepadCamera
  97217. */
  97218. getClassName(): string;
  97219. }
  97220. }
  97221. declare module BABYLON {
  97222. /**
  97223. * Defines supported buttons for XBox360 compatible gamepads
  97224. */
  97225. export enum Xbox360Button {
  97226. /** A */
  97227. A = 0,
  97228. /** B */
  97229. B = 1,
  97230. /** X */
  97231. X = 2,
  97232. /** Y */
  97233. Y = 3,
  97234. /** Start */
  97235. Start = 4,
  97236. /** Back */
  97237. Back = 5,
  97238. /** Left button */
  97239. LB = 6,
  97240. /** Right button */
  97241. RB = 7,
  97242. /** Left stick */
  97243. LeftStick = 8,
  97244. /** Right stick */
  97245. RightStick = 9
  97246. }
  97247. /** Defines values for XBox360 DPad */
  97248. export enum Xbox360Dpad {
  97249. /** Up */
  97250. Up = 0,
  97251. /** Down */
  97252. Down = 1,
  97253. /** Left */
  97254. Left = 2,
  97255. /** Right */
  97256. Right = 3
  97257. }
  97258. /**
  97259. * Defines a XBox360 gamepad
  97260. */
  97261. export class Xbox360Pad extends Gamepad {
  97262. private _leftTrigger;
  97263. private _rightTrigger;
  97264. private _onlefttriggerchanged;
  97265. private _onrighttriggerchanged;
  97266. private _onbuttondown;
  97267. private _onbuttonup;
  97268. private _ondpaddown;
  97269. private _ondpadup;
  97270. /** Observable raised when a button is pressed */
  97271. onButtonDownObservable: Observable<Xbox360Button>;
  97272. /** Observable raised when a button is released */
  97273. onButtonUpObservable: Observable<Xbox360Button>;
  97274. /** Observable raised when a pad is pressed */
  97275. onPadDownObservable: Observable<Xbox360Dpad>;
  97276. /** Observable raised when a pad is released */
  97277. onPadUpObservable: Observable<Xbox360Dpad>;
  97278. private _buttonA;
  97279. private _buttonB;
  97280. private _buttonX;
  97281. private _buttonY;
  97282. private _buttonBack;
  97283. private _buttonStart;
  97284. private _buttonLB;
  97285. private _buttonRB;
  97286. private _buttonLeftStick;
  97287. private _buttonRightStick;
  97288. private _dPadUp;
  97289. private _dPadDown;
  97290. private _dPadLeft;
  97291. private _dPadRight;
  97292. private _isXboxOnePad;
  97293. /**
  97294. * Creates a new XBox360 gamepad object
  97295. * @param id defines the id of this gamepad
  97296. * @param index defines its index
  97297. * @param gamepad defines the internal HTML gamepad object
  97298. * @param xboxOne defines if it is a XBox One gamepad
  97299. */
  97300. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97301. /**
  97302. * Defines the callback to call when left trigger is pressed
  97303. * @param callback defines the callback to use
  97304. */
  97305. onlefttriggerchanged(callback: (value: number) => void): void;
  97306. /**
  97307. * Defines the callback to call when right trigger is pressed
  97308. * @param callback defines the callback to use
  97309. */
  97310. onrighttriggerchanged(callback: (value: number) => void): void;
  97311. /**
  97312. * Gets the left trigger value
  97313. */
  97314. /**
  97315. * Sets the left trigger value
  97316. */
  97317. leftTrigger: number;
  97318. /**
  97319. * Gets the right trigger value
  97320. */
  97321. /**
  97322. * Sets the right trigger value
  97323. */
  97324. rightTrigger: number;
  97325. /**
  97326. * Defines the callback to call when a button is pressed
  97327. * @param callback defines the callback to use
  97328. */
  97329. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97330. /**
  97331. * Defines the callback to call when a button is released
  97332. * @param callback defines the callback to use
  97333. */
  97334. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97335. /**
  97336. * Defines the callback to call when a pad is pressed
  97337. * @param callback defines the callback to use
  97338. */
  97339. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97340. /**
  97341. * Defines the callback to call when a pad is released
  97342. * @param callback defines the callback to use
  97343. */
  97344. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97345. private _setButtonValue;
  97346. private _setDPadValue;
  97347. /**
  97348. * Gets the value of the `A` button
  97349. */
  97350. /**
  97351. * Sets the value of the `A` button
  97352. */
  97353. buttonA: number;
  97354. /**
  97355. * Gets the value of the `B` button
  97356. */
  97357. /**
  97358. * Sets the value of the `B` button
  97359. */
  97360. buttonB: number;
  97361. /**
  97362. * Gets the value of the `X` button
  97363. */
  97364. /**
  97365. * Sets the value of the `X` button
  97366. */
  97367. buttonX: number;
  97368. /**
  97369. * Gets the value of the `Y` button
  97370. */
  97371. /**
  97372. * Sets the value of the `Y` button
  97373. */
  97374. buttonY: number;
  97375. /**
  97376. * Gets the value of the `Start` button
  97377. */
  97378. /**
  97379. * Sets the value of the `Start` button
  97380. */
  97381. buttonStart: number;
  97382. /**
  97383. * Gets the value of the `Back` button
  97384. */
  97385. /**
  97386. * Sets the value of the `Back` button
  97387. */
  97388. buttonBack: number;
  97389. /**
  97390. * Gets the value of the `Left` button
  97391. */
  97392. /**
  97393. * Sets the value of the `Left` button
  97394. */
  97395. buttonLB: number;
  97396. /**
  97397. * Gets the value of the `Right` button
  97398. */
  97399. /**
  97400. * Sets the value of the `Right` button
  97401. */
  97402. buttonRB: number;
  97403. /**
  97404. * Gets the value of the Left joystick
  97405. */
  97406. /**
  97407. * Sets the value of the Left joystick
  97408. */
  97409. buttonLeftStick: number;
  97410. /**
  97411. * Gets the value of the Right joystick
  97412. */
  97413. /**
  97414. * Sets the value of the Right joystick
  97415. */
  97416. buttonRightStick: number;
  97417. /**
  97418. * Gets the value of D-pad up
  97419. */
  97420. /**
  97421. * Sets the value of D-pad up
  97422. */
  97423. dPadUp: number;
  97424. /**
  97425. * Gets the value of D-pad down
  97426. */
  97427. /**
  97428. * Sets the value of D-pad down
  97429. */
  97430. dPadDown: number;
  97431. /**
  97432. * Gets the value of D-pad left
  97433. */
  97434. /**
  97435. * Sets the value of D-pad left
  97436. */
  97437. dPadLeft: number;
  97438. /**
  97439. * Gets the value of D-pad right
  97440. */
  97441. /**
  97442. * Sets the value of D-pad right
  97443. */
  97444. dPadRight: number;
  97445. /**
  97446. * Force the gamepad to synchronize with device values
  97447. */
  97448. update(): void;
  97449. /**
  97450. * Disposes the gamepad
  97451. */
  97452. dispose(): void;
  97453. }
  97454. }
  97455. declare module BABYLON {
  97456. /**
  97457. * Base class of materials working in push mode in babylon JS
  97458. * @hidden
  97459. */
  97460. export class PushMaterial extends Material {
  97461. protected _activeEffect: Effect;
  97462. protected _normalMatrix: Matrix;
  97463. /**
  97464. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97465. * This means that the material can keep using a previous shader while a new one is being compiled.
  97466. * This is mostly used when shader parallel compilation is supported (true by default)
  97467. */
  97468. allowShaderHotSwapping: boolean;
  97469. constructor(name: string, scene: Scene);
  97470. getEffect(): Effect;
  97471. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97472. /**
  97473. * Binds the given world matrix to the active effect
  97474. *
  97475. * @param world the matrix to bind
  97476. */
  97477. bindOnlyWorldMatrix(world: Matrix): void;
  97478. /**
  97479. * Binds the given normal matrix to the active effect
  97480. *
  97481. * @param normalMatrix the matrix to bind
  97482. */
  97483. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97484. bind(world: Matrix, mesh?: Mesh): void;
  97485. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97486. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97487. }
  97488. }
  97489. declare module BABYLON {
  97490. /**
  97491. * This groups all the flags used to control the materials channel.
  97492. */
  97493. export class MaterialFlags {
  97494. private static _DiffuseTextureEnabled;
  97495. /**
  97496. * Are diffuse textures enabled in the application.
  97497. */
  97498. static DiffuseTextureEnabled: boolean;
  97499. private static _AmbientTextureEnabled;
  97500. /**
  97501. * Are ambient textures enabled in the application.
  97502. */
  97503. static AmbientTextureEnabled: boolean;
  97504. private static _OpacityTextureEnabled;
  97505. /**
  97506. * Are opacity textures enabled in the application.
  97507. */
  97508. static OpacityTextureEnabled: boolean;
  97509. private static _ReflectionTextureEnabled;
  97510. /**
  97511. * Are reflection textures enabled in the application.
  97512. */
  97513. static ReflectionTextureEnabled: boolean;
  97514. private static _EmissiveTextureEnabled;
  97515. /**
  97516. * Are emissive textures enabled in the application.
  97517. */
  97518. static EmissiveTextureEnabled: boolean;
  97519. private static _SpecularTextureEnabled;
  97520. /**
  97521. * Are specular textures enabled in the application.
  97522. */
  97523. static SpecularTextureEnabled: boolean;
  97524. private static _BumpTextureEnabled;
  97525. /**
  97526. * Are bump textures enabled in the application.
  97527. */
  97528. static BumpTextureEnabled: boolean;
  97529. private static _LightmapTextureEnabled;
  97530. /**
  97531. * Are lightmap textures enabled in the application.
  97532. */
  97533. static LightmapTextureEnabled: boolean;
  97534. private static _RefractionTextureEnabled;
  97535. /**
  97536. * Are refraction textures enabled in the application.
  97537. */
  97538. static RefractionTextureEnabled: boolean;
  97539. private static _ColorGradingTextureEnabled;
  97540. /**
  97541. * Are color grading textures enabled in the application.
  97542. */
  97543. static ColorGradingTextureEnabled: boolean;
  97544. private static _FresnelEnabled;
  97545. /**
  97546. * Are fresnels enabled in the application.
  97547. */
  97548. static FresnelEnabled: boolean;
  97549. private static _ClearCoatTextureEnabled;
  97550. /**
  97551. * Are clear coat textures enabled in the application.
  97552. */
  97553. static ClearCoatTextureEnabled: boolean;
  97554. private static _ClearCoatBumpTextureEnabled;
  97555. /**
  97556. * Are clear coat bump textures enabled in the application.
  97557. */
  97558. static ClearCoatBumpTextureEnabled: boolean;
  97559. private static _ClearCoatTintTextureEnabled;
  97560. /**
  97561. * Are clear coat tint textures enabled in the application.
  97562. */
  97563. static ClearCoatTintTextureEnabled: boolean;
  97564. private static _SheenTextureEnabled;
  97565. /**
  97566. * Are sheen textures enabled in the application.
  97567. */
  97568. static SheenTextureEnabled: boolean;
  97569. private static _AnisotropicTextureEnabled;
  97570. /**
  97571. * Are anisotropic textures enabled in the application.
  97572. */
  97573. static AnisotropicTextureEnabled: boolean;
  97574. private static _ThicknessTextureEnabled;
  97575. /**
  97576. * Are thickness textures enabled in the application.
  97577. */
  97578. static ThicknessTextureEnabled: boolean;
  97579. }
  97580. }
  97581. declare module BABYLON {
  97582. /** @hidden */
  97583. export var defaultFragmentDeclaration: {
  97584. name: string;
  97585. shader: string;
  97586. };
  97587. }
  97588. declare module BABYLON {
  97589. /** @hidden */
  97590. export var defaultUboDeclaration: {
  97591. name: string;
  97592. shader: string;
  97593. };
  97594. }
  97595. declare module BABYLON {
  97596. /** @hidden */
  97597. export var lightFragmentDeclaration: {
  97598. name: string;
  97599. shader: string;
  97600. };
  97601. }
  97602. declare module BABYLON {
  97603. /** @hidden */
  97604. export var lightUboDeclaration: {
  97605. name: string;
  97606. shader: string;
  97607. };
  97608. }
  97609. declare module BABYLON {
  97610. /** @hidden */
  97611. export var lightsFragmentFunctions: {
  97612. name: string;
  97613. shader: string;
  97614. };
  97615. }
  97616. declare module BABYLON {
  97617. /** @hidden */
  97618. export var shadowsFragmentFunctions: {
  97619. name: string;
  97620. shader: string;
  97621. };
  97622. }
  97623. declare module BABYLON {
  97624. /** @hidden */
  97625. export var fresnelFunction: {
  97626. name: string;
  97627. shader: string;
  97628. };
  97629. }
  97630. declare module BABYLON {
  97631. /** @hidden */
  97632. export var reflectionFunction: {
  97633. name: string;
  97634. shader: string;
  97635. };
  97636. }
  97637. declare module BABYLON {
  97638. /** @hidden */
  97639. export var bumpFragmentFunctions: {
  97640. name: string;
  97641. shader: string;
  97642. };
  97643. }
  97644. declare module BABYLON {
  97645. /** @hidden */
  97646. export var logDepthDeclaration: {
  97647. name: string;
  97648. shader: string;
  97649. };
  97650. }
  97651. declare module BABYLON {
  97652. /** @hidden */
  97653. export var bumpFragment: {
  97654. name: string;
  97655. shader: string;
  97656. };
  97657. }
  97658. declare module BABYLON {
  97659. /** @hidden */
  97660. export var depthPrePass: {
  97661. name: string;
  97662. shader: string;
  97663. };
  97664. }
  97665. declare module BABYLON {
  97666. /** @hidden */
  97667. export var lightFragment: {
  97668. name: string;
  97669. shader: string;
  97670. };
  97671. }
  97672. declare module BABYLON {
  97673. /** @hidden */
  97674. export var logDepthFragment: {
  97675. name: string;
  97676. shader: string;
  97677. };
  97678. }
  97679. declare module BABYLON {
  97680. /** @hidden */
  97681. export var defaultPixelShader: {
  97682. name: string;
  97683. shader: string;
  97684. };
  97685. }
  97686. declare module BABYLON {
  97687. /** @hidden */
  97688. export var defaultVertexDeclaration: {
  97689. name: string;
  97690. shader: string;
  97691. };
  97692. }
  97693. declare module BABYLON {
  97694. /** @hidden */
  97695. export var bumpVertexDeclaration: {
  97696. name: string;
  97697. shader: string;
  97698. };
  97699. }
  97700. declare module BABYLON {
  97701. /** @hidden */
  97702. export var bumpVertex: {
  97703. name: string;
  97704. shader: string;
  97705. };
  97706. }
  97707. declare module BABYLON {
  97708. /** @hidden */
  97709. export var fogVertex: {
  97710. name: string;
  97711. shader: string;
  97712. };
  97713. }
  97714. declare module BABYLON {
  97715. /** @hidden */
  97716. export var shadowsVertex: {
  97717. name: string;
  97718. shader: string;
  97719. };
  97720. }
  97721. declare module BABYLON {
  97722. /** @hidden */
  97723. export var pointCloudVertex: {
  97724. name: string;
  97725. shader: string;
  97726. };
  97727. }
  97728. declare module BABYLON {
  97729. /** @hidden */
  97730. export var logDepthVertex: {
  97731. name: string;
  97732. shader: string;
  97733. };
  97734. }
  97735. declare module BABYLON {
  97736. /** @hidden */
  97737. export var defaultVertexShader: {
  97738. name: string;
  97739. shader: string;
  97740. };
  97741. }
  97742. declare module BABYLON {
  97743. /** @hidden */
  97744. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97745. MAINUV1: boolean;
  97746. MAINUV2: boolean;
  97747. DIFFUSE: boolean;
  97748. DIFFUSEDIRECTUV: number;
  97749. AMBIENT: boolean;
  97750. AMBIENTDIRECTUV: number;
  97751. OPACITY: boolean;
  97752. OPACITYDIRECTUV: number;
  97753. OPACITYRGB: boolean;
  97754. REFLECTION: boolean;
  97755. EMISSIVE: boolean;
  97756. EMISSIVEDIRECTUV: number;
  97757. SPECULAR: boolean;
  97758. SPECULARDIRECTUV: number;
  97759. BUMP: boolean;
  97760. BUMPDIRECTUV: number;
  97761. PARALLAX: boolean;
  97762. PARALLAXOCCLUSION: boolean;
  97763. SPECULAROVERALPHA: boolean;
  97764. CLIPPLANE: boolean;
  97765. CLIPPLANE2: boolean;
  97766. CLIPPLANE3: boolean;
  97767. CLIPPLANE4: boolean;
  97768. ALPHATEST: boolean;
  97769. DEPTHPREPASS: boolean;
  97770. ALPHAFROMDIFFUSE: boolean;
  97771. POINTSIZE: boolean;
  97772. FOG: boolean;
  97773. SPECULARTERM: boolean;
  97774. DIFFUSEFRESNEL: boolean;
  97775. OPACITYFRESNEL: boolean;
  97776. REFLECTIONFRESNEL: boolean;
  97777. REFRACTIONFRESNEL: boolean;
  97778. EMISSIVEFRESNEL: boolean;
  97779. FRESNEL: boolean;
  97780. NORMAL: boolean;
  97781. UV1: boolean;
  97782. UV2: boolean;
  97783. VERTEXCOLOR: boolean;
  97784. VERTEXALPHA: boolean;
  97785. NUM_BONE_INFLUENCERS: number;
  97786. BonesPerMesh: number;
  97787. BONETEXTURE: boolean;
  97788. INSTANCES: boolean;
  97789. GLOSSINESS: boolean;
  97790. ROUGHNESS: boolean;
  97791. EMISSIVEASILLUMINATION: boolean;
  97792. LINKEMISSIVEWITHDIFFUSE: boolean;
  97793. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97794. LIGHTMAP: boolean;
  97795. LIGHTMAPDIRECTUV: number;
  97796. OBJECTSPACE_NORMALMAP: boolean;
  97797. USELIGHTMAPASSHADOWMAP: boolean;
  97798. REFLECTIONMAP_3D: boolean;
  97799. REFLECTIONMAP_SPHERICAL: boolean;
  97800. REFLECTIONMAP_PLANAR: boolean;
  97801. REFLECTIONMAP_CUBIC: boolean;
  97802. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97803. REFLECTIONMAP_PROJECTION: boolean;
  97804. REFLECTIONMAP_SKYBOX: boolean;
  97805. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97806. REFLECTIONMAP_EXPLICIT: boolean;
  97807. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97808. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97809. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97810. INVERTCUBICMAP: boolean;
  97811. LOGARITHMICDEPTH: boolean;
  97812. REFRACTION: boolean;
  97813. REFRACTIONMAP_3D: boolean;
  97814. REFLECTIONOVERALPHA: boolean;
  97815. TWOSIDEDLIGHTING: boolean;
  97816. SHADOWFLOAT: boolean;
  97817. MORPHTARGETS: boolean;
  97818. MORPHTARGETS_NORMAL: boolean;
  97819. MORPHTARGETS_TANGENT: boolean;
  97820. NUM_MORPH_INFLUENCERS: number;
  97821. NONUNIFORMSCALING: boolean;
  97822. PREMULTIPLYALPHA: boolean;
  97823. IMAGEPROCESSING: boolean;
  97824. VIGNETTE: boolean;
  97825. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97826. VIGNETTEBLENDMODEOPAQUE: boolean;
  97827. TONEMAPPING: boolean;
  97828. TONEMAPPING_ACES: boolean;
  97829. CONTRAST: boolean;
  97830. COLORCURVES: boolean;
  97831. COLORGRADING: boolean;
  97832. COLORGRADING3D: boolean;
  97833. SAMPLER3DGREENDEPTH: boolean;
  97834. SAMPLER3DBGRMAP: boolean;
  97835. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97836. MULTIVIEW: boolean;
  97837. /**
  97838. * If the reflection texture on this material is in linear color space
  97839. * @hidden
  97840. */
  97841. IS_REFLECTION_LINEAR: boolean;
  97842. /**
  97843. * If the refraction texture on this material is in linear color space
  97844. * @hidden
  97845. */
  97846. IS_REFRACTION_LINEAR: boolean;
  97847. EXPOSURE: boolean;
  97848. constructor();
  97849. setReflectionMode(modeToEnable: string): void;
  97850. }
  97851. /**
  97852. * This is the default material used in Babylon. It is the best trade off between quality
  97853. * and performances.
  97854. * @see http://doc.babylonjs.com/babylon101/materials
  97855. */
  97856. export class StandardMaterial extends PushMaterial {
  97857. private _diffuseTexture;
  97858. /**
  97859. * The basic texture of the material as viewed under a light.
  97860. */
  97861. diffuseTexture: Nullable<BaseTexture>;
  97862. private _ambientTexture;
  97863. /**
  97864. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97865. */
  97866. ambientTexture: Nullable<BaseTexture>;
  97867. private _opacityTexture;
  97868. /**
  97869. * Define the transparency of the material from a texture.
  97870. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97871. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97872. */
  97873. opacityTexture: Nullable<BaseTexture>;
  97874. private _reflectionTexture;
  97875. /**
  97876. * Define the texture used to display the reflection.
  97877. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97878. */
  97879. reflectionTexture: Nullable<BaseTexture>;
  97880. private _emissiveTexture;
  97881. /**
  97882. * Define texture of the material as if self lit.
  97883. * This will be mixed in the final result even in the absence of light.
  97884. */
  97885. emissiveTexture: Nullable<BaseTexture>;
  97886. private _specularTexture;
  97887. /**
  97888. * Define how the color and intensity of the highlight given by the light in the material.
  97889. */
  97890. specularTexture: Nullable<BaseTexture>;
  97891. private _bumpTexture;
  97892. /**
  97893. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97894. * 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.
  97895. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97896. */
  97897. bumpTexture: Nullable<BaseTexture>;
  97898. private _lightmapTexture;
  97899. /**
  97900. * Complex lighting can be computationally expensive to compute at runtime.
  97901. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97902. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97903. */
  97904. lightmapTexture: Nullable<BaseTexture>;
  97905. private _refractionTexture;
  97906. /**
  97907. * Define the texture used to display the refraction.
  97908. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97909. */
  97910. refractionTexture: Nullable<BaseTexture>;
  97911. /**
  97912. * The color of the material lit by the environmental background lighting.
  97913. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97914. */
  97915. ambientColor: Color3;
  97916. /**
  97917. * The basic color of the material as viewed under a light.
  97918. */
  97919. diffuseColor: Color3;
  97920. /**
  97921. * Define how the color and intensity of the highlight given by the light in the material.
  97922. */
  97923. specularColor: Color3;
  97924. /**
  97925. * Define the color of the material as if self lit.
  97926. * This will be mixed in the final result even in the absence of light.
  97927. */
  97928. emissiveColor: Color3;
  97929. /**
  97930. * Defines how sharp are the highlights in the material.
  97931. * The bigger the value the sharper giving a more glossy feeling to the result.
  97932. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97933. */
  97934. specularPower: number;
  97935. private _useAlphaFromDiffuseTexture;
  97936. /**
  97937. * Does the transparency come from the diffuse texture alpha channel.
  97938. */
  97939. useAlphaFromDiffuseTexture: boolean;
  97940. private _useEmissiveAsIllumination;
  97941. /**
  97942. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97943. */
  97944. useEmissiveAsIllumination: boolean;
  97945. private _linkEmissiveWithDiffuse;
  97946. /**
  97947. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97948. * the emissive level when the final color is close to one.
  97949. */
  97950. linkEmissiveWithDiffuse: boolean;
  97951. private _useSpecularOverAlpha;
  97952. /**
  97953. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97954. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97955. */
  97956. useSpecularOverAlpha: boolean;
  97957. private _useReflectionOverAlpha;
  97958. /**
  97959. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97960. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97961. */
  97962. useReflectionOverAlpha: boolean;
  97963. private _disableLighting;
  97964. /**
  97965. * Does lights from the scene impacts this material.
  97966. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97967. */
  97968. disableLighting: boolean;
  97969. private _useObjectSpaceNormalMap;
  97970. /**
  97971. * Allows using an object space normal map (instead of tangent space).
  97972. */
  97973. useObjectSpaceNormalMap: boolean;
  97974. private _useParallax;
  97975. /**
  97976. * Is parallax enabled or not.
  97977. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97978. */
  97979. useParallax: boolean;
  97980. private _useParallaxOcclusion;
  97981. /**
  97982. * Is parallax occlusion enabled or not.
  97983. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97984. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97985. */
  97986. useParallaxOcclusion: boolean;
  97987. /**
  97988. * 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.
  97989. */
  97990. parallaxScaleBias: number;
  97991. private _roughness;
  97992. /**
  97993. * Helps to define how blurry the reflections should appears in the material.
  97994. */
  97995. roughness: number;
  97996. /**
  97997. * In case of refraction, define the value of the indice of refraction.
  97998. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97999. */
  98000. indexOfRefraction: number;
  98001. /**
  98002. * Invert the refraction texture alongside the y axis.
  98003. * It can be useful with procedural textures or probe for instance.
  98004. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98005. */
  98006. invertRefractionY: boolean;
  98007. /**
  98008. * Defines the alpha limits in alpha test mode.
  98009. */
  98010. alphaCutOff: number;
  98011. private _useLightmapAsShadowmap;
  98012. /**
  98013. * In case of light mapping, define whether the map contains light or shadow informations.
  98014. */
  98015. useLightmapAsShadowmap: boolean;
  98016. private _diffuseFresnelParameters;
  98017. /**
  98018. * Define the diffuse fresnel parameters of the material.
  98019. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98020. */
  98021. diffuseFresnelParameters: FresnelParameters;
  98022. private _opacityFresnelParameters;
  98023. /**
  98024. * Define the opacity fresnel parameters of the material.
  98025. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98026. */
  98027. opacityFresnelParameters: FresnelParameters;
  98028. private _reflectionFresnelParameters;
  98029. /**
  98030. * Define the reflection fresnel parameters of the material.
  98031. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98032. */
  98033. reflectionFresnelParameters: FresnelParameters;
  98034. private _refractionFresnelParameters;
  98035. /**
  98036. * Define the refraction fresnel parameters of the material.
  98037. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98038. */
  98039. refractionFresnelParameters: FresnelParameters;
  98040. private _emissiveFresnelParameters;
  98041. /**
  98042. * Define the emissive fresnel parameters of the material.
  98043. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98044. */
  98045. emissiveFresnelParameters: FresnelParameters;
  98046. private _useReflectionFresnelFromSpecular;
  98047. /**
  98048. * If true automatically deducts the fresnels values from the material specularity.
  98049. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98050. */
  98051. useReflectionFresnelFromSpecular: boolean;
  98052. private _useGlossinessFromSpecularMapAlpha;
  98053. /**
  98054. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98055. */
  98056. useGlossinessFromSpecularMapAlpha: boolean;
  98057. private _maxSimultaneousLights;
  98058. /**
  98059. * Defines the maximum number of lights that can be used in the material
  98060. */
  98061. maxSimultaneousLights: number;
  98062. private _invertNormalMapX;
  98063. /**
  98064. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98065. */
  98066. invertNormalMapX: boolean;
  98067. private _invertNormalMapY;
  98068. /**
  98069. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98070. */
  98071. invertNormalMapY: boolean;
  98072. private _twoSidedLighting;
  98073. /**
  98074. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98075. */
  98076. twoSidedLighting: boolean;
  98077. /**
  98078. * Default configuration related to image processing available in the standard Material.
  98079. */
  98080. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98081. /**
  98082. * Gets the image processing configuration used either in this material.
  98083. */
  98084. /**
  98085. * Sets the Default image processing configuration used either in the this material.
  98086. *
  98087. * If sets to null, the scene one is in use.
  98088. */
  98089. imageProcessingConfiguration: ImageProcessingConfiguration;
  98090. /**
  98091. * Keep track of the image processing observer to allow dispose and replace.
  98092. */
  98093. private _imageProcessingObserver;
  98094. /**
  98095. * Attaches a new image processing configuration to the Standard Material.
  98096. * @param configuration
  98097. */
  98098. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98099. /**
  98100. * Gets wether the color curves effect is enabled.
  98101. */
  98102. /**
  98103. * Sets wether the color curves effect is enabled.
  98104. */
  98105. cameraColorCurvesEnabled: boolean;
  98106. /**
  98107. * Gets wether the color grading effect is enabled.
  98108. */
  98109. /**
  98110. * Gets wether the color grading effect is enabled.
  98111. */
  98112. cameraColorGradingEnabled: boolean;
  98113. /**
  98114. * Gets wether tonemapping is enabled or not.
  98115. */
  98116. /**
  98117. * Sets wether tonemapping is enabled or not
  98118. */
  98119. cameraToneMappingEnabled: boolean;
  98120. /**
  98121. * The camera exposure used on this material.
  98122. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98123. * This corresponds to a photographic exposure.
  98124. */
  98125. /**
  98126. * The camera exposure used on this material.
  98127. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98128. * This corresponds to a photographic exposure.
  98129. */
  98130. cameraExposure: number;
  98131. /**
  98132. * Gets The camera contrast used on this material.
  98133. */
  98134. /**
  98135. * Sets The camera contrast used on this material.
  98136. */
  98137. cameraContrast: number;
  98138. /**
  98139. * Gets the Color Grading 2D Lookup Texture.
  98140. */
  98141. /**
  98142. * Sets the Color Grading 2D Lookup Texture.
  98143. */
  98144. cameraColorGradingTexture: Nullable<BaseTexture>;
  98145. /**
  98146. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98147. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98148. * 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;
  98149. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98150. */
  98151. /**
  98152. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98153. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98154. * 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;
  98155. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98156. */
  98157. cameraColorCurves: Nullable<ColorCurves>;
  98158. /**
  98159. * Custom callback helping to override the default shader used in the material.
  98160. */
  98161. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98162. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98163. protected _worldViewProjectionMatrix: Matrix;
  98164. protected _globalAmbientColor: Color3;
  98165. protected _useLogarithmicDepth: boolean;
  98166. /**
  98167. * Instantiates a new standard material.
  98168. * This is the default material used in Babylon. It is the best trade off between quality
  98169. * and performances.
  98170. * @see http://doc.babylonjs.com/babylon101/materials
  98171. * @param name Define the name of the material in the scene
  98172. * @param scene Define the scene the material belong to
  98173. */
  98174. constructor(name: string, scene: Scene);
  98175. /**
  98176. * Gets a boolean indicating that current material needs to register RTT
  98177. */
  98178. readonly hasRenderTargetTextures: boolean;
  98179. /**
  98180. * Gets the current class name of the material e.g. "StandardMaterial"
  98181. * Mainly use in serialization.
  98182. * @returns the class name
  98183. */
  98184. getClassName(): string;
  98185. /**
  98186. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98187. * You can try switching to logarithmic depth.
  98188. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98189. */
  98190. useLogarithmicDepth: boolean;
  98191. /**
  98192. * Specifies if the material will require alpha blending
  98193. * @returns a boolean specifying if alpha blending is needed
  98194. */
  98195. needAlphaBlending(): boolean;
  98196. /**
  98197. * Specifies if this material should be rendered in alpha test mode
  98198. * @returns a boolean specifying if an alpha test is needed.
  98199. */
  98200. needAlphaTesting(): boolean;
  98201. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98202. /**
  98203. * Get the texture used for alpha test purpose.
  98204. * @returns the diffuse texture in case of the standard material.
  98205. */
  98206. getAlphaTestTexture(): Nullable<BaseTexture>;
  98207. /**
  98208. * Get if the submesh is ready to be used and all its information available.
  98209. * Child classes can use it to update shaders
  98210. * @param mesh defines the mesh to check
  98211. * @param subMesh defines which submesh to check
  98212. * @param useInstances specifies that instances should be used
  98213. * @returns a boolean indicating that the submesh is ready or not
  98214. */
  98215. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98216. /**
  98217. * Builds the material UBO layouts.
  98218. * Used internally during the effect preparation.
  98219. */
  98220. buildUniformLayout(): void;
  98221. /**
  98222. * Unbinds the material from the mesh
  98223. */
  98224. unbind(): void;
  98225. /**
  98226. * Binds the submesh to this material by preparing the effect and shader to draw
  98227. * @param world defines the world transformation matrix
  98228. * @param mesh defines the mesh containing the submesh
  98229. * @param subMesh defines the submesh to bind the material to
  98230. */
  98231. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98232. /**
  98233. * Get the list of animatables in the material.
  98234. * @returns the list of animatables object used in the material
  98235. */
  98236. getAnimatables(): IAnimatable[];
  98237. /**
  98238. * Gets the active textures from the material
  98239. * @returns an array of textures
  98240. */
  98241. getActiveTextures(): BaseTexture[];
  98242. /**
  98243. * Specifies if the material uses a texture
  98244. * @param texture defines the texture to check against the material
  98245. * @returns a boolean specifying if the material uses the texture
  98246. */
  98247. hasTexture(texture: BaseTexture): boolean;
  98248. /**
  98249. * Disposes the material
  98250. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98251. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98252. */
  98253. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98254. /**
  98255. * Makes a duplicate of the material, and gives it a new name
  98256. * @param name defines the new name for the duplicated material
  98257. * @returns the cloned material
  98258. */
  98259. clone(name: string): StandardMaterial;
  98260. /**
  98261. * Serializes this material in a JSON representation
  98262. * @returns the serialized material object
  98263. */
  98264. serialize(): any;
  98265. /**
  98266. * Creates a standard material from parsed material data
  98267. * @param source defines the JSON representation of the material
  98268. * @param scene defines the hosting scene
  98269. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98270. * @returns a new standard material
  98271. */
  98272. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98273. /**
  98274. * Are diffuse textures enabled in the application.
  98275. */
  98276. static DiffuseTextureEnabled: boolean;
  98277. /**
  98278. * Are ambient textures enabled in the application.
  98279. */
  98280. static AmbientTextureEnabled: boolean;
  98281. /**
  98282. * Are opacity textures enabled in the application.
  98283. */
  98284. static OpacityTextureEnabled: boolean;
  98285. /**
  98286. * Are reflection textures enabled in the application.
  98287. */
  98288. static ReflectionTextureEnabled: boolean;
  98289. /**
  98290. * Are emissive textures enabled in the application.
  98291. */
  98292. static EmissiveTextureEnabled: boolean;
  98293. /**
  98294. * Are specular textures enabled in the application.
  98295. */
  98296. static SpecularTextureEnabled: boolean;
  98297. /**
  98298. * Are bump textures enabled in the application.
  98299. */
  98300. static BumpTextureEnabled: boolean;
  98301. /**
  98302. * Are lightmap textures enabled in the application.
  98303. */
  98304. static LightmapTextureEnabled: boolean;
  98305. /**
  98306. * Are refraction textures enabled in the application.
  98307. */
  98308. static RefractionTextureEnabled: boolean;
  98309. /**
  98310. * Are color grading textures enabled in the application.
  98311. */
  98312. static ColorGradingTextureEnabled: boolean;
  98313. /**
  98314. * Are fresnels enabled in the application.
  98315. */
  98316. static FresnelEnabled: boolean;
  98317. }
  98318. }
  98319. declare module BABYLON {
  98320. /**
  98321. * A class extending Texture allowing drawing on a texture
  98322. * @see http://doc.babylonjs.com/how_to/dynamictexture
  98323. */
  98324. export class DynamicTexture extends Texture {
  98325. private _generateMipMaps;
  98326. private _canvas;
  98327. private _context;
  98328. private _engine;
  98329. /**
  98330. * Creates a DynamicTexture
  98331. * @param name defines the name of the texture
  98332. * @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
  98333. * @param scene defines the scene where you want the texture
  98334. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  98335. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98336. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  98337. */
  98338. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  98339. /**
  98340. * Get the current class name of the texture useful for serialization or dynamic coding.
  98341. * @returns "DynamicTexture"
  98342. */
  98343. getClassName(): string;
  98344. /**
  98345. * Gets the current state of canRescale
  98346. */
  98347. readonly canRescale: boolean;
  98348. private _recreate;
  98349. /**
  98350. * Scales the texture
  98351. * @param ratio the scale factor to apply to both width and height
  98352. */
  98353. scale(ratio: number): void;
  98354. /**
  98355. * Resizes the texture
  98356. * @param width the new width
  98357. * @param height the new height
  98358. */
  98359. scaleTo(width: number, height: number): void;
  98360. /**
  98361. * Gets the context of the canvas used by the texture
  98362. * @returns the canvas context of the dynamic texture
  98363. */
  98364. getContext(): CanvasRenderingContext2D;
  98365. /**
  98366. * Clears the texture
  98367. */
  98368. clear(): void;
  98369. /**
  98370. * Updates the texture
  98371. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98372. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  98373. */
  98374. update(invertY?: boolean, premulAlpha?: boolean): void;
  98375. /**
  98376. * Draws text onto the texture
  98377. * @param text defines the text to be drawn
  98378. * @param x defines the placement of the text from the left
  98379. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98380. * @param font defines the font to be used with font-style, font-size, font-name
  98381. * @param color defines the color used for the text
  98382. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98383. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98384. * @param update defines whether texture is immediately update (default is true)
  98385. */
  98386. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98387. /**
  98388. * Clones the texture
  98389. * @returns the clone of the texture.
  98390. */
  98391. clone(): DynamicTexture;
  98392. /**
  98393. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98394. * @returns a serialized dynamic texture object
  98395. */
  98396. serialize(): any;
  98397. /** @hidden */
  98398. _rebuild(): void;
  98399. }
  98400. }
  98401. declare module BABYLON {
  98402. /** @hidden */
  98403. export var imageProcessingPixelShader: {
  98404. name: string;
  98405. shader: string;
  98406. };
  98407. }
  98408. declare module BABYLON {
  98409. /**
  98410. * ImageProcessingPostProcess
  98411. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98412. */
  98413. export class ImageProcessingPostProcess extends PostProcess {
  98414. /**
  98415. * Default configuration related to image processing available in the PBR Material.
  98416. */
  98417. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98418. /**
  98419. * Gets the image processing configuration used either in this material.
  98420. */
  98421. /**
  98422. * Sets the Default image processing configuration used either in the this material.
  98423. *
  98424. * If sets to null, the scene one is in use.
  98425. */
  98426. imageProcessingConfiguration: ImageProcessingConfiguration;
  98427. /**
  98428. * Keep track of the image processing observer to allow dispose and replace.
  98429. */
  98430. private _imageProcessingObserver;
  98431. /**
  98432. * Attaches a new image processing configuration to the PBR Material.
  98433. * @param configuration
  98434. */
  98435. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98436. /**
  98437. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98438. */
  98439. /**
  98440. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98441. */
  98442. colorCurves: Nullable<ColorCurves>;
  98443. /**
  98444. * Gets wether the color curves effect is enabled.
  98445. */
  98446. /**
  98447. * Sets wether the color curves effect is enabled.
  98448. */
  98449. colorCurvesEnabled: boolean;
  98450. /**
  98451. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98452. */
  98453. /**
  98454. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98455. */
  98456. colorGradingTexture: Nullable<BaseTexture>;
  98457. /**
  98458. * Gets wether the color grading effect is enabled.
  98459. */
  98460. /**
  98461. * Gets wether the color grading effect is enabled.
  98462. */
  98463. colorGradingEnabled: boolean;
  98464. /**
  98465. * Gets exposure used in the effect.
  98466. */
  98467. /**
  98468. * Sets exposure used in the effect.
  98469. */
  98470. exposure: number;
  98471. /**
  98472. * Gets wether tonemapping is enabled or not.
  98473. */
  98474. /**
  98475. * Sets wether tonemapping is enabled or not
  98476. */
  98477. toneMappingEnabled: boolean;
  98478. /**
  98479. * Gets the type of tone mapping effect.
  98480. */
  98481. /**
  98482. * Sets the type of tone mapping effect.
  98483. */
  98484. toneMappingType: number;
  98485. /**
  98486. * Gets contrast used in the effect.
  98487. */
  98488. /**
  98489. * Sets contrast used in the effect.
  98490. */
  98491. contrast: number;
  98492. /**
  98493. * Gets Vignette stretch size.
  98494. */
  98495. /**
  98496. * Sets Vignette stretch size.
  98497. */
  98498. vignetteStretch: number;
  98499. /**
  98500. * Gets Vignette centre X Offset.
  98501. */
  98502. /**
  98503. * Sets Vignette centre X Offset.
  98504. */
  98505. vignetteCentreX: number;
  98506. /**
  98507. * Gets Vignette centre Y Offset.
  98508. */
  98509. /**
  98510. * Sets Vignette centre Y Offset.
  98511. */
  98512. vignetteCentreY: number;
  98513. /**
  98514. * Gets Vignette weight or intensity of the vignette effect.
  98515. */
  98516. /**
  98517. * Sets Vignette weight or intensity of the vignette effect.
  98518. */
  98519. vignetteWeight: number;
  98520. /**
  98521. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98522. * if vignetteEnabled is set to true.
  98523. */
  98524. /**
  98525. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98526. * if vignetteEnabled is set to true.
  98527. */
  98528. vignetteColor: Color4;
  98529. /**
  98530. * Gets Camera field of view used by the Vignette effect.
  98531. */
  98532. /**
  98533. * Sets Camera field of view used by the Vignette effect.
  98534. */
  98535. vignetteCameraFov: number;
  98536. /**
  98537. * Gets the vignette blend mode allowing different kind of effect.
  98538. */
  98539. /**
  98540. * Sets the vignette blend mode allowing different kind of effect.
  98541. */
  98542. vignetteBlendMode: number;
  98543. /**
  98544. * Gets wether the vignette effect is enabled.
  98545. */
  98546. /**
  98547. * Sets wether the vignette effect is enabled.
  98548. */
  98549. vignetteEnabled: boolean;
  98550. private _fromLinearSpace;
  98551. /**
  98552. * Gets wether the input of the processing is in Gamma or Linear Space.
  98553. */
  98554. /**
  98555. * Sets wether the input of the processing is in Gamma or Linear Space.
  98556. */
  98557. fromLinearSpace: boolean;
  98558. /**
  98559. * Defines cache preventing GC.
  98560. */
  98561. private _defines;
  98562. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98563. /**
  98564. * "ImageProcessingPostProcess"
  98565. * @returns "ImageProcessingPostProcess"
  98566. */
  98567. getClassName(): string;
  98568. protected _updateParameters(): void;
  98569. dispose(camera?: Camera): void;
  98570. }
  98571. }
  98572. declare module BABYLON {
  98573. /**
  98574. * Class containing static functions to help procedurally build meshes
  98575. */
  98576. export class GroundBuilder {
  98577. /**
  98578. * Creates a ground mesh
  98579. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98580. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98582. * @param name defines the name of the mesh
  98583. * @param options defines the options used to create the mesh
  98584. * @param scene defines the hosting scene
  98585. * @returns the ground mesh
  98586. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98587. */
  98588. static CreateGround(name: string, options: {
  98589. width?: number;
  98590. height?: number;
  98591. subdivisions?: number;
  98592. subdivisionsX?: number;
  98593. subdivisionsY?: number;
  98594. updatable?: boolean;
  98595. }, scene: any): Mesh;
  98596. /**
  98597. * Creates a tiled ground mesh
  98598. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98599. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98600. * * 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
  98601. * * 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
  98602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98603. * @param name defines the name of the mesh
  98604. * @param options defines the options used to create the mesh
  98605. * @param scene defines the hosting scene
  98606. * @returns the tiled ground mesh
  98607. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98608. */
  98609. static CreateTiledGround(name: string, options: {
  98610. xmin: number;
  98611. zmin: number;
  98612. xmax: number;
  98613. zmax: number;
  98614. subdivisions?: {
  98615. w: number;
  98616. h: number;
  98617. };
  98618. precision?: {
  98619. w: number;
  98620. h: number;
  98621. };
  98622. updatable?: boolean;
  98623. }, scene?: Nullable<Scene>): Mesh;
  98624. /**
  98625. * Creates a ground mesh from a height map
  98626. * * The parameter `url` sets the URL of the height map image resource.
  98627. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98628. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98629. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98630. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98631. * * 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.
  98632. * * 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).
  98633. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98635. * @param name defines the name of the mesh
  98636. * @param url defines the url to the height map
  98637. * @param options defines the options used to create the mesh
  98638. * @param scene defines the hosting scene
  98639. * @returns the ground mesh
  98640. * @see https://doc.babylonjs.com/babylon101/height_map
  98641. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98642. */
  98643. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98644. width?: number;
  98645. height?: number;
  98646. subdivisions?: number;
  98647. minHeight?: number;
  98648. maxHeight?: number;
  98649. colorFilter?: Color3;
  98650. alphaFilter?: number;
  98651. updatable?: boolean;
  98652. onReady?: (mesh: GroundMesh) => void;
  98653. }, scene?: Nullable<Scene>): GroundMesh;
  98654. }
  98655. }
  98656. declare module BABYLON {
  98657. /**
  98658. * Class containing static functions to help procedurally build meshes
  98659. */
  98660. export class TorusBuilder {
  98661. /**
  98662. * Creates a torus mesh
  98663. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  98664. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  98665. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  98666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98669. * @param name defines the name of the mesh
  98670. * @param options defines the options used to create the mesh
  98671. * @param scene defines the hosting scene
  98672. * @returns the torus mesh
  98673. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  98674. */
  98675. static CreateTorus(name: string, options: {
  98676. diameter?: number;
  98677. thickness?: number;
  98678. tessellation?: number;
  98679. updatable?: boolean;
  98680. sideOrientation?: number;
  98681. frontUVs?: Vector4;
  98682. backUVs?: Vector4;
  98683. }, scene: any): Mesh;
  98684. }
  98685. }
  98686. declare module BABYLON {
  98687. /**
  98688. * Class containing static functions to help procedurally build meshes
  98689. */
  98690. export class CylinderBuilder {
  98691. /**
  98692. * Creates a cylinder or a cone mesh
  98693. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  98694. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  98695. * * 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.
  98696. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  98697. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  98698. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  98699. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  98700. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  98701. * * 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).
  98702. * * 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
  98703. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  98704. * * 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
  98705. * * 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.
  98706. * * If `enclose` is false, a ring surface is one element.
  98707. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  98708. * * 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
  98709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98710. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98712. * @param name defines the name of the mesh
  98713. * @param options defines the options used to create the mesh
  98714. * @param scene defines the hosting scene
  98715. * @returns the cylinder mesh
  98716. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  98717. */
  98718. static CreateCylinder(name: string, options: {
  98719. height?: number;
  98720. diameterTop?: number;
  98721. diameterBottom?: number;
  98722. diameter?: number;
  98723. tessellation?: number;
  98724. subdivisions?: number;
  98725. arc?: number;
  98726. faceColors?: Color4[];
  98727. faceUV?: Vector4[];
  98728. updatable?: boolean;
  98729. hasRings?: boolean;
  98730. enclose?: boolean;
  98731. sideOrientation?: number;
  98732. frontUVs?: Vector4;
  98733. backUVs?: Vector4;
  98734. }, scene: any): Mesh;
  98735. }
  98736. }
  98737. declare module BABYLON {
  98738. /**
  98739. * Manager for handling gamepads
  98740. */
  98741. export class GamepadManager {
  98742. private _scene?;
  98743. private _babylonGamepads;
  98744. private _oneGamepadConnected;
  98745. /** @hidden */
  98746. _isMonitoring: boolean;
  98747. private _gamepadEventSupported;
  98748. private _gamepadSupport;
  98749. /**
  98750. * observable to be triggered when the gamepad controller has been connected
  98751. */
  98752. onGamepadConnectedObservable: Observable<Gamepad>;
  98753. /**
  98754. * observable to be triggered when the gamepad controller has been disconnected
  98755. */
  98756. onGamepadDisconnectedObservable: Observable<Gamepad>;
  98757. private _onGamepadConnectedEvent;
  98758. private _onGamepadDisconnectedEvent;
  98759. /**
  98760. * Initializes the gamepad manager
  98761. * @param _scene BabylonJS scene
  98762. */
  98763. constructor(_scene?: Scene | undefined);
  98764. /**
  98765. * The gamepads in the game pad manager
  98766. */
  98767. readonly gamepads: Gamepad[];
  98768. /**
  98769. * Get the gamepad controllers based on type
  98770. * @param type The type of gamepad controller
  98771. * @returns Nullable gamepad
  98772. */
  98773. getGamepadByType(type?: number): Nullable<Gamepad>;
  98774. /**
  98775. * Disposes the gamepad manager
  98776. */
  98777. dispose(): void;
  98778. private _addNewGamepad;
  98779. private _startMonitoringGamepads;
  98780. private _stopMonitoringGamepads;
  98781. /** @hidden */
  98782. _checkGamepadsStatus(): void;
  98783. private _updateGamepadObjects;
  98784. }
  98785. }
  98786. declare module BABYLON {
  98787. interface Scene {
  98788. /** @hidden */
  98789. _gamepadManager: Nullable<GamepadManager>;
  98790. /**
  98791. * Gets the gamepad manager associated with the scene
  98792. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  98793. */
  98794. gamepadManager: GamepadManager;
  98795. }
  98796. /**
  98797. * Interface representing a free camera inputs manager
  98798. */
  98799. interface FreeCameraInputsManager {
  98800. /**
  98801. * Adds gamepad input support to the FreeCameraInputsManager.
  98802. * @returns the FreeCameraInputsManager
  98803. */
  98804. addGamepad(): FreeCameraInputsManager;
  98805. }
  98806. /**
  98807. * Interface representing an arc rotate camera inputs manager
  98808. */
  98809. interface ArcRotateCameraInputsManager {
  98810. /**
  98811. * Adds gamepad input support to the ArcRotateCamera InputManager.
  98812. * @returns the camera inputs manager
  98813. */
  98814. addGamepad(): ArcRotateCameraInputsManager;
  98815. }
  98816. /**
  98817. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  98818. */
  98819. export class GamepadSystemSceneComponent implements ISceneComponent {
  98820. /**
  98821. * The component name helpfull to identify the component in the list of scene components.
  98822. */
  98823. readonly name: string;
  98824. /**
  98825. * The scene the component belongs to.
  98826. */
  98827. scene: Scene;
  98828. /**
  98829. * Creates a new instance of the component for the given scene
  98830. * @param scene Defines the scene to register the component in
  98831. */
  98832. constructor(scene: Scene);
  98833. /**
  98834. * Registers the component in a given scene
  98835. */
  98836. register(): void;
  98837. /**
  98838. * Rebuilds the elements related to this component in case of
  98839. * context lost for instance.
  98840. */
  98841. rebuild(): void;
  98842. /**
  98843. * Disposes the component and the associated ressources
  98844. */
  98845. dispose(): void;
  98846. private _beforeCameraUpdate;
  98847. }
  98848. }
  98849. declare module BABYLON {
  98850. /**
  98851. * Options to modify the vr teleportation behavior.
  98852. */
  98853. export interface VRTeleportationOptions {
  98854. /**
  98855. * The name of the mesh which should be used as the teleportation floor. (default: null)
  98856. */
  98857. floorMeshName?: string;
  98858. /**
  98859. * A list of meshes to be used as the teleportation floor. (default: empty)
  98860. */
  98861. floorMeshes?: Mesh[];
  98862. }
  98863. /**
  98864. * Options to modify the vr experience helper's behavior.
  98865. */
  98866. export interface VRExperienceHelperOptions extends WebVROptions {
  98867. /**
  98868. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  98869. */
  98870. createDeviceOrientationCamera?: boolean;
  98871. /**
  98872. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  98873. */
  98874. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  98875. /**
  98876. * Uses the main button on the controller to toggle the laser casted. (default: true)
  98877. */
  98878. laserToggle?: boolean;
  98879. /**
  98880. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  98881. */
  98882. floorMeshes?: Mesh[];
  98883. /**
  98884. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  98885. */
  98886. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  98887. }
  98888. /**
  98889. * Event containing information after VR has been entered
  98890. */
  98891. export class OnAfterEnteringVRObservableEvent {
  98892. /**
  98893. * If entering vr was successful
  98894. */
  98895. success: boolean;
  98896. }
  98897. /**
  98898. * Helps to quickly add VR support to an existing scene.
  98899. * See http://doc.babylonjs.com/how_to/webvr_helper
  98900. */
  98901. export class VRExperienceHelper {
  98902. /** Options to modify the vr experience helper's behavior. */
  98903. webVROptions: VRExperienceHelperOptions;
  98904. private _scene;
  98905. private _position;
  98906. private _btnVR;
  98907. private _btnVRDisplayed;
  98908. private _webVRsupported;
  98909. private _webVRready;
  98910. private _webVRrequesting;
  98911. private _webVRpresenting;
  98912. private _hasEnteredVR;
  98913. private _fullscreenVRpresenting;
  98914. private _canvas;
  98915. private _webVRCamera;
  98916. private _vrDeviceOrientationCamera;
  98917. private _deviceOrientationCamera;
  98918. private _existingCamera;
  98919. private _onKeyDown;
  98920. private _onVrDisplayPresentChange;
  98921. private _onVRDisplayChanged;
  98922. private _onVRRequestPresentStart;
  98923. private _onVRRequestPresentComplete;
  98924. /**
  98925. * Observable raised right before entering VR.
  98926. */
  98927. onEnteringVRObservable: Observable<VRExperienceHelper>;
  98928. /**
  98929. * Observable raised when entering VR has completed.
  98930. */
  98931. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  98932. /**
  98933. * Observable raised when exiting VR.
  98934. */
  98935. onExitingVRObservable: Observable<VRExperienceHelper>;
  98936. /**
  98937. * Observable raised when controller mesh is loaded.
  98938. */
  98939. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98940. /** Return this.onEnteringVRObservable
  98941. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  98942. */
  98943. readonly onEnteringVR: Observable<VRExperienceHelper>;
  98944. /** Return this.onExitingVRObservable
  98945. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  98946. */
  98947. readonly onExitingVR: Observable<VRExperienceHelper>;
  98948. /** Return this.onControllerMeshLoadedObservable
  98949. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  98950. */
  98951. readonly onControllerMeshLoaded: Observable<WebVRController>;
  98952. private _rayLength;
  98953. private _useCustomVRButton;
  98954. private _teleportationRequested;
  98955. private _teleportActive;
  98956. private _floorMeshName;
  98957. private _floorMeshesCollection;
  98958. private _rotationAllowed;
  98959. private _teleportBackwardsVector;
  98960. private _teleportationTarget;
  98961. private _isDefaultTeleportationTarget;
  98962. private _postProcessMove;
  98963. private _teleportationFillColor;
  98964. private _teleportationBorderColor;
  98965. private _rotationAngle;
  98966. private _haloCenter;
  98967. private _cameraGazer;
  98968. private _padSensibilityUp;
  98969. private _padSensibilityDown;
  98970. private _leftController;
  98971. private _rightController;
  98972. /**
  98973. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  98974. */
  98975. onNewMeshSelected: Observable<AbstractMesh>;
  98976. /**
  98977. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  98978. */
  98979. onNewMeshPicked: Observable<PickingInfo>;
  98980. private _circleEase;
  98981. /**
  98982. * Observable raised before camera teleportation
  98983. */
  98984. onBeforeCameraTeleport: Observable<Vector3>;
  98985. /**
  98986. * Observable raised after camera teleportation
  98987. */
  98988. onAfterCameraTeleport: Observable<Vector3>;
  98989. /**
  98990. * Observable raised when current selected mesh gets unselected
  98991. */
  98992. onSelectedMeshUnselected: Observable<AbstractMesh>;
  98993. private _raySelectionPredicate;
  98994. /**
  98995. * To be optionaly changed by user to define custom ray selection
  98996. */
  98997. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  98998. /**
  98999. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99000. */
  99001. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99002. /**
  99003. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99004. */
  99005. teleportationEnabled: boolean;
  99006. private _defaultHeight;
  99007. private _teleportationInitialized;
  99008. private _interactionsEnabled;
  99009. private _interactionsRequested;
  99010. private _displayGaze;
  99011. private _displayLaserPointer;
  99012. /**
  99013. * The mesh used to display where the user is going to teleport.
  99014. */
  99015. /**
  99016. * Sets the mesh to be used to display where the user is going to teleport.
  99017. */
  99018. teleportationTarget: Mesh;
  99019. /**
  99020. * 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
  99021. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99022. * See http://doc.babylonjs.com/resources/baking_transformations
  99023. */
  99024. gazeTrackerMesh: Mesh;
  99025. /**
  99026. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99027. */
  99028. updateGazeTrackerScale: boolean;
  99029. /**
  99030. * If the gaze trackers color should be updated when selecting meshes
  99031. */
  99032. updateGazeTrackerColor: boolean;
  99033. /**
  99034. * The gaze tracking mesh corresponding to the left controller
  99035. */
  99036. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99037. /**
  99038. * The gaze tracking mesh corresponding to the right controller
  99039. */
  99040. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99041. /**
  99042. * If the ray of the gaze should be displayed.
  99043. */
  99044. /**
  99045. * Sets if the ray of the gaze should be displayed.
  99046. */
  99047. displayGaze: boolean;
  99048. /**
  99049. * If the ray of the LaserPointer should be displayed.
  99050. */
  99051. /**
  99052. * Sets if the ray of the LaserPointer should be displayed.
  99053. */
  99054. displayLaserPointer: boolean;
  99055. /**
  99056. * The deviceOrientationCamera used as the camera when not in VR.
  99057. */
  99058. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99059. /**
  99060. * Based on the current WebVR support, returns the current VR camera used.
  99061. */
  99062. readonly currentVRCamera: Nullable<Camera>;
  99063. /**
  99064. * The webVRCamera which is used when in VR.
  99065. */
  99066. readonly webVRCamera: WebVRFreeCamera;
  99067. /**
  99068. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99069. */
  99070. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99071. private readonly _teleportationRequestInitiated;
  99072. /**
  99073. * Defines wether or not Pointer lock should be requested when switching to
  99074. * full screen.
  99075. */
  99076. requestPointerLockOnFullScreen: boolean;
  99077. /**
  99078. * Instantiates a VRExperienceHelper.
  99079. * Helps to quickly add VR support to an existing scene.
  99080. * @param scene The scene the VRExperienceHelper belongs to.
  99081. * @param webVROptions Options to modify the vr experience helper's behavior.
  99082. */
  99083. constructor(scene: Scene,
  99084. /** Options to modify the vr experience helper's behavior. */
  99085. webVROptions?: VRExperienceHelperOptions);
  99086. private _onDefaultMeshLoaded;
  99087. private _onResize;
  99088. private _onFullscreenChange;
  99089. /**
  99090. * Gets a value indicating if we are currently in VR mode.
  99091. */
  99092. readonly isInVRMode: boolean;
  99093. private onVrDisplayPresentChange;
  99094. private onVRDisplayChanged;
  99095. private moveButtonToBottomRight;
  99096. private displayVRButton;
  99097. private updateButtonVisibility;
  99098. private _cachedAngularSensibility;
  99099. /**
  99100. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99101. * Otherwise, will use the fullscreen API.
  99102. */
  99103. enterVR(): void;
  99104. /**
  99105. * Attempt to exit VR, or fullscreen.
  99106. */
  99107. exitVR(): void;
  99108. /**
  99109. * The position of the vr experience helper.
  99110. */
  99111. /**
  99112. * Sets the position of the vr experience helper.
  99113. */
  99114. position: Vector3;
  99115. /**
  99116. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99117. */
  99118. enableInteractions(): void;
  99119. private readonly _noControllerIsActive;
  99120. private beforeRender;
  99121. private _isTeleportationFloor;
  99122. /**
  99123. * Adds a floor mesh to be used for teleportation.
  99124. * @param floorMesh the mesh to be used for teleportation.
  99125. */
  99126. addFloorMesh(floorMesh: Mesh): void;
  99127. /**
  99128. * Removes a floor mesh from being used for teleportation.
  99129. * @param floorMesh the mesh to be removed.
  99130. */
  99131. removeFloorMesh(floorMesh: Mesh): void;
  99132. /**
  99133. * Enables interactions and teleportation using the VR controllers and gaze.
  99134. * @param vrTeleportationOptions options to modify teleportation behavior.
  99135. */
  99136. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99137. private _onNewGamepadConnected;
  99138. private _tryEnableInteractionOnController;
  99139. private _onNewGamepadDisconnected;
  99140. private _enableInteractionOnController;
  99141. private _checkTeleportWithRay;
  99142. private _checkRotate;
  99143. private _checkTeleportBackwards;
  99144. private _enableTeleportationOnController;
  99145. private _createTeleportationCircles;
  99146. private _displayTeleportationTarget;
  99147. private _hideTeleportationTarget;
  99148. private _rotateCamera;
  99149. private _moveTeleportationSelectorTo;
  99150. private _workingVector;
  99151. private _workingQuaternion;
  99152. private _workingMatrix;
  99153. /**
  99154. * Teleports the users feet to the desired location
  99155. * @param location The location where the user's feet should be placed
  99156. */
  99157. teleportCamera(location: Vector3): void;
  99158. private _convertNormalToDirectionOfRay;
  99159. private _castRayAndSelectObject;
  99160. private _notifySelectedMeshUnselected;
  99161. /**
  99162. * Sets the color of the laser ray from the vr controllers.
  99163. * @param color new color for the ray.
  99164. */
  99165. changeLaserColor(color: Color3): void;
  99166. /**
  99167. * Sets the color of the ray from the vr headsets gaze.
  99168. * @param color new color for the ray.
  99169. */
  99170. changeGazeColor(color: Color3): void;
  99171. /**
  99172. * Exits VR and disposes of the vr experience helper
  99173. */
  99174. dispose(): void;
  99175. /**
  99176. * Gets the name of the VRExperienceHelper class
  99177. * @returns "VRExperienceHelper"
  99178. */
  99179. getClassName(): string;
  99180. }
  99181. }
  99182. declare module BABYLON {
  99183. /**
  99184. * Manages an XRSession
  99185. * @see https://doc.babylonjs.com/how_to/webxr
  99186. */
  99187. export class WebXRSessionManager implements IDisposable {
  99188. private scene;
  99189. /**
  99190. * Fires every time a new xrFrame arrives which can be used to update the camera
  99191. */
  99192. onXRFrameObservable: Observable<any>;
  99193. /**
  99194. * Fires when the xr session is ended either by the device or manually done
  99195. */
  99196. onXRSessionEnded: Observable<any>;
  99197. /** @hidden */
  99198. _xrSession: XRSession;
  99199. /** @hidden */
  99200. _frameOfReference: XRFrameOfReference;
  99201. /** @hidden */
  99202. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99203. /** @hidden */
  99204. _currentXRFrame: Nullable<XRFrame>;
  99205. private _xrNavigator;
  99206. private _xrDevice;
  99207. private _tmpMatrix;
  99208. /**
  99209. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99210. * @param scene The scene which the session should be created for
  99211. */
  99212. constructor(scene: Scene);
  99213. /**
  99214. * Initializes the manager
  99215. * After initialization enterXR can be called to start an XR session
  99216. * @returns Promise which resolves after it is initialized
  99217. */
  99218. initializeAsync(): Promise<void>;
  99219. /**
  99220. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99221. * @param sessionCreationOptions xr options to create the session with
  99222. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99223. * @returns Promise which resolves after it enters XR
  99224. */
  99225. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99226. /**
  99227. * Stops the xrSession and restores the renderloop
  99228. * @returns Promise which resolves after it exits XR
  99229. */
  99230. exitXRAsync(): Promise<void>;
  99231. /**
  99232. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99233. * @param ray ray to cast into the environment
  99234. * @returns Promise which resolves with a collision point in the environment if it exists
  99235. */
  99236. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99237. /**
  99238. * Checks if a session would be supported for the creation options specified
  99239. * @param options creation options to check if they are supported
  99240. * @returns true if supported
  99241. */
  99242. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99243. /**
  99244. * @hidden
  99245. * Converts the render layer of xrSession to a render target
  99246. * @param session session to create render target for
  99247. * @param scene scene the new render target should be created for
  99248. */
  99249. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99250. /**
  99251. * Disposes of the session manager
  99252. */
  99253. dispose(): void;
  99254. }
  99255. }
  99256. declare module BABYLON {
  99257. /**
  99258. * WebXR Camera which holds the views for the xrSession
  99259. * @see https://doc.babylonjs.com/how_to/webxr
  99260. */
  99261. export class WebXRCamera extends FreeCamera {
  99262. private static _TmpMatrix;
  99263. /**
  99264. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99265. * @param name the name of the camera
  99266. * @param scene the scene to add the camera to
  99267. */
  99268. constructor(name: string, scene: Scene);
  99269. private _updateNumberOfRigCameras;
  99270. /** @hidden */
  99271. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99272. /**
  99273. * Updates the cameras position from the current pose information of the XR session
  99274. * @param xrSessionManager the session containing pose information
  99275. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99276. */
  99277. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99278. }
  99279. }
  99280. declare module BABYLON {
  99281. /**
  99282. * States of the webXR experience
  99283. */
  99284. export enum WebXRState {
  99285. /**
  99286. * Transitioning to being in XR mode
  99287. */
  99288. ENTERING_XR = 0,
  99289. /**
  99290. * Transitioning to non XR mode
  99291. */
  99292. EXITING_XR = 1,
  99293. /**
  99294. * In XR mode and presenting
  99295. */
  99296. IN_XR = 2,
  99297. /**
  99298. * Not entered XR mode
  99299. */
  99300. NOT_IN_XR = 3
  99301. }
  99302. /**
  99303. * Helper class used to enable XR
  99304. * @see https://doc.babylonjs.com/how_to/webxr
  99305. */
  99306. export class WebXRExperienceHelper implements IDisposable {
  99307. private scene;
  99308. /**
  99309. * 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
  99310. */
  99311. container: AbstractMesh;
  99312. /**
  99313. * Camera used to render xr content
  99314. */
  99315. camera: WebXRCamera;
  99316. /**
  99317. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  99318. */
  99319. state: WebXRState;
  99320. private _setState;
  99321. private static _TmpVector;
  99322. /**
  99323. * Fires when the state of the experience helper has changed
  99324. */
  99325. onStateChangedObservable: Observable<WebXRState>;
  99326. /** @hidden */
  99327. _sessionManager: WebXRSessionManager;
  99328. private _nonVRCamera;
  99329. private _originalSceneAutoClear;
  99330. private _supported;
  99331. /**
  99332. * Creates the experience helper
  99333. * @param scene the scene to attach the experience helper to
  99334. * @returns a promise for the experience helper
  99335. */
  99336. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  99337. /**
  99338. * Creates a WebXRExperienceHelper
  99339. * @param scene The scene the helper should be created in
  99340. */
  99341. private constructor();
  99342. /**
  99343. * Exits XR mode and returns the scene to its original state
  99344. * @returns promise that resolves after xr mode has exited
  99345. */
  99346. exitXRAsync(): Promise<void>;
  99347. /**
  99348. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  99349. * @param sessionCreationOptions options for the XR session
  99350. * @param frameOfReference frame of reference of the XR session
  99351. * @returns promise that resolves after xr mode has entered
  99352. */
  99353. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  99354. /**
  99355. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99356. * @param ray ray to cast into the environment
  99357. * @returns Promise which resolves with a collision point in the environment if it exists
  99358. */
  99359. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99360. /**
  99361. * Updates the global position of the camera by moving the camera's container
  99362. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  99363. * @param position The desired global position of the camera
  99364. */
  99365. setPositionOfCameraUsingContainer(position: Vector3): void;
  99366. /**
  99367. * Rotates the xr camera by rotating the camera's container around the camera's position
  99368. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  99369. * @param rotation the desired quaternion rotation to apply to the camera
  99370. */
  99371. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  99372. /**
  99373. * Checks if the creation options are supported by the xr session
  99374. * @param options creation options
  99375. * @returns true if supported
  99376. */
  99377. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99378. /**
  99379. * Disposes of the experience helper
  99380. */
  99381. dispose(): void;
  99382. }
  99383. }
  99384. declare module BABYLON {
  99385. /**
  99386. * Button which can be used to enter a different mode of XR
  99387. */
  99388. export class WebXREnterExitUIButton {
  99389. /** button element */
  99390. element: HTMLElement;
  99391. /** XR initialization options for the button */
  99392. initializationOptions: XRSessionCreationOptions;
  99393. /**
  99394. * Creates a WebXREnterExitUIButton
  99395. * @param element button element
  99396. * @param initializationOptions XR initialization options for the button
  99397. */
  99398. constructor(
  99399. /** button element */
  99400. element: HTMLElement,
  99401. /** XR initialization options for the button */
  99402. initializationOptions: XRSessionCreationOptions);
  99403. /**
  99404. * Overwritable function which can be used to update the button's visuals when the state changes
  99405. * @param activeButton the current active button in the UI
  99406. */
  99407. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99408. }
  99409. /**
  99410. * Options to create the webXR UI
  99411. */
  99412. export class WebXREnterExitUIOptions {
  99413. /**
  99414. * Context to enter xr with
  99415. */
  99416. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99417. /**
  99418. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99419. */
  99420. customButtons?: Array<WebXREnterExitUIButton>;
  99421. }
  99422. /**
  99423. * UI to allow the user to enter/exit XR mode
  99424. */
  99425. export class WebXREnterExitUI implements IDisposable {
  99426. private scene;
  99427. private _overlay;
  99428. private _buttons;
  99429. private _activeButton;
  99430. /**
  99431. * Fired every time the active button is changed.
  99432. *
  99433. * When xr is entered via a button that launches xr that button will be the callback parameter
  99434. *
  99435. * When exiting xr the callback parameter will be null)
  99436. */
  99437. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99438. /**
  99439. * Creates UI to allow the user to enter/exit XR mode
  99440. * @param scene the scene to add the ui to
  99441. * @param helper the xr experience helper to enter/exit xr with
  99442. * @param options options to configure the UI
  99443. * @returns the created ui
  99444. */
  99445. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99446. private constructor();
  99447. private _updateButtons;
  99448. /**
  99449. * Disposes of the object
  99450. */
  99451. dispose(): void;
  99452. }
  99453. }
  99454. declare module BABYLON {
  99455. /**
  99456. * Represents an XR input
  99457. */
  99458. export class WebXRController {
  99459. /**
  99460. * 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
  99461. */
  99462. grip?: AbstractMesh;
  99463. /**
  99464. * Pointer which can be used to select objects or attach a visible laser to
  99465. */
  99466. pointer: AbstractMesh;
  99467. /**
  99468. * Creates the controller
  99469. * @see https://doc.babylonjs.com/how_to/webxr
  99470. * @param scene the scene which the controller should be associated to
  99471. */
  99472. constructor(scene: Scene);
  99473. /**
  99474. * Disposes of the object
  99475. */
  99476. dispose(): void;
  99477. }
  99478. /**
  99479. * XR input used to track XR inputs such as controllers/rays
  99480. */
  99481. export class WebXRInput implements IDisposable {
  99482. private helper;
  99483. /**
  99484. * XR controllers being tracked
  99485. */
  99486. controllers: Array<WebXRController>;
  99487. private _tmpMatrix;
  99488. private _frameObserver;
  99489. /**
  99490. * Initializes the WebXRInput
  99491. * @param helper experience helper which the input should be created for
  99492. */
  99493. constructor(helper: WebXRExperienceHelper);
  99494. /**
  99495. * Disposes of the object
  99496. */
  99497. dispose(): void;
  99498. }
  99499. }
  99500. declare module BABYLON {
  99501. /**
  99502. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99503. */
  99504. export class WebXRManagedOutputCanvas implements IDisposable {
  99505. private _canvas;
  99506. /**
  99507. * xrpresent context of the canvas which can be used to display/mirror xr content
  99508. */
  99509. canvasContext: Nullable<WebGLRenderingContext>;
  99510. /**
  99511. * Initializes the canvas to be added/removed upon entering/exiting xr
  99512. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99513. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99514. */
  99515. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99516. /**
  99517. * Disposes of the object
  99518. */
  99519. dispose(): void;
  99520. private _setManagedOutputCanvas;
  99521. private _addCanvas;
  99522. private _removeCanvas;
  99523. }
  99524. }
  99525. declare module BABYLON {
  99526. /**
  99527. * Contains an array of blocks representing the octree
  99528. */
  99529. export interface IOctreeContainer<T> {
  99530. /**
  99531. * Blocks within the octree
  99532. */
  99533. blocks: Array<OctreeBlock<T>>;
  99534. }
  99535. /**
  99536. * Class used to store a cell in an octree
  99537. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99538. */
  99539. export class OctreeBlock<T> {
  99540. /**
  99541. * Gets the content of the current block
  99542. */
  99543. entries: T[];
  99544. /**
  99545. * Gets the list of block children
  99546. */
  99547. blocks: Array<OctreeBlock<T>>;
  99548. private _depth;
  99549. private _maxDepth;
  99550. private _capacity;
  99551. private _minPoint;
  99552. private _maxPoint;
  99553. private _boundingVectors;
  99554. private _creationFunc;
  99555. /**
  99556. * Creates a new block
  99557. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99558. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99559. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99560. * @param depth defines the current depth of this block in the octree
  99561. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99562. * @param creationFunc defines a callback to call when an element is added to the block
  99563. */
  99564. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99565. /**
  99566. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99567. */
  99568. readonly capacity: number;
  99569. /**
  99570. * Gets the minimum vector (in world space) of the block's bounding box
  99571. */
  99572. readonly minPoint: Vector3;
  99573. /**
  99574. * Gets the maximum vector (in world space) of the block's bounding box
  99575. */
  99576. readonly maxPoint: Vector3;
  99577. /**
  99578. * Add a new element to this block
  99579. * @param entry defines the element to add
  99580. */
  99581. addEntry(entry: T): void;
  99582. /**
  99583. * Remove an element from this block
  99584. * @param entry defines the element to remove
  99585. */
  99586. removeEntry(entry: T): void;
  99587. /**
  99588. * Add an array of elements to this block
  99589. * @param entries defines the array of elements to add
  99590. */
  99591. addEntries(entries: T[]): void;
  99592. /**
  99593. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99594. * @param frustumPlanes defines the frustum planes to test
  99595. * @param selection defines the array to store current content if selection is positive
  99596. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99597. */
  99598. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99599. /**
  99600. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99601. * @param sphereCenter defines the bounding sphere center
  99602. * @param sphereRadius defines the bounding sphere radius
  99603. * @param selection defines the array to store current content if selection is positive
  99604. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99605. */
  99606. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99607. /**
  99608. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99609. * @param ray defines the ray to test with
  99610. * @param selection defines the array to store current content if selection is positive
  99611. */
  99612. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99613. /**
  99614. * Subdivide the content into child blocks (this block will then be empty)
  99615. */
  99616. createInnerBlocks(): void;
  99617. /**
  99618. * @hidden
  99619. */
  99620. 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;
  99621. }
  99622. }
  99623. declare module BABYLON {
  99624. /**
  99625. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99626. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99627. */
  99628. export class Octree<T> {
  99629. /** 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.) */
  99630. maxDepth: number;
  99631. /**
  99632. * Blocks within the octree containing objects
  99633. */
  99634. blocks: Array<OctreeBlock<T>>;
  99635. /**
  99636. * Content stored in the octree
  99637. */
  99638. dynamicContent: T[];
  99639. private _maxBlockCapacity;
  99640. private _selectionContent;
  99641. private _creationFunc;
  99642. /**
  99643. * Creates a octree
  99644. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99645. * @param creationFunc function to be used to instatiate the octree
  99646. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99647. * @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.)
  99648. */
  99649. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  99650. /** 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.) */
  99651. maxDepth?: number);
  99652. /**
  99653. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  99654. * @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);
  99655. * @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);
  99656. * @param entries meshes to be added to the octree blocks
  99657. */
  99658. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  99659. /**
  99660. * Adds a mesh to the octree
  99661. * @param entry Mesh to add to the octree
  99662. */
  99663. addMesh(entry: T): void;
  99664. /**
  99665. * Remove an element from the octree
  99666. * @param entry defines the element to remove
  99667. */
  99668. removeMesh(entry: T): void;
  99669. /**
  99670. * Selects an array of meshes within the frustum
  99671. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  99672. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  99673. * @returns array of meshes within the frustum
  99674. */
  99675. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  99676. /**
  99677. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  99678. * @param sphereCenter defines the bounding sphere center
  99679. * @param sphereRadius defines the bounding sphere radius
  99680. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99681. * @returns an array of objects that intersect the sphere
  99682. */
  99683. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  99684. /**
  99685. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  99686. * @param ray defines the ray to test with
  99687. * @returns array of intersected objects
  99688. */
  99689. intersectsRay(ray: Ray): SmartArray<T>;
  99690. /**
  99691. * Adds a mesh into the octree block if it intersects the block
  99692. */
  99693. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  99694. /**
  99695. * Adds a submesh into the octree block if it intersects the block
  99696. */
  99697. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  99698. }
  99699. }
  99700. declare module BABYLON {
  99701. interface Scene {
  99702. /**
  99703. * @hidden
  99704. * Backing Filed
  99705. */
  99706. _selectionOctree: Octree<AbstractMesh>;
  99707. /**
  99708. * Gets the octree used to boost mesh selection (picking)
  99709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99710. */
  99711. selectionOctree: Octree<AbstractMesh>;
  99712. /**
  99713. * Creates or updates the octree used to boost selection (picking)
  99714. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99715. * @param maxCapacity defines the maximum capacity per leaf
  99716. * @param maxDepth defines the maximum depth of the octree
  99717. * @returns an octree of AbstractMesh
  99718. */
  99719. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  99720. }
  99721. interface AbstractMesh {
  99722. /**
  99723. * @hidden
  99724. * Backing Field
  99725. */
  99726. _submeshesOctree: Octree<SubMesh>;
  99727. /**
  99728. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  99729. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99730. * @param maxCapacity defines the maximum size of each block (64 by default)
  99731. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  99732. * @returns the new octree
  99733. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  99734. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99735. */
  99736. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  99737. }
  99738. /**
  99739. * Defines the octree scene component responsible to manage any octrees
  99740. * in a given scene.
  99741. */
  99742. export class OctreeSceneComponent {
  99743. /**
  99744. * The component name helpfull to identify the component in the list of scene components.
  99745. */
  99746. readonly name: string;
  99747. /**
  99748. * The scene the component belongs to.
  99749. */
  99750. scene: Scene;
  99751. /**
  99752. * Indicates if the meshes have been checked to make sure they are isEnabled()
  99753. */
  99754. readonly checksIsEnabled: boolean;
  99755. /**
  99756. * Creates a new instance of the component for the given scene
  99757. * @param scene Defines the scene to register the component in
  99758. */
  99759. constructor(scene: Scene);
  99760. /**
  99761. * Registers the component in a given scene
  99762. */
  99763. register(): void;
  99764. /**
  99765. * Return the list of active meshes
  99766. * @returns the list of active meshes
  99767. */
  99768. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99769. /**
  99770. * Return the list of active sub meshes
  99771. * @param mesh The mesh to get the candidates sub meshes from
  99772. * @returns the list of active sub meshes
  99773. */
  99774. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99775. private _tempRay;
  99776. /**
  99777. * Return the list of sub meshes intersecting with a given local ray
  99778. * @param mesh defines the mesh to find the submesh for
  99779. * @param localRay defines the ray in local space
  99780. * @returns the list of intersecting sub meshes
  99781. */
  99782. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  99783. /**
  99784. * Return the list of sub meshes colliding with a collider
  99785. * @param mesh defines the mesh to find the submesh for
  99786. * @param collider defines the collider to evaluate the collision against
  99787. * @returns the list of colliding sub meshes
  99788. */
  99789. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  99790. /**
  99791. * Rebuilds the elements related to this component in case of
  99792. * context lost for instance.
  99793. */
  99794. rebuild(): void;
  99795. /**
  99796. * Disposes the component and the associated ressources.
  99797. */
  99798. dispose(): void;
  99799. }
  99800. }
  99801. declare module BABYLON {
  99802. /**
  99803. * Renders a layer on top of an existing scene
  99804. */
  99805. export class UtilityLayerRenderer implements IDisposable {
  99806. /** the original scene that will be rendered on top of */
  99807. originalScene: Scene;
  99808. private _pointerCaptures;
  99809. private _lastPointerEvents;
  99810. private static _DefaultUtilityLayer;
  99811. private static _DefaultKeepDepthUtilityLayer;
  99812. private _sharedGizmoLight;
  99813. /**
  99814. * @hidden
  99815. * Light which used by gizmos to get light shading
  99816. */
  99817. _getSharedGizmoLight(): HemisphericLight;
  99818. /**
  99819. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  99820. */
  99821. pickUtilitySceneFirst: boolean;
  99822. /**
  99823. * 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)
  99824. */
  99825. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  99826. /**
  99827. * 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)
  99828. */
  99829. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  99830. /**
  99831. * The scene that is rendered on top of the original scene
  99832. */
  99833. utilityLayerScene: Scene;
  99834. /**
  99835. * If the utility layer should automatically be rendered on top of existing scene
  99836. */
  99837. shouldRender: boolean;
  99838. /**
  99839. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  99840. */
  99841. onlyCheckPointerDownEvents: boolean;
  99842. /**
  99843. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  99844. */
  99845. processAllEvents: boolean;
  99846. /**
  99847. * Observable raised when the pointer move from the utility layer scene to the main scene
  99848. */
  99849. onPointerOutObservable: Observable<number>;
  99850. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  99851. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  99852. private _afterRenderObserver;
  99853. private _sceneDisposeObserver;
  99854. private _originalPointerObserver;
  99855. /**
  99856. * Instantiates a UtilityLayerRenderer
  99857. * @param originalScene the original scene that will be rendered on top of
  99858. * @param handleEvents boolean indicating if the utility layer should handle events
  99859. */
  99860. constructor(
  99861. /** the original scene that will be rendered on top of */
  99862. originalScene: Scene, handleEvents?: boolean);
  99863. private _notifyObservers;
  99864. /**
  99865. * Renders the utility layers scene on top of the original scene
  99866. */
  99867. render(): void;
  99868. /**
  99869. * Disposes of the renderer
  99870. */
  99871. dispose(): void;
  99872. private _updateCamera;
  99873. }
  99874. }
  99875. declare module BABYLON {
  99876. /**
  99877. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  99878. */
  99879. export class Gizmo implements IDisposable {
  99880. /** The utility layer the gizmo will be added to */
  99881. gizmoLayer: UtilityLayerRenderer;
  99882. /**
  99883. * The root mesh of the gizmo
  99884. */
  99885. _rootMesh: Mesh;
  99886. private _attachedMesh;
  99887. /**
  99888. * Ratio for the scale of the gizmo (Default: 1)
  99889. */
  99890. scaleRatio: number;
  99891. private _tmpMatrix;
  99892. /**
  99893. * If a custom mesh has been set (Default: false)
  99894. */
  99895. protected _customMeshSet: boolean;
  99896. /**
  99897. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  99898. * * When set, interactions will be enabled
  99899. */
  99900. attachedMesh: Nullable<AbstractMesh>;
  99901. /**
  99902. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99903. * @param mesh The mesh to replace the default mesh of the gizmo
  99904. */
  99905. setCustomMesh(mesh: Mesh): void;
  99906. /**
  99907. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  99908. */
  99909. updateGizmoRotationToMatchAttachedMesh: boolean;
  99910. /**
  99911. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  99912. */
  99913. updateGizmoPositionToMatchAttachedMesh: boolean;
  99914. /**
  99915. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  99916. */
  99917. protected _updateScale: boolean;
  99918. protected _interactionsEnabled: boolean;
  99919. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99920. private _beforeRenderObserver;
  99921. /**
  99922. * Creates a gizmo
  99923. * @param gizmoLayer The utility layer the gizmo will be added to
  99924. */
  99925. constructor(
  99926. /** The utility layer the gizmo will be added to */
  99927. gizmoLayer?: UtilityLayerRenderer);
  99928. private _tempVector;
  99929. /**
  99930. * @hidden
  99931. * Updates the gizmo to match the attached mesh's position/rotation
  99932. */
  99933. protected _update(): void;
  99934. /**
  99935. * Disposes of the gizmo
  99936. */
  99937. dispose(): void;
  99938. }
  99939. }
  99940. declare module BABYLON {
  99941. /**
  99942. * Single axis drag gizmo
  99943. */
  99944. export class AxisDragGizmo extends Gizmo {
  99945. /**
  99946. * Drag behavior responsible for the gizmos dragging interactions
  99947. */
  99948. dragBehavior: PointerDragBehavior;
  99949. private _pointerObserver;
  99950. /**
  99951. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99952. */
  99953. snapDistance: number;
  99954. /**
  99955. * Event that fires each time the gizmo snaps to a new location.
  99956. * * snapDistance is the the change in distance
  99957. */
  99958. onSnapObservable: Observable<{
  99959. snapDistance: number;
  99960. }>;
  99961. /** @hidden */
  99962. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  99963. /** @hidden */
  99964. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  99965. /**
  99966. * Creates an AxisDragGizmo
  99967. * @param gizmoLayer The utility layer the gizmo will be added to
  99968. * @param dragAxis The axis which the gizmo will be able to drag on
  99969. * @param color The color of the gizmo
  99970. */
  99971. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99972. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99973. /**
  99974. * Disposes of the gizmo
  99975. */
  99976. dispose(): void;
  99977. }
  99978. }
  99979. declare module BABYLON.Debug {
  99980. /**
  99981. * The Axes viewer will show 3 axes in a specific point in space
  99982. */
  99983. export class AxesViewer {
  99984. private _xAxis;
  99985. private _yAxis;
  99986. private _zAxis;
  99987. private _scaleLinesFactor;
  99988. private _instanced;
  99989. /**
  99990. * Gets the hosting scene
  99991. */
  99992. scene: Scene;
  99993. /**
  99994. * Gets or sets a number used to scale line length
  99995. */
  99996. scaleLines: number;
  99997. /** Gets the node hierarchy used to render x-axis */
  99998. readonly xAxis: TransformNode;
  99999. /** Gets the node hierarchy used to render y-axis */
  100000. readonly yAxis: TransformNode;
  100001. /** Gets the node hierarchy used to render z-axis */
  100002. readonly zAxis: TransformNode;
  100003. /**
  100004. * Creates a new AxesViewer
  100005. * @param scene defines the hosting scene
  100006. * @param scaleLines defines a number used to scale line length (1 by default)
  100007. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100008. * @param xAxis defines the node hierarchy used to render the x-axis
  100009. * @param yAxis defines the node hierarchy used to render the y-axis
  100010. * @param zAxis defines the node hierarchy used to render the z-axis
  100011. */
  100012. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100013. /**
  100014. * Force the viewer to update
  100015. * @param position defines the position of the viewer
  100016. * @param xaxis defines the x axis of the viewer
  100017. * @param yaxis defines the y axis of the viewer
  100018. * @param zaxis defines the z axis of the viewer
  100019. */
  100020. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100021. /**
  100022. * Creates an instance of this axes viewer.
  100023. * @returns a new axes viewer with instanced meshes
  100024. */
  100025. createInstance(): AxesViewer;
  100026. /** Releases resources */
  100027. dispose(): void;
  100028. private static _SetRenderingGroupId;
  100029. }
  100030. }
  100031. declare module BABYLON.Debug {
  100032. /**
  100033. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100034. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100035. */
  100036. export class BoneAxesViewer extends AxesViewer {
  100037. /**
  100038. * Gets or sets the target mesh where to display the axes viewer
  100039. */
  100040. mesh: Nullable<Mesh>;
  100041. /**
  100042. * Gets or sets the target bone where to display the axes viewer
  100043. */
  100044. bone: Nullable<Bone>;
  100045. /** Gets current position */
  100046. pos: Vector3;
  100047. /** Gets direction of X axis */
  100048. xaxis: Vector3;
  100049. /** Gets direction of Y axis */
  100050. yaxis: Vector3;
  100051. /** Gets direction of Z axis */
  100052. zaxis: Vector3;
  100053. /**
  100054. * Creates a new BoneAxesViewer
  100055. * @param scene defines the hosting scene
  100056. * @param bone defines the target bone
  100057. * @param mesh defines the target mesh
  100058. * @param scaleLines defines a scaling factor for line length (1 by default)
  100059. */
  100060. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100061. /**
  100062. * Force the viewer to update
  100063. */
  100064. update(): void;
  100065. /** Releases resources */
  100066. dispose(): void;
  100067. }
  100068. }
  100069. declare module BABYLON {
  100070. /**
  100071. * Interface used to define scene explorer extensibility option
  100072. */
  100073. export interface IExplorerExtensibilityOption {
  100074. /**
  100075. * Define the option label
  100076. */
  100077. label: string;
  100078. /**
  100079. * Defines the action to execute on click
  100080. */
  100081. action: (entity: any) => void;
  100082. }
  100083. /**
  100084. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100085. */
  100086. export interface IExplorerExtensibilityGroup {
  100087. /**
  100088. * Defines a predicate to test if a given type mut be extended
  100089. */
  100090. predicate: (entity: any) => boolean;
  100091. /**
  100092. * Gets the list of options added to a type
  100093. */
  100094. entries: IExplorerExtensibilityOption[];
  100095. }
  100096. /**
  100097. * Interface used to define the options to use to create the Inspector
  100098. */
  100099. export interface IInspectorOptions {
  100100. /**
  100101. * Display in overlay mode (default: false)
  100102. */
  100103. overlay?: boolean;
  100104. /**
  100105. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100106. */
  100107. globalRoot?: HTMLElement;
  100108. /**
  100109. * Display the Scene explorer
  100110. */
  100111. showExplorer?: boolean;
  100112. /**
  100113. * Display the property inspector
  100114. */
  100115. showInspector?: boolean;
  100116. /**
  100117. * Display in embed mode (both panes on the right)
  100118. */
  100119. embedMode?: boolean;
  100120. /**
  100121. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100122. */
  100123. handleResize?: boolean;
  100124. /**
  100125. * Allow the panes to popup (default: true)
  100126. */
  100127. enablePopup?: boolean;
  100128. /**
  100129. * Allow the panes to be closed by users (default: true)
  100130. */
  100131. enableClose?: boolean;
  100132. /**
  100133. * Optional list of extensibility entries
  100134. */
  100135. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100136. /**
  100137. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100138. */
  100139. inspectorURL?: string;
  100140. }
  100141. interface Scene {
  100142. /**
  100143. * @hidden
  100144. * Backing field
  100145. */
  100146. _debugLayer: DebugLayer;
  100147. /**
  100148. * Gets the debug layer (aka Inspector) associated with the scene
  100149. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100150. */
  100151. debugLayer: DebugLayer;
  100152. }
  100153. /**
  100154. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100155. * what is happening in your scene
  100156. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100157. */
  100158. export class DebugLayer {
  100159. /**
  100160. * Define the url to get the inspector script from.
  100161. * By default it uses the babylonjs CDN.
  100162. * @ignoreNaming
  100163. */
  100164. static InspectorURL: string;
  100165. private _scene;
  100166. private BJSINSPECTOR;
  100167. /**
  100168. * Observable triggered when a property is changed through the inspector.
  100169. */
  100170. onPropertyChangedObservable: Observable<{
  100171. object: any;
  100172. property: string;
  100173. value: any;
  100174. initialValue: any;
  100175. }>;
  100176. /**
  100177. * Instantiates a new debug layer.
  100178. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100179. * what is happening in your scene
  100180. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100181. * @param scene Defines the scene to inspect
  100182. */
  100183. constructor(scene: Scene);
  100184. /** Creates the inspector window. */
  100185. private _createInspector;
  100186. /**
  100187. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100188. * @param entity defines the entity to select
  100189. * @param lineContainerTitle defines the specific block to highlight
  100190. */
  100191. select(entity: any, lineContainerTitle?: string): void;
  100192. /** Get the inspector from bundle or global */
  100193. private _getGlobalInspector;
  100194. /**
  100195. * Get if the inspector is visible or not.
  100196. * @returns true if visible otherwise, false
  100197. */
  100198. isVisible(): boolean;
  100199. /**
  100200. * Hide the inspector and close its window.
  100201. */
  100202. hide(): void;
  100203. /**
  100204. * Launch the debugLayer.
  100205. * @param config Define the configuration of the inspector
  100206. * @return a promise fulfilled when the debug layer is visible
  100207. */
  100208. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100209. }
  100210. }
  100211. declare module BABYLON {
  100212. /**
  100213. * Class containing static functions to help procedurally build meshes
  100214. */
  100215. export class BoxBuilder {
  100216. /**
  100217. * Creates a box mesh
  100218. * * The parameter `size` sets the size (float) of each box side (default 1)
  100219. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100220. * * 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)
  100221. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100225. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100226. * @param name defines the name of the mesh
  100227. * @param options defines the options used to create the mesh
  100228. * @param scene defines the hosting scene
  100229. * @returns the box mesh
  100230. */
  100231. static CreateBox(name: string, options: {
  100232. size?: number;
  100233. width?: number;
  100234. height?: number;
  100235. depth?: number;
  100236. faceUV?: Vector4[];
  100237. faceColors?: Color4[];
  100238. sideOrientation?: number;
  100239. frontUVs?: Vector4;
  100240. backUVs?: Vector4;
  100241. wrap?: boolean;
  100242. topBaseAt?: number;
  100243. bottomBaseAt?: number;
  100244. updatable?: boolean;
  100245. }, scene?: Nullable<Scene>): Mesh;
  100246. }
  100247. }
  100248. declare module BABYLON {
  100249. /**
  100250. * Class containing static functions to help procedurally build meshes
  100251. */
  100252. export class SphereBuilder {
  100253. /**
  100254. * Creates a sphere mesh
  100255. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100256. * * 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`)
  100257. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100258. * * 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
  100259. * * 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)
  100260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100263. * @param name defines the name of the mesh
  100264. * @param options defines the options used to create the mesh
  100265. * @param scene defines the hosting scene
  100266. * @returns the sphere mesh
  100267. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100268. */
  100269. static CreateSphere(name: string, options: {
  100270. segments?: number;
  100271. diameter?: number;
  100272. diameterX?: number;
  100273. diameterY?: number;
  100274. diameterZ?: number;
  100275. arc?: number;
  100276. slice?: number;
  100277. sideOrientation?: number;
  100278. frontUVs?: Vector4;
  100279. backUVs?: Vector4;
  100280. updatable?: boolean;
  100281. }, scene: any): Mesh;
  100282. }
  100283. }
  100284. declare module BABYLON.Debug {
  100285. /**
  100286. * Used to show the physics impostor around the specific mesh
  100287. */
  100288. export class PhysicsViewer {
  100289. /** @hidden */
  100290. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100291. /** @hidden */
  100292. protected _meshes: Array<Nullable<AbstractMesh>>;
  100293. /** @hidden */
  100294. protected _scene: Nullable<Scene>;
  100295. /** @hidden */
  100296. protected _numMeshes: number;
  100297. /** @hidden */
  100298. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  100299. private _renderFunction;
  100300. private _utilityLayer;
  100301. private _debugBoxMesh;
  100302. private _debugSphereMesh;
  100303. private _debugCylinderMesh;
  100304. private _debugMaterial;
  100305. private _debugMeshMeshes;
  100306. /**
  100307. * Creates a new PhysicsViewer
  100308. * @param scene defines the hosting scene
  100309. */
  100310. constructor(scene: Scene);
  100311. /** @hidden */
  100312. protected _updateDebugMeshes(): void;
  100313. /**
  100314. * Renders a specified physic impostor
  100315. * @param impostor defines the impostor to render
  100316. * @param targetMesh defines the mesh represented by the impostor
  100317. * @returns the new debug mesh used to render the impostor
  100318. */
  100319. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  100320. /**
  100321. * Hides a specified physic impostor
  100322. * @param impostor defines the impostor to hide
  100323. */
  100324. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  100325. private _getDebugMaterial;
  100326. private _getDebugBoxMesh;
  100327. private _getDebugSphereMesh;
  100328. private _getDebugCylinderMesh;
  100329. private _getDebugMeshMesh;
  100330. private _getDebugMesh;
  100331. /** Releases all resources */
  100332. dispose(): void;
  100333. }
  100334. }
  100335. declare module BABYLON {
  100336. /**
  100337. * Class containing static functions to help procedurally build meshes
  100338. */
  100339. export class LinesBuilder {
  100340. /**
  100341. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  100342. * * 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
  100343. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  100344. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  100345. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  100346. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  100347. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  100348. * * 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
  100349. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  100350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  100352. * @param name defines the name of the new line system
  100353. * @param options defines the options used to create the line system
  100354. * @param scene defines the hosting scene
  100355. * @returns a new line system mesh
  100356. */
  100357. static CreateLineSystem(name: string, options: {
  100358. lines: Vector3[][];
  100359. updatable?: boolean;
  100360. instance?: Nullable<LinesMesh>;
  100361. colors?: Nullable<Color4[][]>;
  100362. useVertexAlpha?: boolean;
  100363. }, scene: Nullable<Scene>): LinesMesh;
  100364. /**
  100365. * Creates a line mesh
  100366. * 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
  100367. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100368. * * The parameter `points` is an array successive Vector3
  100369. * * 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
  100370. * * The optional parameter `colors` is an array of successive Color4, one per line point
  100371. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  100372. * * When updating an instance, remember that only point positions can change, not the number of points
  100373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  100375. * @param name defines the name of the new line system
  100376. * @param options defines the options used to create the line system
  100377. * @param scene defines the hosting scene
  100378. * @returns a new line mesh
  100379. */
  100380. static CreateLines(name: string, options: {
  100381. points: Vector3[];
  100382. updatable?: boolean;
  100383. instance?: Nullable<LinesMesh>;
  100384. colors?: Color4[];
  100385. useVertexAlpha?: boolean;
  100386. }, scene?: Nullable<Scene>): LinesMesh;
  100387. /**
  100388. * Creates a dashed line mesh
  100389. * * 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
  100390. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100391. * * The parameter `points` is an array successive Vector3
  100392. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100393. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100394. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100395. * * 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
  100396. * * When updating an instance, remember that only point positions can change, not the number of points
  100397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100398. * @param name defines the name of the mesh
  100399. * @param options defines the options used to create the mesh
  100400. * @param scene defines the hosting scene
  100401. * @returns the dashed line mesh
  100402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100403. */
  100404. static CreateDashedLines(name: string, options: {
  100405. points: Vector3[];
  100406. dashSize?: number;
  100407. gapSize?: number;
  100408. dashNb?: number;
  100409. updatable?: boolean;
  100410. instance?: LinesMesh;
  100411. }, scene?: Nullable<Scene>): LinesMesh;
  100412. }
  100413. }
  100414. declare module BABYLON {
  100415. /**
  100416. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100417. * in order to better appreciate the issue one might have.
  100418. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100419. */
  100420. export class RayHelper {
  100421. /**
  100422. * Defines the ray we are currently tryin to visualize.
  100423. */
  100424. ray: Nullable<Ray>;
  100425. private _renderPoints;
  100426. private _renderLine;
  100427. private _renderFunction;
  100428. private _scene;
  100429. private _updateToMeshFunction;
  100430. private _attachedToMesh;
  100431. private _meshSpaceDirection;
  100432. private _meshSpaceOrigin;
  100433. /**
  100434. * Helper function to create a colored helper in a scene in one line.
  100435. * @param ray Defines the ray we are currently tryin to visualize
  100436. * @param scene Defines the scene the ray is used in
  100437. * @param color Defines the color we want to see the ray in
  100438. * @returns The newly created ray helper.
  100439. */
  100440. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100441. /**
  100442. * Instantiate a new ray helper.
  100443. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100444. * in order to better appreciate the issue one might have.
  100445. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100446. * @param ray Defines the ray we are currently tryin to visualize
  100447. */
  100448. constructor(ray: Ray);
  100449. /**
  100450. * Shows the ray we are willing to debug.
  100451. * @param scene Defines the scene the ray needs to be rendered in
  100452. * @param color Defines the color the ray needs to be rendered in
  100453. */
  100454. show(scene: Scene, color?: Color3): void;
  100455. /**
  100456. * Hides the ray we are debugging.
  100457. */
  100458. hide(): void;
  100459. private _render;
  100460. /**
  100461. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100462. * @param mesh Defines the mesh we want the helper attached to
  100463. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100464. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100465. * @param length Defines the length of the ray
  100466. */
  100467. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100468. /**
  100469. * Detach the ray helper from the mesh it has previously been attached to.
  100470. */
  100471. detachFromMesh(): void;
  100472. private _updateToMesh;
  100473. /**
  100474. * Dispose the helper and release its associated resources.
  100475. */
  100476. dispose(): void;
  100477. }
  100478. }
  100479. declare module BABYLON.Debug {
  100480. /**
  100481. * Class used to render a debug view of a given skeleton
  100482. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100483. */
  100484. export class SkeletonViewer {
  100485. /** defines the skeleton to render */
  100486. skeleton: Skeleton;
  100487. /** defines the mesh attached to the skeleton */
  100488. mesh: AbstractMesh;
  100489. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100490. autoUpdateBonesMatrices: boolean;
  100491. /** defines the rendering group id to use with the viewer */
  100492. renderingGroupId: number;
  100493. /** Gets or sets the color used to render the skeleton */
  100494. color: Color3;
  100495. private _scene;
  100496. private _debugLines;
  100497. private _debugMesh;
  100498. private _isEnabled;
  100499. private _renderFunction;
  100500. private _utilityLayer;
  100501. /**
  100502. * Returns the mesh used to render the bones
  100503. */
  100504. readonly debugMesh: Nullable<LinesMesh>;
  100505. /**
  100506. * Creates a new SkeletonViewer
  100507. * @param skeleton defines the skeleton to render
  100508. * @param mesh defines the mesh attached to the skeleton
  100509. * @param scene defines the hosting scene
  100510. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100511. * @param renderingGroupId defines the rendering group id to use with the viewer
  100512. */
  100513. constructor(
  100514. /** defines the skeleton to render */
  100515. skeleton: Skeleton,
  100516. /** defines the mesh attached to the skeleton */
  100517. mesh: AbstractMesh, scene: Scene,
  100518. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100519. autoUpdateBonesMatrices?: boolean,
  100520. /** defines the rendering group id to use with the viewer */
  100521. renderingGroupId?: number);
  100522. /** Gets or sets a boolean indicating if the viewer is enabled */
  100523. isEnabled: boolean;
  100524. private _getBonePosition;
  100525. private _getLinesForBonesWithLength;
  100526. private _getLinesForBonesNoLength;
  100527. /** Update the viewer to sync with current skeleton state */
  100528. update(): void;
  100529. /** Release associated resources */
  100530. dispose(): void;
  100531. }
  100532. }
  100533. declare module BABYLON {
  100534. /**
  100535. * Options to create the null engine
  100536. */
  100537. export class NullEngineOptions {
  100538. /**
  100539. * Render width (Default: 512)
  100540. */
  100541. renderWidth: number;
  100542. /**
  100543. * Render height (Default: 256)
  100544. */
  100545. renderHeight: number;
  100546. /**
  100547. * Texture size (Default: 512)
  100548. */
  100549. textureSize: number;
  100550. /**
  100551. * If delta time between frames should be constant
  100552. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100553. */
  100554. deterministicLockstep: boolean;
  100555. /**
  100556. * Maximum about of steps between frames (Default: 4)
  100557. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100558. */
  100559. lockstepMaxSteps: number;
  100560. }
  100561. /**
  100562. * The null engine class provides support for headless version of babylon.js.
  100563. * This can be used in server side scenario or for testing purposes
  100564. */
  100565. export class NullEngine extends Engine {
  100566. private _options;
  100567. /**
  100568. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100569. */
  100570. isDeterministicLockStep(): boolean;
  100571. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100572. getLockstepMaxSteps(): number;
  100573. /**
  100574. * Sets hardware scaling, used to save performance if needed
  100575. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100576. */
  100577. getHardwareScalingLevel(): number;
  100578. constructor(options?: NullEngineOptions);
  100579. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100580. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  100581. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100582. getRenderWidth(useScreen?: boolean): number;
  100583. getRenderHeight(useScreen?: boolean): number;
  100584. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100585. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100586. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  100587. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  100588. bindSamplers(effect: Effect): void;
  100589. enableEffect(effect: Effect): void;
  100590. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100591. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100592. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100593. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100594. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100595. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100596. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100597. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100598. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100599. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100600. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100601. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100602. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100603. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100604. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100605. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100606. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100607. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100608. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100609. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100610. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100611. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100612. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100613. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100614. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100615. bindBuffers(vertexBuffers: {
  100616. [key: string]: VertexBuffer;
  100617. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  100618. wipeCaches(bruteForce?: boolean): void;
  100619. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100620. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100621. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100622. /** @hidden */
  100623. _createTexture(): WebGLTexture;
  100624. /** @hidden */
  100625. _releaseTexture(texture: InternalTexture): void;
  100626. 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;
  100627. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100628. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100629. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100630. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100631. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100632. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100633. areAllEffectsReady(): boolean;
  100634. /**
  100635. * @hidden
  100636. * Get the current error code of the webGL context
  100637. * @returns the error code
  100638. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100639. */
  100640. getError(): number;
  100641. /** @hidden */
  100642. _getUnpackAlignement(): number;
  100643. /** @hidden */
  100644. _unpackFlipY(value: boolean): void;
  100645. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100646. /**
  100647. * Updates a dynamic vertex buffer.
  100648. * @param vertexBuffer the vertex buffer to update
  100649. * @param data the data used to update the vertex buffer
  100650. * @param byteOffset the byte offset of the data (optional)
  100651. * @param byteLength the byte length of the data (optional)
  100652. */
  100653. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  100654. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  100655. /** @hidden */
  100656. _bindTexture(channel: number, texture: InternalTexture): void;
  100657. /** @hidden */
  100658. _releaseBuffer(buffer: WebGLBuffer): boolean;
  100659. releaseEffects(): void;
  100660. displayLoadingUI(): void;
  100661. hideLoadingUI(): void;
  100662. /** @hidden */
  100663. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100664. /** @hidden */
  100665. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100666. /** @hidden */
  100667. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100668. /** @hidden */
  100669. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  100670. }
  100671. }
  100672. declare module BABYLON {
  100673. /** @hidden */
  100674. export class _OcclusionDataStorage {
  100675. /** @hidden */
  100676. occlusionInternalRetryCounter: number;
  100677. /** @hidden */
  100678. isOcclusionQueryInProgress: boolean;
  100679. /** @hidden */
  100680. isOccluded: boolean;
  100681. /** @hidden */
  100682. occlusionRetryCount: number;
  100683. /** @hidden */
  100684. occlusionType: number;
  100685. /** @hidden */
  100686. occlusionQueryAlgorithmType: number;
  100687. }
  100688. interface Engine {
  100689. /**
  100690. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  100691. * @return the new query
  100692. */
  100693. createQuery(): WebGLQuery;
  100694. /**
  100695. * Delete and release a webGL query
  100696. * @param query defines the query to delete
  100697. * @return the current engine
  100698. */
  100699. deleteQuery(query: WebGLQuery): Engine;
  100700. /**
  100701. * Check if a given query has resolved and got its value
  100702. * @param query defines the query to check
  100703. * @returns true if the query got its value
  100704. */
  100705. isQueryResultAvailable(query: WebGLQuery): boolean;
  100706. /**
  100707. * Gets the value of a given query
  100708. * @param query defines the query to check
  100709. * @returns the value of the query
  100710. */
  100711. getQueryResult(query: WebGLQuery): number;
  100712. /**
  100713. * Initiates an occlusion query
  100714. * @param algorithmType defines the algorithm to use
  100715. * @param query defines the query to use
  100716. * @returns the current engine
  100717. * @see http://doc.babylonjs.com/features/occlusionquery
  100718. */
  100719. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  100720. /**
  100721. * Ends an occlusion query
  100722. * @see http://doc.babylonjs.com/features/occlusionquery
  100723. * @param algorithmType defines the algorithm to use
  100724. * @returns the current engine
  100725. */
  100726. endOcclusionQuery(algorithmType: number): Engine;
  100727. /**
  100728. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  100729. * Please note that only one query can be issued at a time
  100730. * @returns a time token used to track the time span
  100731. */
  100732. startTimeQuery(): Nullable<_TimeToken>;
  100733. /**
  100734. * Ends a time query
  100735. * @param token defines the token used to measure the time span
  100736. * @returns the time spent (in ns)
  100737. */
  100738. endTimeQuery(token: _TimeToken): int;
  100739. /** @hidden */
  100740. _currentNonTimestampToken: Nullable<_TimeToken>;
  100741. /** @hidden */
  100742. _createTimeQuery(): WebGLQuery;
  100743. /** @hidden */
  100744. _deleteTimeQuery(query: WebGLQuery): void;
  100745. /** @hidden */
  100746. _getGlAlgorithmType(algorithmType: number): number;
  100747. /** @hidden */
  100748. _getTimeQueryResult(query: WebGLQuery): any;
  100749. /** @hidden */
  100750. _getTimeQueryAvailability(query: WebGLQuery): any;
  100751. }
  100752. interface AbstractMesh {
  100753. /**
  100754. * Backing filed
  100755. * @hidden
  100756. */
  100757. __occlusionDataStorage: _OcclusionDataStorage;
  100758. /**
  100759. * Access property
  100760. * @hidden
  100761. */
  100762. _occlusionDataStorage: _OcclusionDataStorage;
  100763. /**
  100764. * 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.
  100765. * The default value is -1 which means don't break the query and wait till the result
  100766. * @see http://doc.babylonjs.com/features/occlusionquery
  100767. */
  100768. occlusionRetryCount: number;
  100769. /**
  100770. * 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:
  100771. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  100772. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  100773. * * 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.
  100774. * @see http://doc.babylonjs.com/features/occlusionquery
  100775. */
  100776. occlusionType: number;
  100777. /**
  100778. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  100779. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  100780. * * 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.
  100781. * @see http://doc.babylonjs.com/features/occlusionquery
  100782. */
  100783. occlusionQueryAlgorithmType: number;
  100784. /**
  100785. * 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
  100786. * @see http://doc.babylonjs.com/features/occlusionquery
  100787. */
  100788. isOccluded: boolean;
  100789. /**
  100790. * Flag to check the progress status of the query
  100791. * @see http://doc.babylonjs.com/features/occlusionquery
  100792. */
  100793. isOcclusionQueryInProgress: boolean;
  100794. }
  100795. }
  100796. declare module BABYLON {
  100797. /** @hidden */
  100798. export var _forceTransformFeedbackToBundle: boolean;
  100799. interface Engine {
  100800. /**
  100801. * Creates a webGL transform feedback object
  100802. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  100803. * @returns the webGL transform feedback object
  100804. */
  100805. createTransformFeedback(): WebGLTransformFeedback;
  100806. /**
  100807. * Delete a webGL transform feedback object
  100808. * @param value defines the webGL transform feedback object to delete
  100809. */
  100810. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  100811. /**
  100812. * Bind a webGL transform feedback object to the webgl context
  100813. * @param value defines the webGL transform feedback object to bind
  100814. */
  100815. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  100816. /**
  100817. * Begins a transform feedback operation
  100818. * @param usePoints defines if points or triangles must be used
  100819. */
  100820. beginTransformFeedback(usePoints: boolean): void;
  100821. /**
  100822. * Ends a transform feedback operation
  100823. */
  100824. endTransformFeedback(): void;
  100825. /**
  100826. * Specify the varyings to use with transform feedback
  100827. * @param program defines the associated webGL program
  100828. * @param value defines the list of strings representing the varying names
  100829. */
  100830. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  100831. /**
  100832. * Bind a webGL buffer for a transform feedback operation
  100833. * @param value defines the webGL buffer to bind
  100834. */
  100835. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  100836. }
  100837. }
  100838. declare module BABYLON {
  100839. /**
  100840. * Gather the list of clipboard event types as constants.
  100841. */
  100842. export class ClipboardEventTypes {
  100843. /**
  100844. * The clipboard event is fired when a copy command is active (pressed).
  100845. */
  100846. static readonly COPY: number;
  100847. /**
  100848. * The clipboard event is fired when a cut command is active (pressed).
  100849. */
  100850. static readonly CUT: number;
  100851. /**
  100852. * The clipboard event is fired when a paste command is active (pressed).
  100853. */
  100854. static readonly PASTE: number;
  100855. }
  100856. /**
  100857. * This class is used to store clipboard related info for the onClipboardObservable event.
  100858. */
  100859. export class ClipboardInfo {
  100860. /**
  100861. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100862. */
  100863. type: number;
  100864. /**
  100865. * Defines the related dom event
  100866. */
  100867. event: ClipboardEvent;
  100868. /**
  100869. *Creates an instance of ClipboardInfo.
  100870. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  100871. * @param event Defines the related dom event
  100872. */
  100873. constructor(
  100874. /**
  100875. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100876. */
  100877. type: number,
  100878. /**
  100879. * Defines the related dom event
  100880. */
  100881. event: ClipboardEvent);
  100882. /**
  100883. * Get the clipboard event's type from the keycode.
  100884. * @param keyCode Defines the keyCode for the current keyboard event.
  100885. * @return {number}
  100886. */
  100887. static GetTypeFromCharacter(keyCode: number): number;
  100888. }
  100889. }
  100890. declare module BABYLON {
  100891. /**
  100892. * Class used to represent data loading progression
  100893. */
  100894. export class SceneLoaderProgressEvent {
  100895. /** defines if data length to load can be evaluated */
  100896. readonly lengthComputable: boolean;
  100897. /** defines the loaded data length */
  100898. readonly loaded: number;
  100899. /** defines the data length to load */
  100900. readonly total: number;
  100901. /**
  100902. * Create a new progress event
  100903. * @param lengthComputable defines if data length to load can be evaluated
  100904. * @param loaded defines the loaded data length
  100905. * @param total defines the data length to load
  100906. */
  100907. constructor(
  100908. /** defines if data length to load can be evaluated */
  100909. lengthComputable: boolean,
  100910. /** defines the loaded data length */
  100911. loaded: number,
  100912. /** defines the data length to load */
  100913. total: number);
  100914. /**
  100915. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  100916. * @param event defines the source event
  100917. * @returns a new SceneLoaderProgressEvent
  100918. */
  100919. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  100920. }
  100921. /**
  100922. * Interface used by SceneLoader plugins to define supported file extensions
  100923. */
  100924. export interface ISceneLoaderPluginExtensions {
  100925. /**
  100926. * Defines the list of supported extensions
  100927. */
  100928. [extension: string]: {
  100929. isBinary: boolean;
  100930. };
  100931. }
  100932. /**
  100933. * Interface used by SceneLoader plugin factory
  100934. */
  100935. export interface ISceneLoaderPluginFactory {
  100936. /**
  100937. * Defines the name of the factory
  100938. */
  100939. name: string;
  100940. /**
  100941. * Function called to create a new plugin
  100942. * @return the new plugin
  100943. */
  100944. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  100945. /**
  100946. * Boolean indicating if the plugin can direct load specific data
  100947. */
  100948. canDirectLoad?: (data: string) => boolean;
  100949. }
  100950. /**
  100951. * Interface used to define a SceneLoader plugin
  100952. */
  100953. export interface ISceneLoaderPlugin {
  100954. /**
  100955. * The friendly name of this plugin.
  100956. */
  100957. name: string;
  100958. /**
  100959. * The file extensions supported by this plugin.
  100960. */
  100961. extensions: string | ISceneLoaderPluginExtensions;
  100962. /**
  100963. * Import meshes into a scene.
  100964. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100965. * @param scene The scene to import into
  100966. * @param data The data to import
  100967. * @param rootUrl The root url for scene and resources
  100968. * @param meshes The meshes array to import into
  100969. * @param particleSystems The particle systems array to import into
  100970. * @param skeletons The skeletons array to import into
  100971. * @param onError The callback when import fails
  100972. * @returns True if successful or false otherwise
  100973. */
  100974. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  100975. /**
  100976. * Load into a scene.
  100977. * @param scene The scene to load into
  100978. * @param data The data to import
  100979. * @param rootUrl The root url for scene and resources
  100980. * @param onError The callback when import fails
  100981. * @returns true if successful or false otherwise
  100982. */
  100983. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  100984. /**
  100985. * The callback that returns true if the data can be directly loaded.
  100986. */
  100987. canDirectLoad?: (data: string) => boolean;
  100988. /**
  100989. * The callback that allows custom handling of the root url based on the response url.
  100990. */
  100991. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100992. /**
  100993. * Load into an asset container.
  100994. * @param scene The scene to load into
  100995. * @param data The data to import
  100996. * @param rootUrl The root url for scene and resources
  100997. * @param onError The callback when import fails
  100998. * @returns The loaded asset container
  100999. */
  101000. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101001. }
  101002. /**
  101003. * Interface used to define an async SceneLoader plugin
  101004. */
  101005. export interface ISceneLoaderPluginAsync {
  101006. /**
  101007. * The friendly name of this plugin.
  101008. */
  101009. name: string;
  101010. /**
  101011. * The file extensions supported by this plugin.
  101012. */
  101013. extensions: string | ISceneLoaderPluginExtensions;
  101014. /**
  101015. * Import meshes into a scene.
  101016. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101017. * @param scene The scene to import into
  101018. * @param data The data to import
  101019. * @param rootUrl The root url for scene and resources
  101020. * @param onProgress The callback when the load progresses
  101021. * @param fileName Defines the name of the file to load
  101022. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101023. */
  101024. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101025. meshes: AbstractMesh[];
  101026. particleSystems: IParticleSystem[];
  101027. skeletons: Skeleton[];
  101028. animationGroups: AnimationGroup[];
  101029. }>;
  101030. /**
  101031. * Load into a scene.
  101032. * @param scene The scene to load into
  101033. * @param data The data to import
  101034. * @param rootUrl The root url for scene and resources
  101035. * @param onProgress The callback when the load progresses
  101036. * @param fileName Defines the name of the file to load
  101037. * @returns Nothing
  101038. */
  101039. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101040. /**
  101041. * The callback that returns true if the data can be directly loaded.
  101042. */
  101043. canDirectLoad?: (data: string) => boolean;
  101044. /**
  101045. * The callback that allows custom handling of the root url based on the response url.
  101046. */
  101047. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101048. /**
  101049. * Load into an asset container.
  101050. * @param scene The scene to load into
  101051. * @param data The data to import
  101052. * @param rootUrl The root url for scene and resources
  101053. * @param onProgress The callback when the load progresses
  101054. * @param fileName Defines the name of the file to load
  101055. * @returns The loaded asset container
  101056. */
  101057. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101058. }
  101059. /**
  101060. * Class used to load scene from various file formats using registered plugins
  101061. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101062. */
  101063. export class SceneLoader {
  101064. /**
  101065. * No logging while loading
  101066. */
  101067. static readonly NO_LOGGING: number;
  101068. /**
  101069. * Minimal logging while loading
  101070. */
  101071. static readonly MINIMAL_LOGGING: number;
  101072. /**
  101073. * Summary logging while loading
  101074. */
  101075. static readonly SUMMARY_LOGGING: number;
  101076. /**
  101077. * Detailled logging while loading
  101078. */
  101079. static readonly DETAILED_LOGGING: number;
  101080. /**
  101081. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101082. */
  101083. static ForceFullSceneLoadingForIncremental: boolean;
  101084. /**
  101085. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101086. */
  101087. static ShowLoadingScreen: boolean;
  101088. /**
  101089. * Defines the current logging level (while loading the scene)
  101090. * @ignorenaming
  101091. */
  101092. static loggingLevel: number;
  101093. /**
  101094. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101095. */
  101096. static CleanBoneMatrixWeights: boolean;
  101097. /**
  101098. * Event raised when a plugin is used to load a scene
  101099. */
  101100. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101101. private static _registeredPlugins;
  101102. private static _getDefaultPlugin;
  101103. private static _getPluginForExtension;
  101104. private static _getPluginForDirectLoad;
  101105. private static _getPluginForFilename;
  101106. private static _getDirectLoad;
  101107. private static _loadData;
  101108. private static _getFileInfo;
  101109. /**
  101110. * Gets a plugin that can load the given extension
  101111. * @param extension defines the extension to load
  101112. * @returns a plugin or null if none works
  101113. */
  101114. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101115. /**
  101116. * Gets a boolean indicating that the given extension can be loaded
  101117. * @param extension defines the extension to load
  101118. * @returns true if the extension is supported
  101119. */
  101120. static IsPluginForExtensionAvailable(extension: string): boolean;
  101121. /**
  101122. * Adds a new plugin to the list of registered plugins
  101123. * @param plugin defines the plugin to add
  101124. */
  101125. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101126. /**
  101127. * Import meshes into a scene
  101128. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101129. * @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)
  101130. * @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)
  101131. * @param scene the instance of BABYLON.Scene to append to
  101132. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101133. * @param onProgress a callback with a progress event for each file being loaded
  101134. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101135. * @param pluginExtension the extension used to determine the plugin
  101136. * @returns The loaded plugin
  101137. */
  101138. 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>;
  101139. /**
  101140. * Import meshes into a scene
  101141. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101142. * @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)
  101143. * @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)
  101144. * @param scene the instance of BABYLON.Scene to append to
  101145. * @param onProgress a callback with a progress event for each file being loaded
  101146. * @param pluginExtension the extension used to determine the plugin
  101147. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101148. */
  101149. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101150. meshes: AbstractMesh[];
  101151. particleSystems: IParticleSystem[];
  101152. skeletons: Skeleton[];
  101153. animationGroups: AnimationGroup[];
  101154. }>;
  101155. /**
  101156. * Load a scene
  101157. * @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)
  101158. * @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)
  101159. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101160. * @param onSuccess a callback with the scene when import succeeds
  101161. * @param onProgress a callback with a progress event for each file being loaded
  101162. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101163. * @param pluginExtension the extension used to determine the plugin
  101164. * @returns The loaded plugin
  101165. */
  101166. 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>;
  101167. /**
  101168. * Load a scene
  101169. * @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)
  101170. * @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)
  101171. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101172. * @param onProgress a callback with a progress event for each file being loaded
  101173. * @param pluginExtension the extension used to determine the plugin
  101174. * @returns The loaded scene
  101175. */
  101176. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101177. /**
  101178. * Append a scene
  101179. * @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)
  101180. * @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)
  101181. * @param scene is the instance of BABYLON.Scene to append to
  101182. * @param onSuccess a callback with the scene when import succeeds
  101183. * @param onProgress a callback with a progress event for each file being loaded
  101184. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101185. * @param pluginExtension the extension used to determine the plugin
  101186. * @returns The loaded plugin
  101187. */
  101188. 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>;
  101189. /**
  101190. * Append a scene
  101191. * @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)
  101192. * @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)
  101193. * @param scene is the instance of BABYLON.Scene to append to
  101194. * @param onProgress a callback with a progress event for each file being loaded
  101195. * @param pluginExtension the extension used to determine the plugin
  101196. * @returns The given scene
  101197. */
  101198. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101199. /**
  101200. * Load a scene into an asset container
  101201. * @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)
  101202. * @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)
  101203. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  101204. * @param onSuccess a callback with the scene when import succeeds
  101205. * @param onProgress a callback with a progress event for each file being loaded
  101206. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101207. * @param pluginExtension the extension used to determine the plugin
  101208. * @returns The loaded plugin
  101209. */
  101210. 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>;
  101211. /**
  101212. * Load a scene into an asset container
  101213. * @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)
  101214. * @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)
  101215. * @param scene is the instance of Scene to append to
  101216. * @param onProgress a callback with a progress event for each file being loaded
  101217. * @param pluginExtension the extension used to determine the plugin
  101218. * @returns The loaded asset container
  101219. */
  101220. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  101221. }
  101222. }
  101223. declare module BABYLON {
  101224. /**
  101225. * Google Daydream controller
  101226. */
  101227. export class DaydreamController extends WebVRController {
  101228. /**
  101229. * Base Url for the controller model.
  101230. */
  101231. static MODEL_BASE_URL: string;
  101232. /**
  101233. * File name for the controller model.
  101234. */
  101235. static MODEL_FILENAME: string;
  101236. /**
  101237. * Gamepad Id prefix used to identify Daydream Controller.
  101238. */
  101239. static readonly GAMEPAD_ID_PREFIX: string;
  101240. /**
  101241. * Creates a new DaydreamController from a gamepad
  101242. * @param vrGamepad the gamepad that the controller should be created from
  101243. */
  101244. constructor(vrGamepad: any);
  101245. /**
  101246. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101247. * @param scene scene in which to add meshes
  101248. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101249. */
  101250. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101251. /**
  101252. * Called once for each button that changed state since the last frame
  101253. * @param buttonIdx Which button index changed
  101254. * @param state New state of the button
  101255. * @param changes Which properties on the state changed since last frame
  101256. */
  101257. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101258. }
  101259. }
  101260. declare module BABYLON {
  101261. /**
  101262. * Gear VR Controller
  101263. */
  101264. export class GearVRController extends WebVRController {
  101265. /**
  101266. * Base Url for the controller model.
  101267. */
  101268. static MODEL_BASE_URL: string;
  101269. /**
  101270. * File name for the controller model.
  101271. */
  101272. static MODEL_FILENAME: string;
  101273. /**
  101274. * Gamepad Id prefix used to identify this controller.
  101275. */
  101276. static readonly GAMEPAD_ID_PREFIX: string;
  101277. private readonly _buttonIndexToObservableNameMap;
  101278. /**
  101279. * Creates a new GearVRController from a gamepad
  101280. * @param vrGamepad the gamepad that the controller should be created from
  101281. */
  101282. constructor(vrGamepad: any);
  101283. /**
  101284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101285. * @param scene scene in which to add meshes
  101286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101287. */
  101288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101289. /**
  101290. * Called once for each button that changed state since the last frame
  101291. * @param buttonIdx Which button index changed
  101292. * @param state New state of the button
  101293. * @param changes Which properties on the state changed since last frame
  101294. */
  101295. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101296. }
  101297. }
  101298. declare module BABYLON {
  101299. /**
  101300. * Generic Controller
  101301. */
  101302. export class GenericController extends WebVRController {
  101303. /**
  101304. * Base Url for the controller model.
  101305. */
  101306. static readonly MODEL_BASE_URL: string;
  101307. /**
  101308. * File name for the controller model.
  101309. */
  101310. static readonly MODEL_FILENAME: string;
  101311. /**
  101312. * Creates a new GenericController from a gamepad
  101313. * @param vrGamepad the gamepad that the controller should be created from
  101314. */
  101315. constructor(vrGamepad: any);
  101316. /**
  101317. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101318. * @param scene scene in which to add meshes
  101319. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101320. */
  101321. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101322. /**
  101323. * Called once for each button that changed state since the last frame
  101324. * @param buttonIdx Which button index changed
  101325. * @param state New state of the button
  101326. * @param changes Which properties on the state changed since last frame
  101327. */
  101328. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101329. }
  101330. }
  101331. declare module BABYLON {
  101332. /**
  101333. * Oculus Touch Controller
  101334. */
  101335. export class OculusTouchController extends WebVRController {
  101336. /**
  101337. * Base Url for the controller model.
  101338. */
  101339. static MODEL_BASE_URL: string;
  101340. /**
  101341. * File name for the left controller model.
  101342. */
  101343. static MODEL_LEFT_FILENAME: string;
  101344. /**
  101345. * File name for the right controller model.
  101346. */
  101347. static MODEL_RIGHT_FILENAME: string;
  101348. /**
  101349. * Fired when the secondary trigger on this controller is modified
  101350. */
  101351. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101352. /**
  101353. * Fired when the thumb rest on this controller is modified
  101354. */
  101355. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  101356. /**
  101357. * Creates a new OculusTouchController from a gamepad
  101358. * @param vrGamepad the gamepad that the controller should be created from
  101359. */
  101360. constructor(vrGamepad: any);
  101361. /**
  101362. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101363. * @param scene scene in which to add meshes
  101364. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101365. */
  101366. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101367. /**
  101368. * Fired when the A button on this controller is modified
  101369. */
  101370. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101371. /**
  101372. * Fired when the B button on this controller is modified
  101373. */
  101374. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101375. /**
  101376. * Fired when the X button on this controller is modified
  101377. */
  101378. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101379. /**
  101380. * Fired when the Y button on this controller is modified
  101381. */
  101382. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101383. /**
  101384. * Called once for each button that changed state since the last frame
  101385. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101386. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101387. * 2) secondary trigger (same)
  101388. * 3) A (right) X (left), touch, pressed = value
  101389. * 4) B / Y
  101390. * 5) thumb rest
  101391. * @param buttonIdx Which button index changed
  101392. * @param state New state of the button
  101393. * @param changes Which properties on the state changed since last frame
  101394. */
  101395. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101396. }
  101397. }
  101398. declare module BABYLON {
  101399. /**
  101400. * Vive Controller
  101401. */
  101402. export class ViveController extends WebVRController {
  101403. /**
  101404. * Base Url for the controller model.
  101405. */
  101406. static MODEL_BASE_URL: string;
  101407. /**
  101408. * File name for the controller model.
  101409. */
  101410. static MODEL_FILENAME: string;
  101411. /**
  101412. * Creates a new ViveController from a gamepad
  101413. * @param vrGamepad the gamepad that the controller should be created from
  101414. */
  101415. constructor(vrGamepad: any);
  101416. /**
  101417. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101418. * @param scene scene in which to add meshes
  101419. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101420. */
  101421. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101422. /**
  101423. * Fired when the left button on this controller is modified
  101424. */
  101425. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101426. /**
  101427. * Fired when the right button on this controller is modified
  101428. */
  101429. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101430. /**
  101431. * Fired when the menu button on this controller is modified
  101432. */
  101433. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101434. /**
  101435. * Called once for each button that changed state since the last frame
  101436. * Vive mapping:
  101437. * 0: touchpad
  101438. * 1: trigger
  101439. * 2: left AND right buttons
  101440. * 3: menu button
  101441. * @param buttonIdx Which button index changed
  101442. * @param state New state of the button
  101443. * @param changes Which properties on the state changed since last frame
  101444. */
  101445. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101446. }
  101447. }
  101448. declare module BABYLON {
  101449. /**
  101450. * Defines the WindowsMotionController object that the state of the windows motion controller
  101451. */
  101452. export class WindowsMotionController extends WebVRController {
  101453. /**
  101454. * The base url used to load the left and right controller models
  101455. */
  101456. static MODEL_BASE_URL: string;
  101457. /**
  101458. * The name of the left controller model file
  101459. */
  101460. static MODEL_LEFT_FILENAME: string;
  101461. /**
  101462. * The name of the right controller model file
  101463. */
  101464. static MODEL_RIGHT_FILENAME: string;
  101465. /**
  101466. * The controller name prefix for this controller type
  101467. */
  101468. static readonly GAMEPAD_ID_PREFIX: string;
  101469. /**
  101470. * The controller id pattern for this controller type
  101471. */
  101472. private static readonly GAMEPAD_ID_PATTERN;
  101473. private _loadedMeshInfo;
  101474. private readonly _mapping;
  101475. /**
  101476. * Fired when the trackpad on this controller is clicked
  101477. */
  101478. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101479. /**
  101480. * Fired when the trackpad on this controller is modified
  101481. */
  101482. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101483. /**
  101484. * The current x and y values of this controller's trackpad
  101485. */
  101486. trackpad: StickValues;
  101487. /**
  101488. * Creates a new WindowsMotionController from a gamepad
  101489. * @param vrGamepad the gamepad that the controller should be created from
  101490. */
  101491. constructor(vrGamepad: any);
  101492. /**
  101493. * Fired when the trigger on this controller is modified
  101494. */
  101495. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101496. /**
  101497. * Fired when the menu button on this controller is modified
  101498. */
  101499. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101500. /**
  101501. * Fired when the grip button on this controller is modified
  101502. */
  101503. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101504. /**
  101505. * Fired when the thumbstick button on this controller is modified
  101506. */
  101507. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101508. /**
  101509. * Fired when the touchpad button on this controller is modified
  101510. */
  101511. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101512. /**
  101513. * Fired when the touchpad values on this controller are modified
  101514. */
  101515. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  101516. private _updateTrackpad;
  101517. /**
  101518. * Called once per frame by the engine.
  101519. */
  101520. update(): void;
  101521. /**
  101522. * Called once for each button that changed state since the last frame
  101523. * @param buttonIdx Which button index changed
  101524. * @param state New state of the button
  101525. * @param changes Which properties on the state changed since last frame
  101526. */
  101527. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101528. /**
  101529. * Moves the buttons on the controller mesh based on their current state
  101530. * @param buttonName the name of the button to move
  101531. * @param buttonValue the value of the button which determines the buttons new position
  101532. */
  101533. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  101534. /**
  101535. * Moves the axis on the controller mesh based on its current state
  101536. * @param axis the index of the axis
  101537. * @param axisValue the value of the axis which determines the meshes new position
  101538. * @hidden
  101539. */
  101540. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  101541. /**
  101542. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101543. * @param scene scene in which to add meshes
  101544. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101545. */
  101546. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  101547. /**
  101548. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  101549. * can be transformed by button presses and axes values, based on this._mapping.
  101550. *
  101551. * @param scene scene in which the meshes exist
  101552. * @param meshes list of meshes that make up the controller model to process
  101553. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  101554. */
  101555. private processModel;
  101556. private createMeshInfo;
  101557. /**
  101558. * Gets the ray of the controller in the direction the controller is pointing
  101559. * @param length the length the resulting ray should be
  101560. * @returns a ray in the direction the controller is pointing
  101561. */
  101562. getForwardRay(length?: number): Ray;
  101563. /**
  101564. * Disposes of the controller
  101565. */
  101566. dispose(): void;
  101567. }
  101568. }
  101569. declare module BABYLON {
  101570. /**
  101571. * Single axis scale gizmo
  101572. */
  101573. export class AxisScaleGizmo extends Gizmo {
  101574. private _coloredMaterial;
  101575. /**
  101576. * Drag behavior responsible for the gizmos dragging interactions
  101577. */
  101578. dragBehavior: PointerDragBehavior;
  101579. private _pointerObserver;
  101580. /**
  101581. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101582. */
  101583. snapDistance: number;
  101584. /**
  101585. * Event that fires each time the gizmo snaps to a new location.
  101586. * * snapDistance is the the change in distance
  101587. */
  101588. onSnapObservable: Observable<{
  101589. snapDistance: number;
  101590. }>;
  101591. /**
  101592. * If the scaling operation should be done on all axis (default: false)
  101593. */
  101594. uniformScaling: boolean;
  101595. /**
  101596. * Creates an AxisScaleGizmo
  101597. * @param gizmoLayer The utility layer the gizmo will be added to
  101598. * @param dragAxis The axis which the gizmo will be able to scale on
  101599. * @param color The color of the gizmo
  101600. */
  101601. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101602. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101603. /**
  101604. * Disposes of the gizmo
  101605. */
  101606. dispose(): void;
  101607. /**
  101608. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  101609. * @param mesh The mesh to replace the default mesh of the gizmo
  101610. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  101611. */
  101612. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  101613. }
  101614. }
  101615. declare module BABYLON {
  101616. /**
  101617. * Bounding box gizmo
  101618. */
  101619. export class BoundingBoxGizmo extends Gizmo {
  101620. private _lineBoundingBox;
  101621. private _rotateSpheresParent;
  101622. private _scaleBoxesParent;
  101623. private _boundingDimensions;
  101624. private _renderObserver;
  101625. private _pointerObserver;
  101626. private _scaleDragSpeed;
  101627. private _tmpQuaternion;
  101628. private _tmpVector;
  101629. private _tmpRotationMatrix;
  101630. /**
  101631. * 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)
  101632. */
  101633. ignoreChildren: boolean;
  101634. /**
  101635. * 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)
  101636. */
  101637. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  101638. /**
  101639. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  101640. */
  101641. rotationSphereSize: number;
  101642. /**
  101643. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  101644. */
  101645. scaleBoxSize: number;
  101646. /**
  101647. * 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)
  101648. */
  101649. fixedDragMeshScreenSize: boolean;
  101650. /**
  101651. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  101652. */
  101653. fixedDragMeshScreenSizeDistanceFactor: number;
  101654. /**
  101655. * Fired when a rotation sphere or scale box is dragged
  101656. */
  101657. onDragStartObservable: Observable<{}>;
  101658. /**
  101659. * Fired when a scale box is dragged
  101660. */
  101661. onScaleBoxDragObservable: Observable<{}>;
  101662. /**
  101663. * Fired when a scale box drag is ended
  101664. */
  101665. onScaleBoxDragEndObservable: Observable<{}>;
  101666. /**
  101667. * Fired when a rotation sphere is dragged
  101668. */
  101669. onRotationSphereDragObservable: Observable<{}>;
  101670. /**
  101671. * Fired when a rotation sphere drag is ended
  101672. */
  101673. onRotationSphereDragEndObservable: Observable<{}>;
  101674. /**
  101675. * 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)
  101676. */
  101677. scalePivot: Nullable<Vector3>;
  101678. private _anchorMesh;
  101679. private _existingMeshScale;
  101680. private _dragMesh;
  101681. private pointerDragBehavior;
  101682. private coloredMaterial;
  101683. private hoverColoredMaterial;
  101684. /**
  101685. * Sets the color of the bounding box gizmo
  101686. * @param color the color to set
  101687. */
  101688. setColor(color: Color3): void;
  101689. /**
  101690. * Creates an BoundingBoxGizmo
  101691. * @param gizmoLayer The utility layer the gizmo will be added to
  101692. * @param color The color of the gizmo
  101693. */
  101694. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101695. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101696. private _selectNode;
  101697. /**
  101698. * Updates the bounding box information for the Gizmo
  101699. */
  101700. updateBoundingBox(): void;
  101701. private _updateRotationSpheres;
  101702. private _updateScaleBoxes;
  101703. /**
  101704. * Enables rotation on the specified axis and disables rotation on the others
  101705. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  101706. */
  101707. setEnabledRotationAxis(axis: string): void;
  101708. /**
  101709. * Enables/disables scaling
  101710. * @param enable if scaling should be enabled
  101711. */
  101712. setEnabledScaling(enable: boolean): void;
  101713. private _updateDummy;
  101714. /**
  101715. * Enables a pointer drag behavior on the bounding box of the gizmo
  101716. */
  101717. enableDragBehavior(): void;
  101718. /**
  101719. * Disposes of the gizmo
  101720. */
  101721. dispose(): void;
  101722. /**
  101723. * 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)
  101724. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  101725. * @returns the bounding box mesh with the passed in mesh as a child
  101726. */
  101727. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  101728. /**
  101729. * CustomMeshes are not supported by this gizmo
  101730. * @param mesh The mesh to replace the default mesh of the gizmo
  101731. */
  101732. setCustomMesh(mesh: Mesh): void;
  101733. }
  101734. }
  101735. declare module BABYLON {
  101736. /**
  101737. * Single plane rotation gizmo
  101738. */
  101739. export class PlaneRotationGizmo extends Gizmo {
  101740. /**
  101741. * Drag behavior responsible for the gizmos dragging interactions
  101742. */
  101743. dragBehavior: PointerDragBehavior;
  101744. private _pointerObserver;
  101745. /**
  101746. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  101747. */
  101748. snapDistance: number;
  101749. /**
  101750. * Event that fires each time the gizmo snaps to a new location.
  101751. * * snapDistance is the the change in distance
  101752. */
  101753. onSnapObservable: Observable<{
  101754. snapDistance: number;
  101755. }>;
  101756. /**
  101757. * Creates a PlaneRotationGizmo
  101758. * @param gizmoLayer The utility layer the gizmo will be added to
  101759. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  101760. * @param color The color of the gizmo
  101761. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101762. */
  101763. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101764. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101765. /**
  101766. * Disposes of the gizmo
  101767. */
  101768. dispose(): void;
  101769. }
  101770. }
  101771. declare module BABYLON {
  101772. /**
  101773. * Gizmo that enables rotating a mesh along 3 axis
  101774. */
  101775. export class RotationGizmo extends Gizmo {
  101776. /**
  101777. * Internal gizmo used for interactions on the x axis
  101778. */
  101779. xGizmo: PlaneRotationGizmo;
  101780. /**
  101781. * Internal gizmo used for interactions on the y axis
  101782. */
  101783. yGizmo: PlaneRotationGizmo;
  101784. /**
  101785. * Internal gizmo used for interactions on the z axis
  101786. */
  101787. zGizmo: PlaneRotationGizmo;
  101788. /** Fires an event when any of it's sub gizmos are dragged */
  101789. onDragStartObservable: Observable<{}>;
  101790. /** Fires an event when any of it's sub gizmos are released from dragging */
  101791. onDragEndObservable: Observable<{}>;
  101792. attachedMesh: Nullable<AbstractMesh>;
  101793. /**
  101794. * Creates a RotationGizmo
  101795. * @param gizmoLayer The utility layer the gizmo will be added to
  101796. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101797. */
  101798. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101799. updateGizmoRotationToMatchAttachedMesh: boolean;
  101800. /**
  101801. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101802. */
  101803. snapDistance: number;
  101804. /**
  101805. * Ratio for the scale of the gizmo (Default: 1)
  101806. */
  101807. scaleRatio: number;
  101808. /**
  101809. * Disposes of the gizmo
  101810. */
  101811. dispose(): void;
  101812. /**
  101813. * CustomMeshes are not supported by this gizmo
  101814. * @param mesh The mesh to replace the default mesh of the gizmo
  101815. */
  101816. setCustomMesh(mesh: Mesh): void;
  101817. }
  101818. }
  101819. declare module BABYLON {
  101820. /**
  101821. * Gizmo that enables dragging a mesh along 3 axis
  101822. */
  101823. export class PositionGizmo extends Gizmo {
  101824. /**
  101825. * Internal gizmo used for interactions on the x axis
  101826. */
  101827. xGizmo: AxisDragGizmo;
  101828. /**
  101829. * Internal gizmo used for interactions on the y axis
  101830. */
  101831. yGizmo: AxisDragGizmo;
  101832. /**
  101833. * Internal gizmo used for interactions on the z axis
  101834. */
  101835. zGizmo: AxisDragGizmo;
  101836. /** Fires an event when any of it's sub gizmos are dragged */
  101837. onDragStartObservable: Observable<{}>;
  101838. /** Fires an event when any of it's sub gizmos are released from dragging */
  101839. onDragEndObservable: Observable<{}>;
  101840. attachedMesh: Nullable<AbstractMesh>;
  101841. /**
  101842. * Creates a PositionGizmo
  101843. * @param gizmoLayer The utility layer the gizmo will be added to
  101844. */
  101845. constructor(gizmoLayer?: UtilityLayerRenderer);
  101846. updateGizmoRotationToMatchAttachedMesh: boolean;
  101847. /**
  101848. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101849. */
  101850. snapDistance: number;
  101851. /**
  101852. * Ratio for the scale of the gizmo (Default: 1)
  101853. */
  101854. scaleRatio: number;
  101855. /**
  101856. * Disposes of the gizmo
  101857. */
  101858. dispose(): void;
  101859. /**
  101860. * CustomMeshes are not supported by this gizmo
  101861. * @param mesh The mesh to replace the default mesh of the gizmo
  101862. */
  101863. setCustomMesh(mesh: Mesh): void;
  101864. }
  101865. }
  101866. declare module BABYLON {
  101867. /**
  101868. * Class containing static functions to help procedurally build meshes
  101869. */
  101870. export class PolyhedronBuilder {
  101871. /**
  101872. * Creates a polyhedron mesh
  101873. * * 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
  101874. * * The parameter `size` (positive float, default 1) sets the polygon size
  101875. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101876. * * 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`
  101877. * * 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
  101878. * * 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)`)
  101879. * * 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
  101880. * * 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
  101881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101884. * @param name defines the name of the mesh
  101885. * @param options defines the options used to create the mesh
  101886. * @param scene defines the hosting scene
  101887. * @returns the polyhedron mesh
  101888. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  101889. */
  101890. static CreatePolyhedron(name: string, options: {
  101891. type?: number;
  101892. size?: number;
  101893. sizeX?: number;
  101894. sizeY?: number;
  101895. sizeZ?: number;
  101896. custom?: any;
  101897. faceUV?: Vector4[];
  101898. faceColors?: Color4[];
  101899. flat?: boolean;
  101900. updatable?: boolean;
  101901. sideOrientation?: number;
  101902. frontUVs?: Vector4;
  101903. backUVs?: Vector4;
  101904. }, scene?: Nullable<Scene>): Mesh;
  101905. }
  101906. }
  101907. declare module BABYLON {
  101908. /**
  101909. * Gizmo that enables scaling a mesh along 3 axis
  101910. */
  101911. export class ScaleGizmo extends Gizmo {
  101912. /**
  101913. * Internal gizmo used for interactions on the x axis
  101914. */
  101915. xGizmo: AxisScaleGizmo;
  101916. /**
  101917. * Internal gizmo used for interactions on the y axis
  101918. */
  101919. yGizmo: AxisScaleGizmo;
  101920. /**
  101921. * Internal gizmo used for interactions on the z axis
  101922. */
  101923. zGizmo: AxisScaleGizmo;
  101924. /**
  101925. * Internal gizmo used to scale all axis equally
  101926. */
  101927. uniformScaleGizmo: AxisScaleGizmo;
  101928. /** Fires an event when any of it's sub gizmos are dragged */
  101929. onDragStartObservable: Observable<{}>;
  101930. /** Fires an event when any of it's sub gizmos are released from dragging */
  101931. onDragEndObservable: Observable<{}>;
  101932. attachedMesh: Nullable<AbstractMesh>;
  101933. /**
  101934. * Creates a ScaleGizmo
  101935. * @param gizmoLayer The utility layer the gizmo will be added to
  101936. */
  101937. constructor(gizmoLayer?: UtilityLayerRenderer);
  101938. updateGizmoRotationToMatchAttachedMesh: boolean;
  101939. /**
  101940. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101941. */
  101942. snapDistance: number;
  101943. /**
  101944. * Ratio for the scale of the gizmo (Default: 1)
  101945. */
  101946. scaleRatio: number;
  101947. /**
  101948. * Disposes of the gizmo
  101949. */
  101950. dispose(): void;
  101951. }
  101952. }
  101953. declare module BABYLON {
  101954. /**
  101955. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  101956. */
  101957. export class GizmoManager implements IDisposable {
  101958. private scene;
  101959. /**
  101960. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  101961. */
  101962. gizmos: {
  101963. positionGizmo: Nullable<PositionGizmo>;
  101964. rotationGizmo: Nullable<RotationGizmo>;
  101965. scaleGizmo: Nullable<ScaleGizmo>;
  101966. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  101967. };
  101968. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  101969. clearGizmoOnEmptyPointerEvent: boolean;
  101970. /** Fires an event when the manager is attached to a mesh */
  101971. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  101972. private _gizmosEnabled;
  101973. private _pointerObserver;
  101974. private _attachedMesh;
  101975. private _boundingBoxColor;
  101976. private _defaultUtilityLayer;
  101977. private _defaultKeepDepthUtilityLayer;
  101978. /**
  101979. * When bounding box gizmo is enabled, this can be used to track drag/end events
  101980. */
  101981. boundingBoxDragBehavior: SixDofDragBehavior;
  101982. /**
  101983. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  101984. */
  101985. attachableMeshes: Nullable<Array<AbstractMesh>>;
  101986. /**
  101987. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  101988. */
  101989. usePointerToAttachGizmos: boolean;
  101990. /**
  101991. * Instatiates a gizmo manager
  101992. * @param scene the scene to overlay the gizmos on top of
  101993. */
  101994. constructor(scene: Scene);
  101995. /**
  101996. * Attaches a set of gizmos to the specified mesh
  101997. * @param mesh The mesh the gizmo's should be attached to
  101998. */
  101999. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102000. /**
  102001. * If the position gizmo is enabled
  102002. */
  102003. positionGizmoEnabled: boolean;
  102004. /**
  102005. * If the rotation gizmo is enabled
  102006. */
  102007. rotationGizmoEnabled: boolean;
  102008. /**
  102009. * If the scale gizmo is enabled
  102010. */
  102011. scaleGizmoEnabled: boolean;
  102012. /**
  102013. * If the boundingBox gizmo is enabled
  102014. */
  102015. boundingBoxGizmoEnabled: boolean;
  102016. /**
  102017. * Disposes of the gizmo manager
  102018. */
  102019. dispose(): void;
  102020. }
  102021. }
  102022. declare module BABYLON {
  102023. /**
  102024. * A directional light is defined by a direction (what a surprise!).
  102025. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102026. * 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.
  102027. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102028. */
  102029. export class DirectionalLight extends ShadowLight {
  102030. private _shadowFrustumSize;
  102031. /**
  102032. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102033. */
  102034. /**
  102035. * Specifies a fix frustum size for the shadow generation.
  102036. */
  102037. shadowFrustumSize: number;
  102038. private _shadowOrthoScale;
  102039. /**
  102040. * Gets the shadow projection scale against the optimal computed one.
  102041. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102042. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102043. */
  102044. /**
  102045. * Sets the shadow projection scale against the optimal computed one.
  102046. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102047. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102048. */
  102049. shadowOrthoScale: number;
  102050. /**
  102051. * Automatically compute the projection matrix to best fit (including all the casters)
  102052. * on each frame.
  102053. */
  102054. autoUpdateExtends: boolean;
  102055. private _orthoLeft;
  102056. private _orthoRight;
  102057. private _orthoTop;
  102058. private _orthoBottom;
  102059. /**
  102060. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102061. * The directional light is emitted from everywhere in the given direction.
  102062. * It can cast shadows.
  102063. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102064. * @param name The friendly name of the light
  102065. * @param direction The direction of the light
  102066. * @param scene The scene the light belongs to
  102067. */
  102068. constructor(name: string, direction: Vector3, scene: Scene);
  102069. /**
  102070. * Returns the string "DirectionalLight".
  102071. * @return The class name
  102072. */
  102073. getClassName(): string;
  102074. /**
  102075. * Returns the integer 1.
  102076. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102077. */
  102078. getTypeID(): number;
  102079. /**
  102080. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102081. * Returns the DirectionalLight Shadow projection matrix.
  102082. */
  102083. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102084. /**
  102085. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102086. * Returns the DirectionalLight Shadow projection matrix.
  102087. */
  102088. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102089. /**
  102090. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102091. * Returns the DirectionalLight Shadow projection matrix.
  102092. */
  102093. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102094. protected _buildUniformLayout(): void;
  102095. /**
  102096. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102097. * @param effect The effect to update
  102098. * @param lightIndex The index of the light in the effect to update
  102099. * @returns The directional light
  102100. */
  102101. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102102. /**
  102103. * Gets the minZ used for shadow according to both the scene and the light.
  102104. *
  102105. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102106. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102107. * @param activeCamera The camera we are returning the min for
  102108. * @returns the depth min z
  102109. */
  102110. getDepthMinZ(activeCamera: Camera): number;
  102111. /**
  102112. * Gets the maxZ used for shadow according to both the scene and the light.
  102113. *
  102114. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102115. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102116. * @param activeCamera The camera we are returning the max for
  102117. * @returns the depth max z
  102118. */
  102119. getDepthMaxZ(activeCamera: Camera): number;
  102120. /**
  102121. * Prepares the list of defines specific to the light type.
  102122. * @param defines the list of defines
  102123. * @param lightIndex defines the index of the light for the effect
  102124. */
  102125. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102126. }
  102127. }
  102128. declare module BABYLON {
  102129. /**
  102130. * Class containing static functions to help procedurally build meshes
  102131. */
  102132. export class HemisphereBuilder {
  102133. /**
  102134. * Creates a hemisphere mesh
  102135. * @param name defines the name of the mesh
  102136. * @param options defines the options used to create the mesh
  102137. * @param scene defines the hosting scene
  102138. * @returns the hemisphere mesh
  102139. */
  102140. static CreateHemisphere(name: string, options: {
  102141. segments?: number;
  102142. diameter?: number;
  102143. sideOrientation?: number;
  102144. }, scene: any): Mesh;
  102145. }
  102146. }
  102147. declare module BABYLON {
  102148. /**
  102149. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102150. * These values define a cone of light starting from the position, emitting toward the direction.
  102151. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102152. * and the exponent defines the speed of the decay of the light with distance (reach).
  102153. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102154. */
  102155. export class SpotLight extends ShadowLight {
  102156. private _angle;
  102157. private _innerAngle;
  102158. private _cosHalfAngle;
  102159. private _lightAngleScale;
  102160. private _lightAngleOffset;
  102161. /**
  102162. * Gets the cone angle of the spot light in Radians.
  102163. */
  102164. /**
  102165. * Sets the cone angle of the spot light in Radians.
  102166. */
  102167. angle: number;
  102168. /**
  102169. * Only used in gltf falloff mode, this defines the angle where
  102170. * the directional falloff will start before cutting at angle which could be seen
  102171. * as outer angle.
  102172. */
  102173. /**
  102174. * Only used in gltf falloff mode, this defines the angle where
  102175. * the directional falloff will start before cutting at angle which could be seen
  102176. * as outer angle.
  102177. */
  102178. innerAngle: number;
  102179. private _shadowAngleScale;
  102180. /**
  102181. * Allows scaling the angle of the light for shadow generation only.
  102182. */
  102183. /**
  102184. * Allows scaling the angle of the light for shadow generation only.
  102185. */
  102186. shadowAngleScale: number;
  102187. /**
  102188. * The light decay speed with the distance from the emission spot.
  102189. */
  102190. exponent: number;
  102191. private _projectionTextureMatrix;
  102192. /**
  102193. * Allows reading the projecton texture
  102194. */
  102195. readonly projectionTextureMatrix: Matrix;
  102196. protected _projectionTextureLightNear: number;
  102197. /**
  102198. * Gets the near clip of the Spotlight for texture projection.
  102199. */
  102200. /**
  102201. * Sets the near clip of the Spotlight for texture projection.
  102202. */
  102203. projectionTextureLightNear: number;
  102204. protected _projectionTextureLightFar: number;
  102205. /**
  102206. * Gets the far clip of the Spotlight for texture projection.
  102207. */
  102208. /**
  102209. * Sets the far clip of the Spotlight for texture projection.
  102210. */
  102211. projectionTextureLightFar: number;
  102212. protected _projectionTextureUpDirection: Vector3;
  102213. /**
  102214. * Gets the Up vector of the Spotlight for texture projection.
  102215. */
  102216. /**
  102217. * Sets the Up vector of the Spotlight for texture projection.
  102218. */
  102219. projectionTextureUpDirection: Vector3;
  102220. private _projectionTexture;
  102221. /**
  102222. * Gets the projection texture of the light.
  102223. */
  102224. /**
  102225. * Sets the projection texture of the light.
  102226. */
  102227. projectionTexture: Nullable<BaseTexture>;
  102228. private _projectionTextureViewLightDirty;
  102229. private _projectionTextureProjectionLightDirty;
  102230. private _projectionTextureDirty;
  102231. private _projectionTextureViewTargetVector;
  102232. private _projectionTextureViewLightMatrix;
  102233. private _projectionTextureProjectionLightMatrix;
  102234. private _projectionTextureScalingMatrix;
  102235. /**
  102236. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102237. * It can cast shadows.
  102238. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102239. * @param name The light friendly name
  102240. * @param position The position of the spot light in the scene
  102241. * @param direction The direction of the light in the scene
  102242. * @param angle The cone angle of the light in Radians
  102243. * @param exponent The light decay speed with the distance from the emission spot
  102244. * @param scene The scene the lights belongs to
  102245. */
  102246. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102247. /**
  102248. * Returns the string "SpotLight".
  102249. * @returns the class name
  102250. */
  102251. getClassName(): string;
  102252. /**
  102253. * Returns the integer 2.
  102254. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102255. */
  102256. getTypeID(): number;
  102257. /**
  102258. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102259. */
  102260. protected _setDirection(value: Vector3): void;
  102261. /**
  102262. * Overrides the position setter to recompute the projection texture view light Matrix.
  102263. */
  102264. protected _setPosition(value: Vector3): void;
  102265. /**
  102266. * 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.
  102267. * Returns the SpotLight.
  102268. */
  102269. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102270. protected _computeProjectionTextureViewLightMatrix(): void;
  102271. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102272. /**
  102273. * Main function for light texture projection matrix computing.
  102274. */
  102275. protected _computeProjectionTextureMatrix(): void;
  102276. protected _buildUniformLayout(): void;
  102277. private _computeAngleValues;
  102278. /**
  102279. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102280. * @param effect The effect to update
  102281. * @param lightIndex The index of the light in the effect to update
  102282. * @returns The spot light
  102283. */
  102284. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102285. /**
  102286. * Disposes the light and the associated resources.
  102287. */
  102288. dispose(): void;
  102289. /**
  102290. * Prepares the list of defines specific to the light type.
  102291. * @param defines the list of defines
  102292. * @param lightIndex defines the index of the light for the effect
  102293. */
  102294. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102295. }
  102296. }
  102297. declare module BABYLON {
  102298. /**
  102299. * Gizmo that enables viewing a light
  102300. */
  102301. export class LightGizmo extends Gizmo {
  102302. private _lightMesh;
  102303. private _material;
  102304. /**
  102305. * Creates a LightGizmo
  102306. * @param gizmoLayer The utility layer the gizmo will be added to
  102307. */
  102308. constructor(gizmoLayer?: UtilityLayerRenderer);
  102309. private _light;
  102310. /**
  102311. * The light that the gizmo is attached to
  102312. */
  102313. light: Nullable<Light>;
  102314. /**
  102315. * @hidden
  102316. * Updates the gizmo to match the attached mesh's position/rotation
  102317. */
  102318. protected _update(): void;
  102319. private static _Scale;
  102320. /**
  102321. * Creates the lines for a light mesh
  102322. */
  102323. private static _createLightLines;
  102324. private static _CreateHemisphericLightMesh;
  102325. private static _CreatePointLightMesh;
  102326. private static _CreateSpotLightMesh;
  102327. private static _CreateDirectionalLightMesh;
  102328. }
  102329. }
  102330. declare module BABYLON {
  102331. /** @hidden */
  102332. export var backgroundFragmentDeclaration: {
  102333. name: string;
  102334. shader: string;
  102335. };
  102336. }
  102337. declare module BABYLON {
  102338. /** @hidden */
  102339. export var backgroundUboDeclaration: {
  102340. name: string;
  102341. shader: string;
  102342. };
  102343. }
  102344. declare module BABYLON {
  102345. /** @hidden */
  102346. export var backgroundPixelShader: {
  102347. name: string;
  102348. shader: string;
  102349. };
  102350. }
  102351. declare module BABYLON {
  102352. /** @hidden */
  102353. export var backgroundVertexDeclaration: {
  102354. name: string;
  102355. shader: string;
  102356. };
  102357. }
  102358. declare module BABYLON {
  102359. /** @hidden */
  102360. export var backgroundVertexShader: {
  102361. name: string;
  102362. shader: string;
  102363. };
  102364. }
  102365. declare module BABYLON {
  102366. /**
  102367. * Background material used to create an efficient environement around your scene.
  102368. */
  102369. export class BackgroundMaterial extends PushMaterial {
  102370. /**
  102371. * Standard reflectance value at parallel view angle.
  102372. */
  102373. static StandardReflectance0: number;
  102374. /**
  102375. * Standard reflectance value at grazing angle.
  102376. */
  102377. static StandardReflectance90: number;
  102378. protected _primaryColor: Color3;
  102379. /**
  102380. * Key light Color (multiply against the environement texture)
  102381. */
  102382. primaryColor: Color3;
  102383. protected __perceptualColor: Nullable<Color3>;
  102384. /**
  102385. * Experimental Internal Use Only.
  102386. *
  102387. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102388. * This acts as a helper to set the primary color to a more "human friendly" value.
  102389. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102390. * output color as close as possible from the chosen value.
  102391. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102392. * part of lighting setup.)
  102393. */
  102394. _perceptualColor: Nullable<Color3>;
  102395. protected _primaryColorShadowLevel: float;
  102396. /**
  102397. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102398. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102399. */
  102400. primaryColorShadowLevel: float;
  102401. protected _primaryColorHighlightLevel: float;
  102402. /**
  102403. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102404. * The primary color is used at the level chosen to define what the white area would look.
  102405. */
  102406. primaryColorHighlightLevel: float;
  102407. protected _reflectionTexture: Nullable<BaseTexture>;
  102408. /**
  102409. * Reflection Texture used in the material.
  102410. * Should be author in a specific way for the best result (refer to the documentation).
  102411. */
  102412. reflectionTexture: Nullable<BaseTexture>;
  102413. protected _reflectionBlur: float;
  102414. /**
  102415. * Reflection Texture level of blur.
  102416. *
  102417. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102418. * texture twice.
  102419. */
  102420. reflectionBlur: float;
  102421. protected _diffuseTexture: Nullable<BaseTexture>;
  102422. /**
  102423. * Diffuse Texture used in the material.
  102424. * Should be author in a specific way for the best result (refer to the documentation).
  102425. */
  102426. diffuseTexture: Nullable<BaseTexture>;
  102427. protected _shadowLights: Nullable<IShadowLight[]>;
  102428. /**
  102429. * Specify the list of lights casting shadow on the material.
  102430. * All scene shadow lights will be included if null.
  102431. */
  102432. shadowLights: Nullable<IShadowLight[]>;
  102433. protected _shadowLevel: float;
  102434. /**
  102435. * Helps adjusting the shadow to a softer level if required.
  102436. * 0 means black shadows and 1 means no shadows.
  102437. */
  102438. shadowLevel: float;
  102439. protected _sceneCenter: Vector3;
  102440. /**
  102441. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102442. * It is usually zero but might be interesting to modify according to your setup.
  102443. */
  102444. sceneCenter: Vector3;
  102445. protected _opacityFresnel: boolean;
  102446. /**
  102447. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102448. * This helps ensuring a nice transition when the camera goes under the ground.
  102449. */
  102450. opacityFresnel: boolean;
  102451. protected _reflectionFresnel: boolean;
  102452. /**
  102453. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102454. * This helps adding a mirror texture on the ground.
  102455. */
  102456. reflectionFresnel: boolean;
  102457. protected _reflectionFalloffDistance: number;
  102458. /**
  102459. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102460. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102461. */
  102462. reflectionFalloffDistance: number;
  102463. protected _reflectionAmount: number;
  102464. /**
  102465. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102466. */
  102467. reflectionAmount: number;
  102468. protected _reflectionReflectance0: number;
  102469. /**
  102470. * This specifies the weight of the reflection at grazing angle.
  102471. */
  102472. reflectionReflectance0: number;
  102473. protected _reflectionReflectance90: number;
  102474. /**
  102475. * This specifies the weight of the reflection at a perpendicular point of view.
  102476. */
  102477. reflectionReflectance90: number;
  102478. /**
  102479. * Sets the reflection reflectance fresnel values according to the default standard
  102480. * empirically know to work well :-)
  102481. */
  102482. reflectionStandardFresnelWeight: number;
  102483. protected _useRGBColor: boolean;
  102484. /**
  102485. * Helps to directly use the maps channels instead of their level.
  102486. */
  102487. useRGBColor: boolean;
  102488. protected _enableNoise: boolean;
  102489. /**
  102490. * This helps reducing the banding effect that could occur on the background.
  102491. */
  102492. enableNoise: boolean;
  102493. /**
  102494. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102495. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102496. * Recommended to be keep at 1.0 except for special cases.
  102497. */
  102498. fovMultiplier: number;
  102499. private _fovMultiplier;
  102500. /**
  102501. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102502. */
  102503. useEquirectangularFOV: boolean;
  102504. private _maxSimultaneousLights;
  102505. /**
  102506. * Number of Simultaneous lights allowed on the material.
  102507. */
  102508. maxSimultaneousLights: int;
  102509. /**
  102510. * Default configuration related to image processing available in the Background Material.
  102511. */
  102512. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102513. /**
  102514. * Keep track of the image processing observer to allow dispose and replace.
  102515. */
  102516. private _imageProcessingObserver;
  102517. /**
  102518. * Attaches a new image processing configuration to the PBR Material.
  102519. * @param configuration (if null the scene configuration will be use)
  102520. */
  102521. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102522. /**
  102523. * Gets the image processing configuration used either in this material.
  102524. */
  102525. /**
  102526. * Sets the Default image processing configuration used either in the this material.
  102527. *
  102528. * If sets to null, the scene one is in use.
  102529. */
  102530. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  102531. /**
  102532. * Gets wether the color curves effect is enabled.
  102533. */
  102534. /**
  102535. * Sets wether the color curves effect is enabled.
  102536. */
  102537. cameraColorCurvesEnabled: boolean;
  102538. /**
  102539. * Gets wether the color grading effect is enabled.
  102540. */
  102541. /**
  102542. * Gets wether the color grading effect is enabled.
  102543. */
  102544. cameraColorGradingEnabled: boolean;
  102545. /**
  102546. * Gets wether tonemapping is enabled or not.
  102547. */
  102548. /**
  102549. * Sets wether tonemapping is enabled or not
  102550. */
  102551. cameraToneMappingEnabled: boolean;
  102552. /**
  102553. * The camera exposure used on this material.
  102554. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102555. * This corresponds to a photographic exposure.
  102556. */
  102557. /**
  102558. * The camera exposure used on this material.
  102559. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102560. * This corresponds to a photographic exposure.
  102561. */
  102562. cameraExposure: float;
  102563. /**
  102564. * Gets The camera contrast used on this material.
  102565. */
  102566. /**
  102567. * Sets The camera contrast used on this material.
  102568. */
  102569. cameraContrast: float;
  102570. /**
  102571. * Gets the Color Grading 2D Lookup Texture.
  102572. */
  102573. /**
  102574. * Sets the Color Grading 2D Lookup Texture.
  102575. */
  102576. cameraColorGradingTexture: Nullable<BaseTexture>;
  102577. /**
  102578. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102579. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102580. * 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;
  102581. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102582. */
  102583. /**
  102584. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102585. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102586. * 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;
  102587. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102588. */
  102589. cameraColorCurves: Nullable<ColorCurves>;
  102590. /**
  102591. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  102592. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  102593. */
  102594. switchToBGR: boolean;
  102595. private _renderTargets;
  102596. private _reflectionControls;
  102597. private _white;
  102598. private _primaryShadowColor;
  102599. private _primaryHighlightColor;
  102600. /**
  102601. * Instantiates a Background Material in the given scene
  102602. * @param name The friendly name of the material
  102603. * @param scene The scene to add the material to
  102604. */
  102605. constructor(name: string, scene: Scene);
  102606. /**
  102607. * Gets a boolean indicating that current material needs to register RTT
  102608. */
  102609. readonly hasRenderTargetTextures: boolean;
  102610. /**
  102611. * The entire material has been created in order to prevent overdraw.
  102612. * @returns false
  102613. */
  102614. needAlphaTesting(): boolean;
  102615. /**
  102616. * The entire material has been created in order to prevent overdraw.
  102617. * @returns true if blending is enable
  102618. */
  102619. needAlphaBlending(): boolean;
  102620. /**
  102621. * Checks wether the material is ready to be rendered for a given mesh.
  102622. * @param mesh The mesh to render
  102623. * @param subMesh The submesh to check against
  102624. * @param useInstances Specify wether or not the material is used with instances
  102625. * @returns true if all the dependencies are ready (Textures, Effects...)
  102626. */
  102627. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102628. /**
  102629. * Compute the primary color according to the chosen perceptual color.
  102630. */
  102631. private _computePrimaryColorFromPerceptualColor;
  102632. /**
  102633. * Compute the highlights and shadow colors according to their chosen levels.
  102634. */
  102635. private _computePrimaryColors;
  102636. /**
  102637. * Build the uniform buffer used in the material.
  102638. */
  102639. buildUniformLayout(): void;
  102640. /**
  102641. * Unbind the material.
  102642. */
  102643. unbind(): void;
  102644. /**
  102645. * Bind only the world matrix to the material.
  102646. * @param world The world matrix to bind.
  102647. */
  102648. bindOnlyWorldMatrix(world: Matrix): void;
  102649. /**
  102650. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  102651. * @param world The world matrix to bind.
  102652. * @param subMesh The submesh to bind for.
  102653. */
  102654. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102655. /**
  102656. * Dispose the material.
  102657. * @param forceDisposeEffect Force disposal of the associated effect.
  102658. * @param forceDisposeTextures Force disposal of the associated textures.
  102659. */
  102660. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102661. /**
  102662. * Clones the material.
  102663. * @param name The cloned name.
  102664. * @returns The cloned material.
  102665. */
  102666. clone(name: string): BackgroundMaterial;
  102667. /**
  102668. * Serializes the current material to its JSON representation.
  102669. * @returns The JSON representation.
  102670. */
  102671. serialize(): any;
  102672. /**
  102673. * Gets the class name of the material
  102674. * @returns "BackgroundMaterial"
  102675. */
  102676. getClassName(): string;
  102677. /**
  102678. * Parse a JSON input to create back a background material.
  102679. * @param source The JSON data to parse
  102680. * @param scene The scene to create the parsed material in
  102681. * @param rootUrl The root url of the assets the material depends upon
  102682. * @returns the instantiated BackgroundMaterial.
  102683. */
  102684. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  102685. }
  102686. }
  102687. declare module BABYLON {
  102688. /**
  102689. * Represents the different options available during the creation of
  102690. * a Environment helper.
  102691. *
  102692. * This can control the default ground, skybox and image processing setup of your scene.
  102693. */
  102694. export interface IEnvironmentHelperOptions {
  102695. /**
  102696. * Specifies wether or not to create a ground.
  102697. * True by default.
  102698. */
  102699. createGround: boolean;
  102700. /**
  102701. * Specifies the ground size.
  102702. * 15 by default.
  102703. */
  102704. groundSize: number;
  102705. /**
  102706. * The texture used on the ground for the main color.
  102707. * Comes from the BabylonJS CDN by default.
  102708. *
  102709. * Remarks: Can be either a texture or a url.
  102710. */
  102711. groundTexture: string | BaseTexture;
  102712. /**
  102713. * The color mixed in the ground texture by default.
  102714. * BabylonJS clearColor by default.
  102715. */
  102716. groundColor: Color3;
  102717. /**
  102718. * Specifies the ground opacity.
  102719. * 1 by default.
  102720. */
  102721. groundOpacity: number;
  102722. /**
  102723. * Enables the ground to receive shadows.
  102724. * True by default.
  102725. */
  102726. enableGroundShadow: boolean;
  102727. /**
  102728. * Helps preventing the shadow to be fully black on the ground.
  102729. * 0.5 by default.
  102730. */
  102731. groundShadowLevel: number;
  102732. /**
  102733. * Creates a mirror texture attach to the ground.
  102734. * false by default.
  102735. */
  102736. enableGroundMirror: boolean;
  102737. /**
  102738. * Specifies the ground mirror size ratio.
  102739. * 0.3 by default as the default kernel is 64.
  102740. */
  102741. groundMirrorSizeRatio: number;
  102742. /**
  102743. * Specifies the ground mirror blur kernel size.
  102744. * 64 by default.
  102745. */
  102746. groundMirrorBlurKernel: number;
  102747. /**
  102748. * Specifies the ground mirror visibility amount.
  102749. * 1 by default
  102750. */
  102751. groundMirrorAmount: number;
  102752. /**
  102753. * Specifies the ground mirror reflectance weight.
  102754. * This uses the standard weight of the background material to setup the fresnel effect
  102755. * of the mirror.
  102756. * 1 by default.
  102757. */
  102758. groundMirrorFresnelWeight: number;
  102759. /**
  102760. * Specifies the ground mirror Falloff distance.
  102761. * This can helps reducing the size of the reflection.
  102762. * 0 by Default.
  102763. */
  102764. groundMirrorFallOffDistance: number;
  102765. /**
  102766. * Specifies the ground mirror texture type.
  102767. * Unsigned Int by Default.
  102768. */
  102769. groundMirrorTextureType: number;
  102770. /**
  102771. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  102772. * the shown objects.
  102773. */
  102774. groundYBias: number;
  102775. /**
  102776. * Specifies wether or not to create a skybox.
  102777. * True by default.
  102778. */
  102779. createSkybox: boolean;
  102780. /**
  102781. * Specifies the skybox size.
  102782. * 20 by default.
  102783. */
  102784. skyboxSize: number;
  102785. /**
  102786. * The texture used on the skybox for the main color.
  102787. * Comes from the BabylonJS CDN by default.
  102788. *
  102789. * Remarks: Can be either a texture or a url.
  102790. */
  102791. skyboxTexture: string | BaseTexture;
  102792. /**
  102793. * The color mixed in the skybox texture by default.
  102794. * BabylonJS clearColor by default.
  102795. */
  102796. skyboxColor: Color3;
  102797. /**
  102798. * The background rotation around the Y axis of the scene.
  102799. * This helps aligning the key lights of your scene with the background.
  102800. * 0 by default.
  102801. */
  102802. backgroundYRotation: number;
  102803. /**
  102804. * Compute automatically the size of the elements to best fit with the scene.
  102805. */
  102806. sizeAuto: boolean;
  102807. /**
  102808. * Default position of the rootMesh if autoSize is not true.
  102809. */
  102810. rootPosition: Vector3;
  102811. /**
  102812. * Sets up the image processing in the scene.
  102813. * true by default.
  102814. */
  102815. setupImageProcessing: boolean;
  102816. /**
  102817. * The texture used as your environment texture in the scene.
  102818. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  102819. *
  102820. * Remarks: Can be either a texture or a url.
  102821. */
  102822. environmentTexture: string | BaseTexture;
  102823. /**
  102824. * The value of the exposure to apply to the scene.
  102825. * 0.6 by default if setupImageProcessing is true.
  102826. */
  102827. cameraExposure: number;
  102828. /**
  102829. * The value of the contrast to apply to the scene.
  102830. * 1.6 by default if setupImageProcessing is true.
  102831. */
  102832. cameraContrast: number;
  102833. /**
  102834. * Specifies wether or not tonemapping should be enabled in the scene.
  102835. * true by default if setupImageProcessing is true.
  102836. */
  102837. toneMappingEnabled: boolean;
  102838. }
  102839. /**
  102840. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  102841. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  102842. * It also helps with the default setup of your imageProcessing configuration.
  102843. */
  102844. export class EnvironmentHelper {
  102845. /**
  102846. * Default ground texture URL.
  102847. */
  102848. private static _groundTextureCDNUrl;
  102849. /**
  102850. * Default skybox texture URL.
  102851. */
  102852. private static _skyboxTextureCDNUrl;
  102853. /**
  102854. * Default environment texture URL.
  102855. */
  102856. private static _environmentTextureCDNUrl;
  102857. /**
  102858. * Creates the default options for the helper.
  102859. */
  102860. private static _getDefaultOptions;
  102861. private _rootMesh;
  102862. /**
  102863. * Gets the root mesh created by the helper.
  102864. */
  102865. readonly rootMesh: Mesh;
  102866. private _skybox;
  102867. /**
  102868. * Gets the skybox created by the helper.
  102869. */
  102870. readonly skybox: Nullable<Mesh>;
  102871. private _skyboxTexture;
  102872. /**
  102873. * Gets the skybox texture created by the helper.
  102874. */
  102875. readonly skyboxTexture: Nullable<BaseTexture>;
  102876. private _skyboxMaterial;
  102877. /**
  102878. * Gets the skybox material created by the helper.
  102879. */
  102880. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  102881. private _ground;
  102882. /**
  102883. * Gets the ground mesh created by the helper.
  102884. */
  102885. readonly ground: Nullable<Mesh>;
  102886. private _groundTexture;
  102887. /**
  102888. * Gets the ground texture created by the helper.
  102889. */
  102890. readonly groundTexture: Nullable<BaseTexture>;
  102891. private _groundMirror;
  102892. /**
  102893. * Gets the ground mirror created by the helper.
  102894. */
  102895. readonly groundMirror: Nullable<MirrorTexture>;
  102896. /**
  102897. * Gets the ground mirror render list to helps pushing the meshes
  102898. * you wish in the ground reflection.
  102899. */
  102900. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  102901. private _groundMaterial;
  102902. /**
  102903. * Gets the ground material created by the helper.
  102904. */
  102905. readonly groundMaterial: Nullable<BackgroundMaterial>;
  102906. /**
  102907. * Stores the creation options.
  102908. */
  102909. private readonly _scene;
  102910. private _options;
  102911. /**
  102912. * This observable will be notified with any error during the creation of the environment,
  102913. * mainly texture creation errors.
  102914. */
  102915. onErrorObservable: Observable<{
  102916. message?: string;
  102917. exception?: any;
  102918. }>;
  102919. /**
  102920. * constructor
  102921. * @param options Defines the options we want to customize the helper
  102922. * @param scene The scene to add the material to
  102923. */
  102924. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  102925. /**
  102926. * Updates the background according to the new options
  102927. * @param options
  102928. */
  102929. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  102930. /**
  102931. * Sets the primary color of all the available elements.
  102932. * @param color the main color to affect to the ground and the background
  102933. */
  102934. setMainColor(color: Color3): void;
  102935. /**
  102936. * Setup the image processing according to the specified options.
  102937. */
  102938. private _setupImageProcessing;
  102939. /**
  102940. * Setup the environment texture according to the specified options.
  102941. */
  102942. private _setupEnvironmentTexture;
  102943. /**
  102944. * Setup the background according to the specified options.
  102945. */
  102946. private _setupBackground;
  102947. /**
  102948. * Get the scene sizes according to the setup.
  102949. */
  102950. private _getSceneSize;
  102951. /**
  102952. * Setup the ground according to the specified options.
  102953. */
  102954. private _setupGround;
  102955. /**
  102956. * Setup the ground material according to the specified options.
  102957. */
  102958. private _setupGroundMaterial;
  102959. /**
  102960. * Setup the ground diffuse texture according to the specified options.
  102961. */
  102962. private _setupGroundDiffuseTexture;
  102963. /**
  102964. * Setup the ground mirror texture according to the specified options.
  102965. */
  102966. private _setupGroundMirrorTexture;
  102967. /**
  102968. * Setup the ground to receive the mirror texture.
  102969. */
  102970. private _setupMirrorInGroundMaterial;
  102971. /**
  102972. * Setup the skybox according to the specified options.
  102973. */
  102974. private _setupSkybox;
  102975. /**
  102976. * Setup the skybox material according to the specified options.
  102977. */
  102978. private _setupSkyboxMaterial;
  102979. /**
  102980. * Setup the skybox reflection texture according to the specified options.
  102981. */
  102982. private _setupSkyboxReflectionTexture;
  102983. private _errorHandler;
  102984. /**
  102985. * Dispose all the elements created by the Helper.
  102986. */
  102987. dispose(): void;
  102988. }
  102989. }
  102990. declare module BABYLON {
  102991. /**
  102992. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  102993. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  102994. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  102995. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102996. */
  102997. export class PhotoDome extends TransformNode {
  102998. private _useDirectMapping;
  102999. /**
  103000. * The texture being displayed on the sphere
  103001. */
  103002. protected _photoTexture: Texture;
  103003. /**
  103004. * Gets or sets the texture being displayed on the sphere
  103005. */
  103006. photoTexture: Texture;
  103007. /**
  103008. * Observable raised when an error occured while loading the 360 image
  103009. */
  103010. onLoadErrorObservable: Observable<string>;
  103011. /**
  103012. * The skybox material
  103013. */
  103014. protected _material: BackgroundMaterial;
  103015. /**
  103016. * The surface used for the skybox
  103017. */
  103018. protected _mesh: Mesh;
  103019. /**
  103020. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103021. * Also see the options.resolution property.
  103022. */
  103023. fovMultiplier: number;
  103024. /**
  103025. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103026. * @param name Element's name, child elements will append suffixes for their own names.
  103027. * @param urlsOfPhoto defines the url of the photo to display
  103028. * @param options defines an object containing optional or exposed sub element properties
  103029. * @param onError defines a callback called when an error occured while loading the texture
  103030. */
  103031. constructor(name: string, urlOfPhoto: string, options: {
  103032. resolution?: number;
  103033. size?: number;
  103034. useDirectMapping?: boolean;
  103035. faceForward?: boolean;
  103036. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103037. /**
  103038. * Releases resources associated with this node.
  103039. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103040. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103041. */
  103042. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103043. }
  103044. }
  103045. declare module BABYLON {
  103046. /** @hidden */
  103047. export var rgbdDecodePixelShader: {
  103048. name: string;
  103049. shader: string;
  103050. };
  103051. }
  103052. declare module BABYLON {
  103053. /**
  103054. * Class used to host texture specific utilities
  103055. */
  103056. export class BRDFTextureTools {
  103057. /**
  103058. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103059. * @param texture the texture to expand.
  103060. */
  103061. private static _ExpandDefaultBRDFTexture;
  103062. /**
  103063. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103064. * @param scene defines the hosting scene
  103065. * @returns the environment BRDF texture
  103066. */
  103067. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103068. private static _environmentBRDFBase64Texture;
  103069. }
  103070. }
  103071. declare module BABYLON {
  103072. /**
  103073. * @hidden
  103074. */
  103075. export interface IMaterialClearCoatDefines {
  103076. CLEARCOAT: boolean;
  103077. CLEARCOAT_DEFAULTIOR: boolean;
  103078. CLEARCOAT_TEXTURE: boolean;
  103079. CLEARCOAT_TEXTUREDIRECTUV: number;
  103080. CLEARCOAT_BUMP: boolean;
  103081. CLEARCOAT_BUMPDIRECTUV: number;
  103082. CLEARCOAT_TINT: boolean;
  103083. CLEARCOAT_TINT_TEXTURE: boolean;
  103084. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103085. /** @hidden */
  103086. _areTexturesDirty: boolean;
  103087. }
  103088. /**
  103089. * Define the code related to the clear coat parameters of the pbr material.
  103090. */
  103091. export class PBRClearCoatConfiguration {
  103092. /**
  103093. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103094. * The default fits with a polyurethane material.
  103095. */
  103096. private static readonly _DefaultIndiceOfRefraction;
  103097. private _isEnabled;
  103098. /**
  103099. * Defines if the clear coat is enabled in the material.
  103100. */
  103101. isEnabled: boolean;
  103102. /**
  103103. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103104. */
  103105. intensity: number;
  103106. /**
  103107. * Defines the clear coat layer roughness.
  103108. */
  103109. roughness: number;
  103110. private _indiceOfRefraction;
  103111. /**
  103112. * Defines the indice of refraction of the clear coat.
  103113. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103114. * The default fits with a polyurethane material.
  103115. * Changing the default value is more performance intensive.
  103116. */
  103117. indiceOfRefraction: number;
  103118. private _texture;
  103119. /**
  103120. * Stores the clear coat values in a texture.
  103121. */
  103122. texture: Nullable<BaseTexture>;
  103123. private _bumpTexture;
  103124. /**
  103125. * Define the clear coat specific bump texture.
  103126. */
  103127. bumpTexture: Nullable<BaseTexture>;
  103128. private _isTintEnabled;
  103129. /**
  103130. * Defines if the clear coat tint is enabled in the material.
  103131. */
  103132. isTintEnabled: boolean;
  103133. /**
  103134. * Defines the clear coat tint of the material.
  103135. * This is only use if tint is enabled
  103136. */
  103137. tintColor: Color3;
  103138. /**
  103139. * Defines the distance at which the tint color should be found in the
  103140. * clear coat media.
  103141. * This is only use if tint is enabled
  103142. */
  103143. tintColorAtDistance: number;
  103144. /**
  103145. * Defines the clear coat layer thickness.
  103146. * This is only use if tint is enabled
  103147. */
  103148. tintThickness: number;
  103149. private _tintTexture;
  103150. /**
  103151. * Stores the clear tint values in a texture.
  103152. * rgb is tint
  103153. * a is a thickness factor
  103154. */
  103155. tintTexture: Nullable<BaseTexture>;
  103156. /** @hidden */
  103157. private _internalMarkAllSubMeshesAsTexturesDirty;
  103158. /** @hidden */
  103159. _markAllSubMeshesAsTexturesDirty(): void;
  103160. /**
  103161. * Instantiate a new istance of clear coat configuration.
  103162. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103163. */
  103164. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103165. /**
  103166. * Gets wehter the submesh is ready to be used or not.
  103167. * @param defines the list of "defines" to update.
  103168. * @param scene defines the scene the material belongs to.
  103169. * @param engine defines the engine the material belongs to.
  103170. * @param disableBumpMap defines wether the material disables bump or not.
  103171. * @returns - boolean indicating that the submesh is ready or not.
  103172. */
  103173. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  103174. /**
  103175. * Checks to see if a texture is used in the material.
  103176. * @param defines the list of "defines" to update.
  103177. * @param scene defines the scene to the material belongs to.
  103178. */
  103179. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  103180. /**
  103181. * Binds the material data.
  103182. * @param uniformBuffer defines the Uniform buffer to fill in.
  103183. * @param scene defines the scene the material belongs to.
  103184. * @param engine defines the engine the material belongs to.
  103185. * @param disableBumpMap defines wether the material disables bump or not.
  103186. * @param isFrozen defines wether the material is frozen or not.
  103187. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103188. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103189. */
  103190. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  103191. /**
  103192. * Checks to see if a texture is used in the material.
  103193. * @param texture - Base texture to use.
  103194. * @returns - Boolean specifying if a texture is used in the material.
  103195. */
  103196. hasTexture(texture: BaseTexture): boolean;
  103197. /**
  103198. * Returns an array of the actively used textures.
  103199. * @param activeTextures Array of BaseTextures
  103200. */
  103201. getActiveTextures(activeTextures: BaseTexture[]): void;
  103202. /**
  103203. * Returns the animatable textures.
  103204. * @param animatables Array of animatable textures.
  103205. */
  103206. getAnimatables(animatables: IAnimatable[]): void;
  103207. /**
  103208. * Disposes the resources of the material.
  103209. * @param forceDisposeTextures - Forces the disposal of all textures.
  103210. */
  103211. dispose(forceDisposeTextures?: boolean): void;
  103212. /**
  103213. * Get the current class name of the texture useful for serialization or dynamic coding.
  103214. * @returns "PBRClearCoatConfiguration"
  103215. */
  103216. getClassName(): string;
  103217. /**
  103218. * Add fallbacks to the effect fallbacks list.
  103219. * @param defines defines the Base texture to use.
  103220. * @param fallbacks defines the current fallback list.
  103221. * @param currentRank defines the current fallback rank.
  103222. * @returns the new fallback rank.
  103223. */
  103224. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103225. /**
  103226. * Add the required uniforms to the current list.
  103227. * @param uniforms defines the current uniform list.
  103228. */
  103229. static AddUniforms(uniforms: string[]): void;
  103230. /**
  103231. * Add the required samplers to the current list.
  103232. * @param samplers defines the current sampler list.
  103233. */
  103234. static AddSamplers(samplers: string[]): void;
  103235. /**
  103236. * Add the required uniforms to the current buffer.
  103237. * @param uniformBuffer defines the current uniform buffer.
  103238. */
  103239. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103240. /**
  103241. * Makes a duplicate of the current configuration into another one.
  103242. * @param clearCoatConfiguration define the config where to copy the info
  103243. */
  103244. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  103245. /**
  103246. * Serializes this clear coat configuration.
  103247. * @returns - An object with the serialized config.
  103248. */
  103249. serialize(): any;
  103250. /**
  103251. * Parses a Clear Coat Configuration from a serialized object.
  103252. * @param source - Serialized object.
  103253. */
  103254. parse(source: any): void;
  103255. }
  103256. }
  103257. declare module BABYLON {
  103258. /**
  103259. * @hidden
  103260. */
  103261. export interface IMaterialAnisotropicDefines {
  103262. ANISOTROPIC: boolean;
  103263. ANISOTROPIC_TEXTURE: boolean;
  103264. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103265. MAINUV1: boolean;
  103266. _areTexturesDirty: boolean;
  103267. _needUVs: boolean;
  103268. }
  103269. /**
  103270. * Define the code related to the anisotropic parameters of the pbr material.
  103271. */
  103272. export class PBRAnisotropicConfiguration {
  103273. private _isEnabled;
  103274. /**
  103275. * Defines if the anisotropy is enabled in the material.
  103276. */
  103277. isEnabled: boolean;
  103278. /**
  103279. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  103280. */
  103281. intensity: number;
  103282. /**
  103283. * Defines if the effect is along the tangents, bitangents or in between.
  103284. * By default, the effect is "strectching" the highlights along the tangents.
  103285. */
  103286. direction: Vector2;
  103287. private _texture;
  103288. /**
  103289. * Stores the anisotropy values in a texture.
  103290. * rg is direction (like normal from -1 to 1)
  103291. * b is a intensity
  103292. */
  103293. texture: Nullable<BaseTexture>;
  103294. /** @hidden */
  103295. private _internalMarkAllSubMeshesAsTexturesDirty;
  103296. /** @hidden */
  103297. _markAllSubMeshesAsTexturesDirty(): void;
  103298. /**
  103299. * Instantiate a new istance of anisotropy configuration.
  103300. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103301. */
  103302. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103303. /**
  103304. * Specifies that the submesh is ready to be used.
  103305. * @param defines the list of "defines" to update.
  103306. * @param scene defines the scene the material belongs to.
  103307. * @returns - boolean indicating that the submesh is ready or not.
  103308. */
  103309. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  103310. /**
  103311. * Checks to see if a texture is used in the material.
  103312. * @param defines the list of "defines" to update.
  103313. * @param mesh the mesh we are preparing the defines for.
  103314. * @param scene defines the scene the material belongs to.
  103315. */
  103316. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  103317. /**
  103318. * Binds the material data.
  103319. * @param uniformBuffer defines the Uniform buffer to fill in.
  103320. * @param scene defines the scene the material belongs to.
  103321. * @param isFrozen defines wether the material is frozen or not.
  103322. */
  103323. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103324. /**
  103325. * Checks to see if a texture is used in the material.
  103326. * @param texture - Base texture to use.
  103327. * @returns - Boolean specifying if a texture is used in the material.
  103328. */
  103329. hasTexture(texture: BaseTexture): boolean;
  103330. /**
  103331. * Returns an array of the actively used textures.
  103332. * @param activeTextures Array of BaseTextures
  103333. */
  103334. getActiveTextures(activeTextures: BaseTexture[]): void;
  103335. /**
  103336. * Returns the animatable textures.
  103337. * @param animatables Array of animatable textures.
  103338. */
  103339. getAnimatables(animatables: IAnimatable[]): void;
  103340. /**
  103341. * Disposes the resources of the material.
  103342. * @param forceDisposeTextures - Forces the disposal of all textures.
  103343. */
  103344. dispose(forceDisposeTextures?: boolean): void;
  103345. /**
  103346. * Get the current class name of the texture useful for serialization or dynamic coding.
  103347. * @returns "PBRAnisotropicConfiguration"
  103348. */
  103349. getClassName(): string;
  103350. /**
  103351. * Add fallbacks to the effect fallbacks list.
  103352. * @param defines defines the Base texture to use.
  103353. * @param fallbacks defines the current fallback list.
  103354. * @param currentRank defines the current fallback rank.
  103355. * @returns the new fallback rank.
  103356. */
  103357. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103358. /**
  103359. * Add the required uniforms to the current list.
  103360. * @param uniforms defines the current uniform list.
  103361. */
  103362. static AddUniforms(uniforms: string[]): void;
  103363. /**
  103364. * Add the required uniforms to the current buffer.
  103365. * @param uniformBuffer defines the current uniform buffer.
  103366. */
  103367. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103368. /**
  103369. * Add the required samplers to the current list.
  103370. * @param samplers defines the current sampler list.
  103371. */
  103372. static AddSamplers(samplers: string[]): void;
  103373. /**
  103374. * Makes a duplicate of the current configuration into another one.
  103375. * @param anisotropicConfiguration define the config where to copy the info
  103376. */
  103377. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  103378. /**
  103379. * Serializes this anisotropy configuration.
  103380. * @returns - An object with the serialized config.
  103381. */
  103382. serialize(): any;
  103383. /**
  103384. * Parses a anisotropy Configuration from a serialized object.
  103385. * @param source - Serialized object.
  103386. */
  103387. parse(source: any): void;
  103388. }
  103389. }
  103390. declare module BABYLON {
  103391. /**
  103392. * @hidden
  103393. */
  103394. export interface IMaterialBRDFDefines {
  103395. BRDF_V_HEIGHT_CORRELATED: boolean;
  103396. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103397. /** @hidden */
  103398. _areMiscDirty: boolean;
  103399. }
  103400. /**
  103401. * Define the code related to the BRDF parameters of the pbr material.
  103402. */
  103403. export class PBRBRDFConfiguration {
  103404. /**
  103405. * Default value used for the energy conservation.
  103406. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103407. */
  103408. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103409. /**
  103410. * Default value used for the Smith Visibility Height Correlated mode.
  103411. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103412. */
  103413. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103414. private _useEnergyConservation;
  103415. /**
  103416. * Defines if the material uses energy conservation.
  103417. */
  103418. useEnergyConservation: boolean;
  103419. private _useSmithVisibilityHeightCorrelated;
  103420. /**
  103421. * LEGACY Mode set to false
  103422. * Defines if the material uses height smith correlated visibility term.
  103423. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103424. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103425. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103426. * Not relying on height correlated will also disable energy conservation.
  103427. */
  103428. useSmithVisibilityHeightCorrelated: boolean;
  103429. /** @hidden */
  103430. private _internalMarkAllSubMeshesAsMiscDirty;
  103431. /** @hidden */
  103432. _markAllSubMeshesAsMiscDirty(): void;
  103433. /**
  103434. * Instantiate a new istance of clear coat configuration.
  103435. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103436. */
  103437. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103438. /**
  103439. * Checks to see if a texture is used in the material.
  103440. * @param defines the list of "defines" to update.
  103441. */
  103442. prepareDefines(defines: IMaterialBRDFDefines): void;
  103443. /**
  103444. * Get the current class name of the texture useful for serialization or dynamic coding.
  103445. * @returns "PBRClearCoatConfiguration"
  103446. */
  103447. getClassName(): string;
  103448. /**
  103449. * Makes a duplicate of the current configuration into another one.
  103450. * @param brdfConfiguration define the config where to copy the info
  103451. */
  103452. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103453. /**
  103454. * Serializes this BRDF configuration.
  103455. * @returns - An object with the serialized config.
  103456. */
  103457. serialize(): any;
  103458. /**
  103459. * Parses a BRDF Configuration from a serialized object.
  103460. * @param source - Serialized object.
  103461. */
  103462. parse(source: any): void;
  103463. }
  103464. }
  103465. declare module BABYLON {
  103466. /**
  103467. * @hidden
  103468. */
  103469. export interface IMaterialSheenDefines {
  103470. SHEEN: boolean;
  103471. SHEEN_TEXTURE: boolean;
  103472. SHEEN_TEXTUREDIRECTUV: number;
  103473. SHEEN_LINKWITHALBEDO: boolean;
  103474. /** @hidden */
  103475. _areTexturesDirty: boolean;
  103476. }
  103477. /**
  103478. * Define the code related to the Sheen parameters of the pbr material.
  103479. */
  103480. export class PBRSheenConfiguration {
  103481. private _isEnabled;
  103482. /**
  103483. * Defines if the material uses sheen.
  103484. */
  103485. isEnabled: boolean;
  103486. private _linkSheenWithAlbedo;
  103487. /**
  103488. * Defines if the sheen is linked to the sheen color.
  103489. */
  103490. linkSheenWithAlbedo: boolean;
  103491. /**
  103492. * Defines the sheen intensity.
  103493. */
  103494. intensity: number;
  103495. /**
  103496. * Defines the sheen color.
  103497. */
  103498. color: Color3;
  103499. private _texture;
  103500. /**
  103501. * Stores the sheen tint values in a texture.
  103502. * rgb is tint
  103503. * a is a intensity
  103504. */
  103505. texture: Nullable<BaseTexture>;
  103506. /** @hidden */
  103507. private _internalMarkAllSubMeshesAsTexturesDirty;
  103508. /** @hidden */
  103509. _markAllSubMeshesAsTexturesDirty(): void;
  103510. /**
  103511. * Instantiate a new istance of clear coat configuration.
  103512. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103513. */
  103514. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103515. /**
  103516. * Specifies that the submesh is ready to be used.
  103517. * @param defines the list of "defines" to update.
  103518. * @param scene defines the scene the material belongs to.
  103519. * @returns - boolean indicating that the submesh is ready or not.
  103520. */
  103521. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  103522. /**
  103523. * Checks to see if a texture is used in the material.
  103524. * @param defines the list of "defines" to update.
  103525. * @param scene defines the scene the material belongs to.
  103526. */
  103527. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  103528. /**
  103529. * Binds the material data.
  103530. * @param uniformBuffer defines the Uniform buffer to fill in.
  103531. * @param scene defines the scene the material belongs to.
  103532. * @param isFrozen defines wether the material is frozen or not.
  103533. */
  103534. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103535. /**
  103536. * Checks to see if a texture is used in the material.
  103537. * @param texture - Base texture to use.
  103538. * @returns - Boolean specifying if a texture is used in the material.
  103539. */
  103540. hasTexture(texture: BaseTexture): boolean;
  103541. /**
  103542. * Returns an array of the actively used textures.
  103543. * @param activeTextures Array of BaseTextures
  103544. */
  103545. getActiveTextures(activeTextures: BaseTexture[]): void;
  103546. /**
  103547. * Returns the animatable textures.
  103548. * @param animatables Array of animatable textures.
  103549. */
  103550. getAnimatables(animatables: IAnimatable[]): void;
  103551. /**
  103552. * Disposes the resources of the material.
  103553. * @param forceDisposeTextures - Forces the disposal of all textures.
  103554. */
  103555. dispose(forceDisposeTextures?: boolean): void;
  103556. /**
  103557. * Get the current class name of the texture useful for serialization or dynamic coding.
  103558. * @returns "PBRSheenConfiguration"
  103559. */
  103560. getClassName(): string;
  103561. /**
  103562. * Add fallbacks to the effect fallbacks list.
  103563. * @param defines defines the Base texture to use.
  103564. * @param fallbacks defines the current fallback list.
  103565. * @param currentRank defines the current fallback rank.
  103566. * @returns the new fallback rank.
  103567. */
  103568. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103569. /**
  103570. * Add the required uniforms to the current list.
  103571. * @param uniforms defines the current uniform list.
  103572. */
  103573. static AddUniforms(uniforms: string[]): void;
  103574. /**
  103575. * Add the required uniforms to the current buffer.
  103576. * @param uniformBuffer defines the current uniform buffer.
  103577. */
  103578. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103579. /**
  103580. * Add the required samplers to the current list.
  103581. * @param samplers defines the current sampler list.
  103582. */
  103583. static AddSamplers(samplers: string[]): void;
  103584. /**
  103585. * Makes a duplicate of the current configuration into another one.
  103586. * @param sheenConfiguration define the config where to copy the info
  103587. */
  103588. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  103589. /**
  103590. * Serializes this BRDF configuration.
  103591. * @returns - An object with the serialized config.
  103592. */
  103593. serialize(): any;
  103594. /**
  103595. * Parses a Sheen Configuration from a serialized object.
  103596. * @param source - Serialized object.
  103597. */
  103598. parse(source: any): void;
  103599. }
  103600. }
  103601. declare module BABYLON {
  103602. /**
  103603. * @hidden
  103604. */
  103605. export interface IMaterialSubSurfaceDefines {
  103606. SUBSURFACE: boolean;
  103607. SS_REFRACTION: boolean;
  103608. SS_TRANSLUCENCY: boolean;
  103609. SS_SCATERRING: boolean;
  103610. SS_THICKNESSANDMASK_TEXTURE: boolean;
  103611. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  103612. SS_REFRACTIONMAP_3D: boolean;
  103613. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  103614. SS_LODINREFRACTIONALPHA: boolean;
  103615. SS_GAMMAREFRACTION: boolean;
  103616. SS_RGBDREFRACTION: boolean;
  103617. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  103618. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  103619. /** @hidden */
  103620. _areTexturesDirty: boolean;
  103621. }
  103622. /**
  103623. * Define the code related to the sub surface parameters of the pbr material.
  103624. */
  103625. export class PBRSubSurfaceConfiguration {
  103626. private _isRefractionEnabled;
  103627. /**
  103628. * Defines if the refraction is enabled in the material.
  103629. */
  103630. isRefractionEnabled: boolean;
  103631. private _isTranslucencyEnabled;
  103632. /**
  103633. * Defines if the translucency is enabled in the material.
  103634. */
  103635. isTranslucencyEnabled: boolean;
  103636. private _isScatteringEnabled;
  103637. /**
  103638. * Defines the refraction intensity of the material.
  103639. * The refraction when enabled replaces the Diffuse part of the material.
  103640. * The intensity helps transitionning between diffuse and refraction.
  103641. */
  103642. refractionIntensity: number;
  103643. /**
  103644. * Defines the translucency intensity of the material.
  103645. * When translucency has been enabled, this defines how much of the "translucency"
  103646. * is addded to the diffuse part of the material.
  103647. */
  103648. translucencyIntensity: number;
  103649. /**
  103650. * Defines the scattering intensity of the material.
  103651. * When scattering has been enabled, this defines how much of the "scattered light"
  103652. * is addded to the diffuse part of the material.
  103653. */
  103654. scatteringIntensity: number;
  103655. private _thicknessTexture;
  103656. /**
  103657. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  103658. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  103659. * 0 would mean minimumThickness
  103660. * 1 would mean maximumThickness
  103661. * The other channels might be use as a mask to vary the different effects intensity.
  103662. */
  103663. thicknessTexture: Nullable<BaseTexture>;
  103664. private _refractionTexture;
  103665. /**
  103666. * Defines the texture to use for refraction.
  103667. */
  103668. refractionTexture: Nullable<BaseTexture>;
  103669. private _indexOfRefraction;
  103670. /**
  103671. * Defines the indice of refraction used in the material.
  103672. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103673. */
  103674. indexOfRefraction: number;
  103675. private _invertRefractionY;
  103676. /**
  103677. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103678. */
  103679. invertRefractionY: boolean;
  103680. private _linkRefractionWithTransparency;
  103681. /**
  103682. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103683. * Materials half opaque for instance using refraction could benefit from this control.
  103684. */
  103685. linkRefractionWithTransparency: boolean;
  103686. /**
  103687. * Defines the minimum thickness stored in the thickness map.
  103688. * If no thickness map is defined, this value will be used to simulate thickness.
  103689. */
  103690. minimumThickness: number;
  103691. /**
  103692. * Defines the maximum thickness stored in the thickness map.
  103693. */
  103694. maximumThickness: number;
  103695. /**
  103696. * Defines the volume tint of the material.
  103697. * This is used for both translucency and scattering.
  103698. */
  103699. tintColor: Color3;
  103700. /**
  103701. * Defines the distance at which the tint color should be found in the media.
  103702. * This is used for refraction only.
  103703. */
  103704. tintColorAtDistance: number;
  103705. /**
  103706. * Defines how far each channel transmit through the media.
  103707. * It is defined as a color to simplify it selection.
  103708. */
  103709. diffusionDistance: Color3;
  103710. private _useMaskFromThicknessTexture;
  103711. /**
  103712. * Stores the intensity of the different subsurface effects in the thickness texture.
  103713. * * the green channel is the translucency intensity.
  103714. * * the blue channel is the scattering intensity.
  103715. * * the alpha channel is the refraction intensity.
  103716. */
  103717. useMaskFromThicknessTexture: boolean;
  103718. /** @hidden */
  103719. private _internalMarkAllSubMeshesAsTexturesDirty;
  103720. /** @hidden */
  103721. _markAllSubMeshesAsTexturesDirty(): void;
  103722. /**
  103723. * Instantiate a new istance of sub surface configuration.
  103724. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103725. */
  103726. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103727. /**
  103728. * Gets wehter the submesh is ready to be used or not.
  103729. * @param defines the list of "defines" to update.
  103730. * @param scene defines the scene the material belongs to.
  103731. * @returns - boolean indicating that the submesh is ready or not.
  103732. */
  103733. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  103734. /**
  103735. * Checks to see if a texture is used in the material.
  103736. * @param defines the list of "defines" to update.
  103737. * @param scene defines the scene to the material belongs to.
  103738. */
  103739. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  103740. /**
  103741. * Binds the material data.
  103742. * @param uniformBuffer defines the Uniform buffer to fill in.
  103743. * @param scene defines the scene the material belongs to.
  103744. * @param engine defines the engine the material belongs to.
  103745. * @param isFrozen defines wether the material is frozen or not.
  103746. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  103747. */
  103748. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  103749. /**
  103750. * Unbinds the material from the mesh.
  103751. * @param activeEffect defines the effect that should be unbound from.
  103752. * @returns true if unbound, otherwise false
  103753. */
  103754. unbind(activeEffect: Effect): boolean;
  103755. /**
  103756. * Returns the texture used for refraction or null if none is used.
  103757. * @param scene defines the scene the material belongs to.
  103758. * @returns - Refraction texture if present. If no refraction texture and refraction
  103759. * is linked with transparency, returns environment texture. Otherwise, returns null.
  103760. */
  103761. private _getRefractionTexture;
  103762. /**
  103763. * Returns true if alpha blending should be disabled.
  103764. */
  103765. readonly disableAlphaBlending: boolean;
  103766. /**
  103767. * Fills the list of render target textures.
  103768. * @param renderTargets the list of render targets to update
  103769. */
  103770. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  103771. /**
  103772. * Checks to see if a texture is used in the material.
  103773. * @param texture - Base texture to use.
  103774. * @returns - Boolean specifying if a texture is used in the material.
  103775. */
  103776. hasTexture(texture: BaseTexture): boolean;
  103777. /**
  103778. * Gets a boolean indicating that current material needs to register RTT
  103779. * @returns true if this uses a render target otherwise false.
  103780. */
  103781. hasRenderTargetTextures(): boolean;
  103782. /**
  103783. * Returns an array of the actively used textures.
  103784. * @param activeTextures Array of BaseTextures
  103785. */
  103786. getActiveTextures(activeTextures: BaseTexture[]): void;
  103787. /**
  103788. * Returns the animatable textures.
  103789. * @param animatables Array of animatable textures.
  103790. */
  103791. getAnimatables(animatables: IAnimatable[]): void;
  103792. /**
  103793. * Disposes the resources of the material.
  103794. * @param forceDisposeTextures - Forces the disposal of all textures.
  103795. */
  103796. dispose(forceDisposeTextures?: boolean): void;
  103797. /**
  103798. * Get the current class name of the texture useful for serialization or dynamic coding.
  103799. * @returns "PBRSubSurfaceConfiguration"
  103800. */
  103801. getClassName(): string;
  103802. /**
  103803. * Add fallbacks to the effect fallbacks list.
  103804. * @param defines defines the Base texture to use.
  103805. * @param fallbacks defines the current fallback list.
  103806. * @param currentRank defines the current fallback rank.
  103807. * @returns the new fallback rank.
  103808. */
  103809. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103810. /**
  103811. * Add the required uniforms to the current list.
  103812. * @param uniforms defines the current uniform list.
  103813. */
  103814. static AddUniforms(uniforms: string[]): void;
  103815. /**
  103816. * Add the required samplers to the current list.
  103817. * @param samplers defines the current sampler list.
  103818. */
  103819. static AddSamplers(samplers: string[]): void;
  103820. /**
  103821. * Add the required uniforms to the current buffer.
  103822. * @param uniformBuffer defines the current uniform buffer.
  103823. */
  103824. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103825. /**
  103826. * Makes a duplicate of the current configuration into another one.
  103827. * @param configuration define the config where to copy the info
  103828. */
  103829. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  103830. /**
  103831. * Serializes this Sub Surface configuration.
  103832. * @returns - An object with the serialized config.
  103833. */
  103834. serialize(): any;
  103835. /**
  103836. * Parses a Sub Surface Configuration from a serialized object.
  103837. * @param source - Serialized object.
  103838. */
  103839. parse(source: any): void;
  103840. }
  103841. }
  103842. declare module BABYLON {
  103843. /** @hidden */
  103844. export var pbrFragmentDeclaration: {
  103845. name: string;
  103846. shader: string;
  103847. };
  103848. }
  103849. declare module BABYLON {
  103850. /** @hidden */
  103851. export var pbrUboDeclaration: {
  103852. name: string;
  103853. shader: string;
  103854. };
  103855. }
  103856. declare module BABYLON {
  103857. /** @hidden */
  103858. export var pbrFragmentExtraDeclaration: {
  103859. name: string;
  103860. shader: string;
  103861. };
  103862. }
  103863. declare module BABYLON {
  103864. /** @hidden */
  103865. export var pbrFragmentSamplersDeclaration: {
  103866. name: string;
  103867. shader: string;
  103868. };
  103869. }
  103870. declare module BABYLON {
  103871. /** @hidden */
  103872. export var pbrHelperFunctions: {
  103873. name: string;
  103874. shader: string;
  103875. };
  103876. }
  103877. declare module BABYLON {
  103878. /** @hidden */
  103879. export var harmonicsFunctions: {
  103880. name: string;
  103881. shader: string;
  103882. };
  103883. }
  103884. declare module BABYLON {
  103885. /** @hidden */
  103886. export var pbrDirectLightingSetupFunctions: {
  103887. name: string;
  103888. shader: string;
  103889. };
  103890. }
  103891. declare module BABYLON {
  103892. /** @hidden */
  103893. export var pbrDirectLightingFalloffFunctions: {
  103894. name: string;
  103895. shader: string;
  103896. };
  103897. }
  103898. declare module BABYLON {
  103899. /** @hidden */
  103900. export var pbrBRDFFunctions: {
  103901. name: string;
  103902. shader: string;
  103903. };
  103904. }
  103905. declare module BABYLON {
  103906. /** @hidden */
  103907. export var pbrDirectLightingFunctions: {
  103908. name: string;
  103909. shader: string;
  103910. };
  103911. }
  103912. declare module BABYLON {
  103913. /** @hidden */
  103914. export var pbrIBLFunctions: {
  103915. name: string;
  103916. shader: string;
  103917. };
  103918. }
  103919. declare module BABYLON {
  103920. /** @hidden */
  103921. export var pbrDebug: {
  103922. name: string;
  103923. shader: string;
  103924. };
  103925. }
  103926. declare module BABYLON {
  103927. /** @hidden */
  103928. export var pbrPixelShader: {
  103929. name: string;
  103930. shader: string;
  103931. };
  103932. }
  103933. declare module BABYLON {
  103934. /** @hidden */
  103935. export var pbrVertexDeclaration: {
  103936. name: string;
  103937. shader: string;
  103938. };
  103939. }
  103940. declare module BABYLON {
  103941. /** @hidden */
  103942. export var pbrVertexShader: {
  103943. name: string;
  103944. shader: string;
  103945. };
  103946. }
  103947. declare module BABYLON {
  103948. /**
  103949. * Manages the defines for the PBR Material.
  103950. * @hidden
  103951. */
  103952. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  103953. PBR: boolean;
  103954. MAINUV1: boolean;
  103955. MAINUV2: boolean;
  103956. UV1: boolean;
  103957. UV2: boolean;
  103958. ALBEDO: boolean;
  103959. ALBEDODIRECTUV: number;
  103960. VERTEXCOLOR: boolean;
  103961. AMBIENT: boolean;
  103962. AMBIENTDIRECTUV: number;
  103963. AMBIENTINGRAYSCALE: boolean;
  103964. OPACITY: boolean;
  103965. VERTEXALPHA: boolean;
  103966. OPACITYDIRECTUV: number;
  103967. OPACITYRGB: boolean;
  103968. ALPHATEST: boolean;
  103969. DEPTHPREPASS: boolean;
  103970. ALPHABLEND: boolean;
  103971. ALPHAFROMALBEDO: boolean;
  103972. ALPHATESTVALUE: string;
  103973. SPECULAROVERALPHA: boolean;
  103974. RADIANCEOVERALPHA: boolean;
  103975. ALPHAFRESNEL: boolean;
  103976. LINEARALPHAFRESNEL: boolean;
  103977. PREMULTIPLYALPHA: boolean;
  103978. EMISSIVE: boolean;
  103979. EMISSIVEDIRECTUV: number;
  103980. REFLECTIVITY: boolean;
  103981. REFLECTIVITYDIRECTUV: number;
  103982. SPECULARTERM: boolean;
  103983. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  103984. MICROSURFACEAUTOMATIC: boolean;
  103985. LODBASEDMICROSFURACE: boolean;
  103986. MICROSURFACEMAP: boolean;
  103987. MICROSURFACEMAPDIRECTUV: number;
  103988. METALLICWORKFLOW: boolean;
  103989. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  103990. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  103991. METALLNESSSTOREINMETALMAPBLUE: boolean;
  103992. AOSTOREINMETALMAPRED: boolean;
  103993. ENVIRONMENTBRDF: boolean;
  103994. ENVIRONMENTBRDF_RGBD: boolean;
  103995. NORMAL: boolean;
  103996. TANGENT: boolean;
  103997. BUMP: boolean;
  103998. BUMPDIRECTUV: number;
  103999. OBJECTSPACE_NORMALMAP: boolean;
  104000. PARALLAX: boolean;
  104001. PARALLAXOCCLUSION: boolean;
  104002. NORMALXYSCALE: boolean;
  104003. LIGHTMAP: boolean;
  104004. LIGHTMAPDIRECTUV: number;
  104005. USELIGHTMAPASSHADOWMAP: boolean;
  104006. GAMMALIGHTMAP: boolean;
  104007. REFLECTION: boolean;
  104008. REFLECTIONMAP_3D: boolean;
  104009. REFLECTIONMAP_SPHERICAL: boolean;
  104010. REFLECTIONMAP_PLANAR: boolean;
  104011. REFLECTIONMAP_CUBIC: boolean;
  104012. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104013. REFLECTIONMAP_PROJECTION: boolean;
  104014. REFLECTIONMAP_SKYBOX: boolean;
  104015. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104016. REFLECTIONMAP_EXPLICIT: boolean;
  104017. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104018. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104019. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104020. INVERTCUBICMAP: boolean;
  104021. USESPHERICALFROMREFLECTIONMAP: boolean;
  104022. USESPHERICALINVERTEX: boolean;
  104023. REFLECTIONMAP_OPPOSITEZ: boolean;
  104024. LODINREFLECTIONALPHA: boolean;
  104025. GAMMAREFLECTION: boolean;
  104026. RGBDREFLECTION: boolean;
  104027. RADIANCEOCCLUSION: boolean;
  104028. HORIZONOCCLUSION: boolean;
  104029. INSTANCES: boolean;
  104030. NUM_BONE_INFLUENCERS: number;
  104031. BonesPerMesh: number;
  104032. BONETEXTURE: boolean;
  104033. NONUNIFORMSCALING: boolean;
  104034. MORPHTARGETS: boolean;
  104035. MORPHTARGETS_NORMAL: boolean;
  104036. MORPHTARGETS_TANGENT: boolean;
  104037. NUM_MORPH_INFLUENCERS: number;
  104038. IMAGEPROCESSING: boolean;
  104039. VIGNETTE: boolean;
  104040. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104041. VIGNETTEBLENDMODEOPAQUE: boolean;
  104042. TONEMAPPING: boolean;
  104043. TONEMAPPING_ACES: boolean;
  104044. CONTRAST: boolean;
  104045. COLORCURVES: boolean;
  104046. COLORGRADING: boolean;
  104047. COLORGRADING3D: boolean;
  104048. SAMPLER3DGREENDEPTH: boolean;
  104049. SAMPLER3DBGRMAP: boolean;
  104050. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104051. EXPOSURE: boolean;
  104052. MULTIVIEW: boolean;
  104053. USEPHYSICALLIGHTFALLOFF: boolean;
  104054. USEGLTFLIGHTFALLOFF: boolean;
  104055. TWOSIDEDLIGHTING: boolean;
  104056. SHADOWFLOAT: boolean;
  104057. CLIPPLANE: boolean;
  104058. CLIPPLANE2: boolean;
  104059. CLIPPLANE3: boolean;
  104060. CLIPPLANE4: boolean;
  104061. POINTSIZE: boolean;
  104062. FOG: boolean;
  104063. LOGARITHMICDEPTH: boolean;
  104064. FORCENORMALFORWARD: boolean;
  104065. SPECULARAA: boolean;
  104066. CLEARCOAT: boolean;
  104067. CLEARCOAT_DEFAULTIOR: boolean;
  104068. CLEARCOAT_TEXTURE: boolean;
  104069. CLEARCOAT_TEXTUREDIRECTUV: number;
  104070. CLEARCOAT_BUMP: boolean;
  104071. CLEARCOAT_BUMPDIRECTUV: number;
  104072. CLEARCOAT_TINT: boolean;
  104073. CLEARCOAT_TINT_TEXTURE: boolean;
  104074. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104075. ANISOTROPIC: boolean;
  104076. ANISOTROPIC_TEXTURE: boolean;
  104077. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104078. BRDF_V_HEIGHT_CORRELATED: boolean;
  104079. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104080. SHEEN: boolean;
  104081. SHEEN_TEXTURE: boolean;
  104082. SHEEN_TEXTUREDIRECTUV: number;
  104083. SHEEN_LINKWITHALBEDO: boolean;
  104084. SUBSURFACE: boolean;
  104085. SS_REFRACTION: boolean;
  104086. SS_TRANSLUCENCY: boolean;
  104087. SS_SCATERRING: boolean;
  104088. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104089. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104090. SS_REFRACTIONMAP_3D: boolean;
  104091. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104092. SS_LODINREFRACTIONALPHA: boolean;
  104093. SS_GAMMAREFRACTION: boolean;
  104094. SS_RGBDREFRACTION: boolean;
  104095. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104096. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104097. UNLIT: boolean;
  104098. DEBUGMODE: number;
  104099. /**
  104100. * Initializes the PBR Material defines.
  104101. */
  104102. constructor();
  104103. /**
  104104. * Resets the PBR Material defines.
  104105. */
  104106. reset(): void;
  104107. }
  104108. /**
  104109. * The Physically based material base class of BJS.
  104110. *
  104111. * This offers the main features of a standard PBR material.
  104112. * For more information, please refer to the documentation :
  104113. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104114. */
  104115. export abstract class PBRBaseMaterial extends PushMaterial {
  104116. /**
  104117. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104118. */
  104119. static readonly PBRMATERIAL_OPAQUE: number;
  104120. /**
  104121. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104122. */
  104123. static readonly PBRMATERIAL_ALPHATEST: number;
  104124. /**
  104125. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104126. */
  104127. static readonly PBRMATERIAL_ALPHABLEND: number;
  104128. /**
  104129. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104130. * They are also discarded below the alpha cutoff threshold to improve performances.
  104131. */
  104132. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104133. /**
  104134. * Defines the default value of how much AO map is occluding the analytical lights
  104135. * (point spot...).
  104136. */
  104137. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104138. /**
  104139. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  104140. */
  104141. static readonly LIGHTFALLOFF_PHYSICAL: number;
  104142. /**
  104143. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  104144. * to enhance interoperability with other engines.
  104145. */
  104146. static readonly LIGHTFALLOFF_GLTF: number;
  104147. /**
  104148. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  104149. * to enhance interoperability with other materials.
  104150. */
  104151. static readonly LIGHTFALLOFF_STANDARD: number;
  104152. /**
  104153. * Intensity of the direct lights e.g. the four lights available in your scene.
  104154. * This impacts both the direct diffuse and specular highlights.
  104155. */
  104156. protected _directIntensity: number;
  104157. /**
  104158. * Intensity of the emissive part of the material.
  104159. * This helps controlling the emissive effect without modifying the emissive color.
  104160. */
  104161. protected _emissiveIntensity: number;
  104162. /**
  104163. * Intensity of the environment e.g. how much the environment will light the object
  104164. * either through harmonics for rough material or through the refelction for shiny ones.
  104165. */
  104166. protected _environmentIntensity: number;
  104167. /**
  104168. * This is a special control allowing the reduction of the specular highlights coming from the
  104169. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104170. */
  104171. protected _specularIntensity: number;
  104172. /**
  104173. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  104174. */
  104175. private _lightingInfos;
  104176. /**
  104177. * Debug Control allowing disabling the bump map on this material.
  104178. */
  104179. protected _disableBumpMap: boolean;
  104180. /**
  104181. * AKA Diffuse Texture in standard nomenclature.
  104182. */
  104183. protected _albedoTexture: BaseTexture;
  104184. /**
  104185. * AKA Occlusion Texture in other nomenclature.
  104186. */
  104187. protected _ambientTexture: BaseTexture;
  104188. /**
  104189. * AKA Occlusion Texture Intensity in other nomenclature.
  104190. */
  104191. protected _ambientTextureStrength: number;
  104192. /**
  104193. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104194. * 1 means it completely occludes it
  104195. * 0 mean it has no impact
  104196. */
  104197. protected _ambientTextureImpactOnAnalyticalLights: number;
  104198. /**
  104199. * Stores the alpha values in a texture.
  104200. */
  104201. protected _opacityTexture: BaseTexture;
  104202. /**
  104203. * Stores the reflection values in a texture.
  104204. */
  104205. protected _reflectionTexture: BaseTexture;
  104206. /**
  104207. * Stores the emissive values in a texture.
  104208. */
  104209. protected _emissiveTexture: BaseTexture;
  104210. /**
  104211. * AKA Specular texture in other nomenclature.
  104212. */
  104213. protected _reflectivityTexture: BaseTexture;
  104214. /**
  104215. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104216. */
  104217. protected _metallicTexture: BaseTexture;
  104218. /**
  104219. * Specifies the metallic scalar of the metallic/roughness workflow.
  104220. * Can also be used to scale the metalness values of the metallic texture.
  104221. */
  104222. protected _metallic: Nullable<number>;
  104223. /**
  104224. * Specifies the roughness scalar of the metallic/roughness workflow.
  104225. * Can also be used to scale the roughness values of the metallic texture.
  104226. */
  104227. protected _roughness: Nullable<number>;
  104228. /**
  104229. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104230. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104231. */
  104232. protected _microSurfaceTexture: BaseTexture;
  104233. /**
  104234. * Stores surface normal data used to displace a mesh in a texture.
  104235. */
  104236. protected _bumpTexture: BaseTexture;
  104237. /**
  104238. * Stores the pre-calculated light information of a mesh in a texture.
  104239. */
  104240. protected _lightmapTexture: BaseTexture;
  104241. /**
  104242. * The color of a material in ambient lighting.
  104243. */
  104244. protected _ambientColor: Color3;
  104245. /**
  104246. * AKA Diffuse Color in other nomenclature.
  104247. */
  104248. protected _albedoColor: Color3;
  104249. /**
  104250. * AKA Specular Color in other nomenclature.
  104251. */
  104252. protected _reflectivityColor: Color3;
  104253. /**
  104254. * The color applied when light is reflected from a material.
  104255. */
  104256. protected _reflectionColor: Color3;
  104257. /**
  104258. * The color applied when light is emitted from a material.
  104259. */
  104260. protected _emissiveColor: Color3;
  104261. /**
  104262. * AKA Glossiness in other nomenclature.
  104263. */
  104264. protected _microSurface: number;
  104265. /**
  104266. * Specifies that the material will use the light map as a show map.
  104267. */
  104268. protected _useLightmapAsShadowmap: boolean;
  104269. /**
  104270. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104271. * makes the reflect vector face the model (under horizon).
  104272. */
  104273. protected _useHorizonOcclusion: boolean;
  104274. /**
  104275. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104276. * too much the area relying on ambient texture to define their ambient occlusion.
  104277. */
  104278. protected _useRadianceOcclusion: boolean;
  104279. /**
  104280. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104281. */
  104282. protected _useAlphaFromAlbedoTexture: boolean;
  104283. /**
  104284. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  104285. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104286. */
  104287. protected _useSpecularOverAlpha: boolean;
  104288. /**
  104289. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104290. */
  104291. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104292. /**
  104293. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104294. */
  104295. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  104296. /**
  104297. * Specifies if the metallic texture contains the roughness information in its green channel.
  104298. */
  104299. protected _useRoughnessFromMetallicTextureGreen: boolean;
  104300. /**
  104301. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104302. */
  104303. protected _useMetallnessFromMetallicTextureBlue: boolean;
  104304. /**
  104305. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104306. */
  104307. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  104308. /**
  104309. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104310. */
  104311. protected _useAmbientInGrayScale: boolean;
  104312. /**
  104313. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104314. * The material will try to infer what glossiness each pixel should be.
  104315. */
  104316. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  104317. /**
  104318. * Defines the falloff type used in this material.
  104319. * It by default is Physical.
  104320. */
  104321. protected _lightFalloff: number;
  104322. /**
  104323. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104324. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104325. */
  104326. protected _useRadianceOverAlpha: boolean;
  104327. /**
  104328. * Allows using an object space normal map (instead of tangent space).
  104329. */
  104330. protected _useObjectSpaceNormalMap: boolean;
  104331. /**
  104332. * Allows using the bump map in parallax mode.
  104333. */
  104334. protected _useParallax: boolean;
  104335. /**
  104336. * Allows using the bump map in parallax occlusion mode.
  104337. */
  104338. protected _useParallaxOcclusion: boolean;
  104339. /**
  104340. * Controls the scale bias of the parallax mode.
  104341. */
  104342. protected _parallaxScaleBias: number;
  104343. /**
  104344. * If sets to true, disables all the lights affecting the material.
  104345. */
  104346. protected _disableLighting: boolean;
  104347. /**
  104348. * Number of Simultaneous lights allowed on the material.
  104349. */
  104350. protected _maxSimultaneousLights: number;
  104351. /**
  104352. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104353. */
  104354. protected _invertNormalMapX: boolean;
  104355. /**
  104356. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104357. */
  104358. protected _invertNormalMapY: boolean;
  104359. /**
  104360. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104361. */
  104362. protected _twoSidedLighting: boolean;
  104363. /**
  104364. * Defines the alpha limits in alpha test mode.
  104365. */
  104366. protected _alphaCutOff: number;
  104367. /**
  104368. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104369. */
  104370. protected _forceAlphaTest: boolean;
  104371. /**
  104372. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104373. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104374. */
  104375. protected _useAlphaFresnel: boolean;
  104376. /**
  104377. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104378. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104379. */
  104380. protected _useLinearAlphaFresnel: boolean;
  104381. /**
  104382. * The transparency mode of the material.
  104383. */
  104384. protected _transparencyMode: Nullable<number>;
  104385. /**
  104386. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  104387. * from cos thetav and roughness:
  104388. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  104389. */
  104390. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  104391. /**
  104392. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104393. */
  104394. protected _forceIrradianceInFragment: boolean;
  104395. /**
  104396. * Force normal to face away from face.
  104397. */
  104398. protected _forceNormalForward: boolean;
  104399. /**
  104400. * Enables specular anti aliasing in the PBR shader.
  104401. * It will both interacts on the Geometry for analytical and IBL lighting.
  104402. * It also prefilter the roughness map based on the bump values.
  104403. */
  104404. protected _enableSpecularAntiAliasing: boolean;
  104405. /**
  104406. * Default configuration related to image processing available in the PBR Material.
  104407. */
  104408. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104409. /**
  104410. * Keep track of the image processing observer to allow dispose and replace.
  104411. */
  104412. private _imageProcessingObserver;
  104413. /**
  104414. * Attaches a new image processing configuration to the PBR Material.
  104415. * @param configuration
  104416. */
  104417. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104418. /**
  104419. * Stores the available render targets.
  104420. */
  104421. private _renderTargets;
  104422. /**
  104423. * Sets the global ambient color for the material used in lighting calculations.
  104424. */
  104425. private _globalAmbientColor;
  104426. /**
  104427. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  104428. */
  104429. private _useLogarithmicDepth;
  104430. /**
  104431. * If set to true, no lighting calculations will be applied.
  104432. */
  104433. private _unlit;
  104434. private _debugMode;
  104435. /**
  104436. * @hidden
  104437. * This is reserved for the inspector.
  104438. * Defines the material debug mode.
  104439. * It helps seeing only some components of the material while troubleshooting.
  104440. */
  104441. debugMode: number;
  104442. /**
  104443. * @hidden
  104444. * This is reserved for the inspector.
  104445. * Specify from where on screen the debug mode should start.
  104446. * The value goes from -1 (full screen) to 1 (not visible)
  104447. * It helps with side by side comparison against the final render
  104448. * This defaults to -1
  104449. */
  104450. private debugLimit;
  104451. /**
  104452. * @hidden
  104453. * This is reserved for the inspector.
  104454. * As the default viewing range might not be enough (if the ambient is really small for instance)
  104455. * You can use the factor to better multiply the final value.
  104456. */
  104457. private debugFactor;
  104458. /**
  104459. * Defines the clear coat layer parameters for the material.
  104460. */
  104461. readonly clearCoat: PBRClearCoatConfiguration;
  104462. /**
  104463. * Defines the anisotropic parameters for the material.
  104464. */
  104465. readonly anisotropy: PBRAnisotropicConfiguration;
  104466. /**
  104467. * Defines the BRDF parameters for the material.
  104468. */
  104469. readonly brdf: PBRBRDFConfiguration;
  104470. /**
  104471. * Defines the Sheen parameters for the material.
  104472. */
  104473. readonly sheen: PBRSheenConfiguration;
  104474. /**
  104475. * Defines the SubSurface parameters for the material.
  104476. */
  104477. readonly subSurface: PBRSubSurfaceConfiguration;
  104478. /**
  104479. * Custom callback helping to override the default shader used in the material.
  104480. */
  104481. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  104482. /**
  104483. * Instantiates a new PBRMaterial instance.
  104484. *
  104485. * @param name The material name
  104486. * @param scene The scene the material will be use in.
  104487. */
  104488. constructor(name: string, scene: Scene);
  104489. /**
  104490. * Gets a boolean indicating that current material needs to register RTT
  104491. */
  104492. readonly hasRenderTargetTextures: boolean;
  104493. /**
  104494. * Gets the name of the material class.
  104495. */
  104496. getClassName(): string;
  104497. /**
  104498. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104499. */
  104500. /**
  104501. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104502. */
  104503. useLogarithmicDepth: boolean;
  104504. /**
  104505. * Gets the current transparency mode.
  104506. */
  104507. /**
  104508. * Sets the transparency mode of the material.
  104509. *
  104510. * | Value | Type | Description |
  104511. * | ----- | ----------------------------------- | ----------- |
  104512. * | 0 | OPAQUE | |
  104513. * | 1 | ALPHATEST | |
  104514. * | 2 | ALPHABLEND | |
  104515. * | 3 | ALPHATESTANDBLEND | |
  104516. *
  104517. */
  104518. transparencyMode: Nullable<number>;
  104519. /**
  104520. * Returns true if alpha blending should be disabled.
  104521. */
  104522. private readonly _disableAlphaBlending;
  104523. /**
  104524. * Specifies whether or not this material should be rendered in alpha blend mode.
  104525. */
  104526. needAlphaBlending(): boolean;
  104527. /**
  104528. * Specifies if the mesh will require alpha blending.
  104529. * @param mesh - BJS mesh.
  104530. */
  104531. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104532. /**
  104533. * Specifies whether or not this material should be rendered in alpha test mode.
  104534. */
  104535. needAlphaTesting(): boolean;
  104536. /**
  104537. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  104538. */
  104539. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  104540. /**
  104541. * Gets the texture used for the alpha test.
  104542. */
  104543. getAlphaTestTexture(): BaseTexture;
  104544. /**
  104545. * Specifies that the submesh is ready to be used.
  104546. * @param mesh - BJS mesh.
  104547. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  104548. * @param useInstances - Specifies that instances should be used.
  104549. * @returns - boolean indicating that the submesh is ready or not.
  104550. */
  104551. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104552. /**
  104553. * Specifies if the material uses metallic roughness workflow.
  104554. * @returns boolean specifiying if the material uses metallic roughness workflow.
  104555. */
  104556. isMetallicWorkflow(): boolean;
  104557. private _prepareEffect;
  104558. private _prepareDefines;
  104559. /**
  104560. * Force shader compilation
  104561. */
  104562. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  104563. clipPlane: boolean;
  104564. }>): void;
  104565. /**
  104566. * Initializes the uniform buffer layout for the shader.
  104567. */
  104568. buildUniformLayout(): void;
  104569. /**
  104570. * Unbinds the material from the mesh
  104571. */
  104572. unbind(): void;
  104573. /**
  104574. * Binds the submesh data.
  104575. * @param world - The world matrix.
  104576. * @param mesh - The BJS mesh.
  104577. * @param subMesh - A submesh of the BJS mesh.
  104578. */
  104579. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104580. /**
  104581. * Returns the animatable textures.
  104582. * @returns - Array of animatable textures.
  104583. */
  104584. getAnimatables(): IAnimatable[];
  104585. /**
  104586. * Returns the texture used for reflections.
  104587. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  104588. */
  104589. private _getReflectionTexture;
  104590. /**
  104591. * Returns an array of the actively used textures.
  104592. * @returns - Array of BaseTextures
  104593. */
  104594. getActiveTextures(): BaseTexture[];
  104595. /**
  104596. * Checks to see if a texture is used in the material.
  104597. * @param texture - Base texture to use.
  104598. * @returns - Boolean specifying if a texture is used in the material.
  104599. */
  104600. hasTexture(texture: BaseTexture): boolean;
  104601. /**
  104602. * Disposes the resources of the material.
  104603. * @param forceDisposeEffect - Forces the disposal of effects.
  104604. * @param forceDisposeTextures - Forces the disposal of all textures.
  104605. */
  104606. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104607. }
  104608. }
  104609. declare module BABYLON {
  104610. /**
  104611. * The Physically based material of BJS.
  104612. *
  104613. * This offers the main features of a standard PBR material.
  104614. * For more information, please refer to the documentation :
  104615. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104616. */
  104617. export class PBRMaterial extends PBRBaseMaterial {
  104618. /**
  104619. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104620. */
  104621. static readonly PBRMATERIAL_OPAQUE: number;
  104622. /**
  104623. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104624. */
  104625. static readonly PBRMATERIAL_ALPHATEST: number;
  104626. /**
  104627. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104628. */
  104629. static readonly PBRMATERIAL_ALPHABLEND: number;
  104630. /**
  104631. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104632. * They are also discarded below the alpha cutoff threshold to improve performances.
  104633. */
  104634. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104635. /**
  104636. * Defines the default value of how much AO map is occluding the analytical lights
  104637. * (point spot...).
  104638. */
  104639. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104640. /**
  104641. * Intensity of the direct lights e.g. the four lights available in your scene.
  104642. * This impacts both the direct diffuse and specular highlights.
  104643. */
  104644. directIntensity: number;
  104645. /**
  104646. * Intensity of the emissive part of the material.
  104647. * This helps controlling the emissive effect without modifying the emissive color.
  104648. */
  104649. emissiveIntensity: number;
  104650. /**
  104651. * Intensity of the environment e.g. how much the environment will light the object
  104652. * either through harmonics for rough material or through the refelction for shiny ones.
  104653. */
  104654. environmentIntensity: number;
  104655. /**
  104656. * This is a special control allowing the reduction of the specular highlights coming from the
  104657. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104658. */
  104659. specularIntensity: number;
  104660. /**
  104661. * Debug Control allowing disabling the bump map on this material.
  104662. */
  104663. disableBumpMap: boolean;
  104664. /**
  104665. * AKA Diffuse Texture in standard nomenclature.
  104666. */
  104667. albedoTexture: BaseTexture;
  104668. /**
  104669. * AKA Occlusion Texture in other nomenclature.
  104670. */
  104671. ambientTexture: BaseTexture;
  104672. /**
  104673. * AKA Occlusion Texture Intensity in other nomenclature.
  104674. */
  104675. ambientTextureStrength: number;
  104676. /**
  104677. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104678. * 1 means it completely occludes it
  104679. * 0 mean it has no impact
  104680. */
  104681. ambientTextureImpactOnAnalyticalLights: number;
  104682. /**
  104683. * Stores the alpha values in a texture.
  104684. */
  104685. opacityTexture: BaseTexture;
  104686. /**
  104687. * Stores the reflection values in a texture.
  104688. */
  104689. reflectionTexture: Nullable<BaseTexture>;
  104690. /**
  104691. * Stores the emissive values in a texture.
  104692. */
  104693. emissiveTexture: BaseTexture;
  104694. /**
  104695. * AKA Specular texture in other nomenclature.
  104696. */
  104697. reflectivityTexture: BaseTexture;
  104698. /**
  104699. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104700. */
  104701. metallicTexture: BaseTexture;
  104702. /**
  104703. * Specifies the metallic scalar of the metallic/roughness workflow.
  104704. * Can also be used to scale the metalness values of the metallic texture.
  104705. */
  104706. metallic: Nullable<number>;
  104707. /**
  104708. * Specifies the roughness scalar of the metallic/roughness workflow.
  104709. * Can also be used to scale the roughness values of the metallic texture.
  104710. */
  104711. roughness: Nullable<number>;
  104712. /**
  104713. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104714. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104715. */
  104716. microSurfaceTexture: BaseTexture;
  104717. /**
  104718. * Stores surface normal data used to displace a mesh in a texture.
  104719. */
  104720. bumpTexture: BaseTexture;
  104721. /**
  104722. * Stores the pre-calculated light information of a mesh in a texture.
  104723. */
  104724. lightmapTexture: BaseTexture;
  104725. /**
  104726. * Stores the refracted light information in a texture.
  104727. */
  104728. refractionTexture: Nullable<BaseTexture>;
  104729. /**
  104730. * The color of a material in ambient lighting.
  104731. */
  104732. ambientColor: Color3;
  104733. /**
  104734. * AKA Diffuse Color in other nomenclature.
  104735. */
  104736. albedoColor: Color3;
  104737. /**
  104738. * AKA Specular Color in other nomenclature.
  104739. */
  104740. reflectivityColor: Color3;
  104741. /**
  104742. * The color reflected from the material.
  104743. */
  104744. reflectionColor: Color3;
  104745. /**
  104746. * The color emitted from the material.
  104747. */
  104748. emissiveColor: Color3;
  104749. /**
  104750. * AKA Glossiness in other nomenclature.
  104751. */
  104752. microSurface: number;
  104753. /**
  104754. * source material index of refraction (IOR)' / 'destination material IOR.
  104755. */
  104756. indexOfRefraction: number;
  104757. /**
  104758. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104759. */
  104760. invertRefractionY: boolean;
  104761. /**
  104762. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104763. * Materials half opaque for instance using refraction could benefit from this control.
  104764. */
  104765. linkRefractionWithTransparency: boolean;
  104766. /**
  104767. * If true, the light map contains occlusion information instead of lighting info.
  104768. */
  104769. useLightmapAsShadowmap: boolean;
  104770. /**
  104771. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104772. */
  104773. useAlphaFromAlbedoTexture: boolean;
  104774. /**
  104775. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104776. */
  104777. forceAlphaTest: boolean;
  104778. /**
  104779. * Defines the alpha limits in alpha test mode.
  104780. */
  104781. alphaCutOff: number;
  104782. /**
  104783. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104784. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104785. */
  104786. useSpecularOverAlpha: boolean;
  104787. /**
  104788. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104789. */
  104790. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104791. /**
  104792. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104793. */
  104794. useRoughnessFromMetallicTextureAlpha: boolean;
  104795. /**
  104796. * Specifies if the metallic texture contains the roughness information in its green channel.
  104797. */
  104798. useRoughnessFromMetallicTextureGreen: boolean;
  104799. /**
  104800. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104801. */
  104802. useMetallnessFromMetallicTextureBlue: boolean;
  104803. /**
  104804. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104805. */
  104806. useAmbientOcclusionFromMetallicTextureRed: boolean;
  104807. /**
  104808. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104809. */
  104810. useAmbientInGrayScale: boolean;
  104811. /**
  104812. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104813. * The material will try to infer what glossiness each pixel should be.
  104814. */
  104815. useAutoMicroSurfaceFromReflectivityMap: boolean;
  104816. /**
  104817. * BJS is using an harcoded light falloff based on a manually sets up range.
  104818. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104819. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104820. */
  104821. /**
  104822. * BJS is using an harcoded light falloff based on a manually sets up range.
  104823. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104824. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104825. */
  104826. usePhysicalLightFalloff: boolean;
  104827. /**
  104828. * In order to support the falloff compatibility with gltf, a special mode has been added
  104829. * to reproduce the gltf light falloff.
  104830. */
  104831. /**
  104832. * In order to support the falloff compatibility with gltf, a special mode has been added
  104833. * to reproduce the gltf light falloff.
  104834. */
  104835. useGLTFLightFalloff: boolean;
  104836. /**
  104837. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104838. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104839. */
  104840. useRadianceOverAlpha: boolean;
  104841. /**
  104842. * Allows using an object space normal map (instead of tangent space).
  104843. */
  104844. useObjectSpaceNormalMap: boolean;
  104845. /**
  104846. * Allows using the bump map in parallax mode.
  104847. */
  104848. useParallax: boolean;
  104849. /**
  104850. * Allows using the bump map in parallax occlusion mode.
  104851. */
  104852. useParallaxOcclusion: boolean;
  104853. /**
  104854. * Controls the scale bias of the parallax mode.
  104855. */
  104856. parallaxScaleBias: number;
  104857. /**
  104858. * If sets to true, disables all the lights affecting the material.
  104859. */
  104860. disableLighting: boolean;
  104861. /**
  104862. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104863. */
  104864. forceIrradianceInFragment: boolean;
  104865. /**
  104866. * Number of Simultaneous lights allowed on the material.
  104867. */
  104868. maxSimultaneousLights: number;
  104869. /**
  104870. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104871. */
  104872. invertNormalMapX: boolean;
  104873. /**
  104874. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104875. */
  104876. invertNormalMapY: boolean;
  104877. /**
  104878. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104879. */
  104880. twoSidedLighting: boolean;
  104881. /**
  104882. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104883. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104884. */
  104885. useAlphaFresnel: boolean;
  104886. /**
  104887. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104888. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104889. */
  104890. useLinearAlphaFresnel: boolean;
  104891. /**
  104892. * Let user defines the brdf lookup texture used for IBL.
  104893. * A default 8bit version is embedded but you could point at :
  104894. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  104895. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  104896. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104897. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  104898. */
  104899. environmentBRDFTexture: Nullable<BaseTexture>;
  104900. /**
  104901. * Force normal to face away from face.
  104902. */
  104903. forceNormalForward: boolean;
  104904. /**
  104905. * Enables specular anti aliasing in the PBR shader.
  104906. * It will both interacts on the Geometry for analytical and IBL lighting.
  104907. * It also prefilter the roughness map based on the bump values.
  104908. */
  104909. enableSpecularAntiAliasing: boolean;
  104910. /**
  104911. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104912. * makes the reflect vector face the model (under horizon).
  104913. */
  104914. useHorizonOcclusion: boolean;
  104915. /**
  104916. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104917. * too much the area relying on ambient texture to define their ambient occlusion.
  104918. */
  104919. useRadianceOcclusion: boolean;
  104920. /**
  104921. * If set to true, no lighting calculations will be applied.
  104922. */
  104923. unlit: boolean;
  104924. /**
  104925. * Gets the image processing configuration used either in this material.
  104926. */
  104927. /**
  104928. * Sets the Default image processing configuration used either in the this material.
  104929. *
  104930. * If sets to null, the scene one is in use.
  104931. */
  104932. imageProcessingConfiguration: ImageProcessingConfiguration;
  104933. /**
  104934. * Gets wether the color curves effect is enabled.
  104935. */
  104936. /**
  104937. * Sets wether the color curves effect is enabled.
  104938. */
  104939. cameraColorCurvesEnabled: boolean;
  104940. /**
  104941. * Gets wether the color grading effect is enabled.
  104942. */
  104943. /**
  104944. * Gets wether the color grading effect is enabled.
  104945. */
  104946. cameraColorGradingEnabled: boolean;
  104947. /**
  104948. * Gets wether tonemapping is enabled or not.
  104949. */
  104950. /**
  104951. * Sets wether tonemapping is enabled or not
  104952. */
  104953. cameraToneMappingEnabled: boolean;
  104954. /**
  104955. * The camera exposure used on this material.
  104956. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104957. * This corresponds to a photographic exposure.
  104958. */
  104959. /**
  104960. * The camera exposure used on this material.
  104961. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104962. * This corresponds to a photographic exposure.
  104963. */
  104964. cameraExposure: number;
  104965. /**
  104966. * Gets The camera contrast used on this material.
  104967. */
  104968. /**
  104969. * Sets The camera contrast used on this material.
  104970. */
  104971. cameraContrast: number;
  104972. /**
  104973. * Gets the Color Grading 2D Lookup Texture.
  104974. */
  104975. /**
  104976. * Sets the Color Grading 2D Lookup Texture.
  104977. */
  104978. cameraColorGradingTexture: Nullable<BaseTexture>;
  104979. /**
  104980. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104981. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104982. * 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;
  104983. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104984. */
  104985. /**
  104986. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104987. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104988. * 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;
  104989. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104990. */
  104991. cameraColorCurves: Nullable<ColorCurves>;
  104992. /**
  104993. * Instantiates a new PBRMaterial instance.
  104994. *
  104995. * @param name The material name
  104996. * @param scene The scene the material will be use in.
  104997. */
  104998. constructor(name: string, scene: Scene);
  104999. /**
  105000. * Returns the name of this material class.
  105001. */
  105002. getClassName(): string;
  105003. /**
  105004. * Makes a duplicate of the current material.
  105005. * @param name - name to use for the new material.
  105006. */
  105007. clone(name: string): PBRMaterial;
  105008. /**
  105009. * Serializes this PBR Material.
  105010. * @returns - An object with the serialized material.
  105011. */
  105012. serialize(): any;
  105013. /**
  105014. * Parses a PBR Material from a serialized object.
  105015. * @param source - Serialized object.
  105016. * @param scene - BJS scene instance.
  105017. * @param rootUrl - url for the scene object
  105018. * @returns - PBRMaterial
  105019. */
  105020. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105021. }
  105022. }
  105023. declare module BABYLON {
  105024. /**
  105025. * Direct draw surface info
  105026. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105027. */
  105028. export interface DDSInfo {
  105029. /**
  105030. * Width of the texture
  105031. */
  105032. width: number;
  105033. /**
  105034. * Width of the texture
  105035. */
  105036. height: number;
  105037. /**
  105038. * Number of Mipmaps for the texture
  105039. * @see https://en.wikipedia.org/wiki/Mipmap
  105040. */
  105041. mipmapCount: number;
  105042. /**
  105043. * If the textures format is a known fourCC format
  105044. * @see https://www.fourcc.org/
  105045. */
  105046. isFourCC: boolean;
  105047. /**
  105048. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105049. */
  105050. isRGB: boolean;
  105051. /**
  105052. * If the texture is a lumincance format
  105053. */
  105054. isLuminance: boolean;
  105055. /**
  105056. * If this is a cube texture
  105057. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105058. */
  105059. isCube: boolean;
  105060. /**
  105061. * If the texture is a compressed format eg. FOURCC_DXT1
  105062. */
  105063. isCompressed: boolean;
  105064. /**
  105065. * The dxgiFormat of the texture
  105066. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105067. */
  105068. dxgiFormat: number;
  105069. /**
  105070. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105071. */
  105072. textureType: number;
  105073. /**
  105074. * Sphericle polynomial created for the dds texture
  105075. */
  105076. sphericalPolynomial?: SphericalPolynomial;
  105077. }
  105078. /**
  105079. * Class used to provide DDS decompression tools
  105080. */
  105081. export class DDSTools {
  105082. /**
  105083. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105084. */
  105085. static StoreLODInAlphaChannel: boolean;
  105086. /**
  105087. * Gets DDS information from an array buffer
  105088. * @param arrayBuffer defines the array buffer to read data from
  105089. * @returns the DDS information
  105090. */
  105091. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105092. private static _FloatView;
  105093. private static _Int32View;
  105094. private static _ToHalfFloat;
  105095. private static _FromHalfFloat;
  105096. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105097. private static _GetHalfFloatRGBAArrayBuffer;
  105098. private static _GetFloatRGBAArrayBuffer;
  105099. private static _GetFloatAsUIntRGBAArrayBuffer;
  105100. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105101. private static _GetRGBAArrayBuffer;
  105102. private static _ExtractLongWordOrder;
  105103. private static _GetRGBArrayBuffer;
  105104. private static _GetLuminanceArrayBuffer;
  105105. /**
  105106. * Uploads DDS Levels to a Babylon Texture
  105107. * @hidden
  105108. */
  105109. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105110. }
  105111. interface Engine {
  105112. /**
  105113. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105114. * @param rootUrl defines the url where the file to load is located
  105115. * @param scene defines the current scene
  105116. * @param lodScale defines scale to apply to the mip map selection
  105117. * @param lodOffset defines offset to apply to the mip map selection
  105118. * @param onLoad defines an optional callback raised when the texture is loaded
  105119. * @param onError defines an optional callback raised if there is an issue to load the texture
  105120. * @param format defines the format of the data
  105121. * @param forcedExtension defines the extension to use to pick the right loader
  105122. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105123. * @returns the cube texture as an InternalTexture
  105124. */
  105125. 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;
  105126. }
  105127. }
  105128. declare module BABYLON {
  105129. /**
  105130. * Implementation of the DDS Texture Loader.
  105131. * @hidden
  105132. */
  105133. export class _DDSTextureLoader implements IInternalTextureLoader {
  105134. /**
  105135. * Defines wether the loader supports cascade loading the different faces.
  105136. */
  105137. readonly supportCascades: boolean;
  105138. /**
  105139. * This returns if the loader support the current file information.
  105140. * @param extension defines the file extension of the file being loaded
  105141. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105142. * @param fallback defines the fallback internal texture if any
  105143. * @param isBase64 defines whether the texture is encoded as a base64
  105144. * @param isBuffer defines whether the texture data are stored as a buffer
  105145. * @returns true if the loader can load the specified file
  105146. */
  105147. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105148. /**
  105149. * Transform the url before loading if required.
  105150. * @param rootUrl the url of the texture
  105151. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105152. * @returns the transformed texture
  105153. */
  105154. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105155. /**
  105156. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105157. * @param rootUrl the url of the texture
  105158. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105159. * @returns the fallback texture
  105160. */
  105161. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105162. /**
  105163. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105164. * @param data contains the texture data
  105165. * @param texture defines the BabylonJS internal texture
  105166. * @param createPolynomials will be true if polynomials have been requested
  105167. * @param onLoad defines the callback to trigger once the texture is ready
  105168. * @param onError defines the callback to trigger in case of error
  105169. */
  105170. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105171. /**
  105172. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105173. * @param data contains the texture data
  105174. * @param texture defines the BabylonJS internal texture
  105175. * @param callback defines the method to call once ready to upload
  105176. */
  105177. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105178. }
  105179. }
  105180. declare module BABYLON {
  105181. /** @hidden */
  105182. export var rgbdEncodePixelShader: {
  105183. name: string;
  105184. shader: string;
  105185. };
  105186. }
  105187. declare module BABYLON {
  105188. /**
  105189. * Raw texture data and descriptor sufficient for WebGL texture upload
  105190. */
  105191. export interface EnvironmentTextureInfo {
  105192. /**
  105193. * Version of the environment map
  105194. */
  105195. version: number;
  105196. /**
  105197. * Width of image
  105198. */
  105199. width: number;
  105200. /**
  105201. * Irradiance information stored in the file.
  105202. */
  105203. irradiance: any;
  105204. /**
  105205. * Specular information stored in the file.
  105206. */
  105207. specular: any;
  105208. }
  105209. /**
  105210. * Sets of helpers addressing the serialization and deserialization of environment texture
  105211. * stored in a BabylonJS env file.
  105212. * Those files are usually stored as .env files.
  105213. */
  105214. export class EnvironmentTextureTools {
  105215. /**
  105216. * Magic number identifying the env file.
  105217. */
  105218. private static _MagicBytes;
  105219. /**
  105220. * Gets the environment info from an env file.
  105221. * @param data The array buffer containing the .env bytes.
  105222. * @returns the environment file info (the json header) if successfully parsed.
  105223. */
  105224. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  105225. /**
  105226. * Creates an environment texture from a loaded cube texture.
  105227. * @param texture defines the cube texture to convert in env file
  105228. * @return a promise containing the environment data if succesfull.
  105229. */
  105230. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  105231. /**
  105232. * Creates a JSON representation of the spherical data.
  105233. * @param texture defines the texture containing the polynomials
  105234. * @return the JSON representation of the spherical info
  105235. */
  105236. private static _CreateEnvTextureIrradiance;
  105237. /**
  105238. * Uploads the texture info contained in the env file to the GPU.
  105239. * @param texture defines the internal texture to upload to
  105240. * @param arrayBuffer defines the buffer cotaining the data to load
  105241. * @param info defines the texture info retrieved through the GetEnvInfo method
  105242. * @returns a promise
  105243. */
  105244. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  105245. /**
  105246. * Uploads the levels of image data to the GPU.
  105247. * @param texture defines the internal texture to upload to
  105248. * @param imageData defines the array buffer views of image data [mipmap][face]
  105249. * @returns a promise
  105250. */
  105251. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  105252. /**
  105253. * Uploads spherical polynomials information to the texture.
  105254. * @param texture defines the texture we are trying to upload the information to
  105255. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  105256. */
  105257. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  105258. /** @hidden */
  105259. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105260. }
  105261. }
  105262. declare module BABYLON {
  105263. /**
  105264. * Implementation of the ENV Texture Loader.
  105265. * @hidden
  105266. */
  105267. export class _ENVTextureLoader implements IInternalTextureLoader {
  105268. /**
  105269. * Defines wether the loader supports cascade loading the different faces.
  105270. */
  105271. readonly supportCascades: boolean;
  105272. /**
  105273. * This returns if the loader support the current file information.
  105274. * @param extension defines the file extension of the file being loaded
  105275. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105276. * @param fallback defines the fallback internal texture if any
  105277. * @param isBase64 defines whether the texture is encoded as a base64
  105278. * @param isBuffer defines whether the texture data are stored as a buffer
  105279. * @returns true if the loader can load the specified file
  105280. */
  105281. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105282. /**
  105283. * Transform the url before loading if required.
  105284. * @param rootUrl the url of the texture
  105285. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105286. * @returns the transformed texture
  105287. */
  105288. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105289. /**
  105290. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105291. * @param rootUrl the url of the texture
  105292. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105293. * @returns the fallback texture
  105294. */
  105295. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105296. /**
  105297. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105298. * @param data contains the texture data
  105299. * @param texture defines the BabylonJS internal texture
  105300. * @param createPolynomials will be true if polynomials have been requested
  105301. * @param onLoad defines the callback to trigger once the texture is ready
  105302. * @param onError defines the callback to trigger in case of error
  105303. */
  105304. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105305. /**
  105306. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105307. * @param data contains the texture data
  105308. * @param texture defines the BabylonJS internal texture
  105309. * @param callback defines the method to call once ready to upload
  105310. */
  105311. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105312. }
  105313. }
  105314. declare module BABYLON {
  105315. /**
  105316. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  105317. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  105318. */
  105319. export class KhronosTextureContainer {
  105320. /** contents of the KTX container file */
  105321. arrayBuffer: any;
  105322. private static HEADER_LEN;
  105323. private static COMPRESSED_2D;
  105324. private static COMPRESSED_3D;
  105325. private static TEX_2D;
  105326. private static TEX_3D;
  105327. /**
  105328. * Gets the openGL type
  105329. */
  105330. glType: number;
  105331. /**
  105332. * Gets the openGL type size
  105333. */
  105334. glTypeSize: number;
  105335. /**
  105336. * Gets the openGL format
  105337. */
  105338. glFormat: number;
  105339. /**
  105340. * Gets the openGL internal format
  105341. */
  105342. glInternalFormat: number;
  105343. /**
  105344. * Gets the base internal format
  105345. */
  105346. glBaseInternalFormat: number;
  105347. /**
  105348. * Gets image width in pixel
  105349. */
  105350. pixelWidth: number;
  105351. /**
  105352. * Gets image height in pixel
  105353. */
  105354. pixelHeight: number;
  105355. /**
  105356. * Gets image depth in pixels
  105357. */
  105358. pixelDepth: number;
  105359. /**
  105360. * Gets the number of array elements
  105361. */
  105362. numberOfArrayElements: number;
  105363. /**
  105364. * Gets the number of faces
  105365. */
  105366. numberOfFaces: number;
  105367. /**
  105368. * Gets the number of mipmap levels
  105369. */
  105370. numberOfMipmapLevels: number;
  105371. /**
  105372. * Gets the bytes of key value data
  105373. */
  105374. bytesOfKeyValueData: number;
  105375. /**
  105376. * Gets the load type
  105377. */
  105378. loadType: number;
  105379. /**
  105380. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  105381. */
  105382. isInvalid: boolean;
  105383. /**
  105384. * Creates a new KhronosTextureContainer
  105385. * @param arrayBuffer contents of the KTX container file
  105386. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  105387. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  105388. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  105389. */
  105390. constructor(
  105391. /** contents of the KTX container file */
  105392. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  105393. /**
  105394. * Uploads KTX content to a Babylon Texture.
  105395. * It is assumed that the texture has already been created & is currently bound
  105396. * @hidden
  105397. */
  105398. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  105399. private _upload2DCompressedLevels;
  105400. }
  105401. }
  105402. declare module BABYLON {
  105403. /**
  105404. * Implementation of the KTX Texture Loader.
  105405. * @hidden
  105406. */
  105407. export class _KTXTextureLoader implements IInternalTextureLoader {
  105408. /**
  105409. * Defines wether the loader supports cascade loading the different faces.
  105410. */
  105411. readonly supportCascades: boolean;
  105412. /**
  105413. * This returns if the loader support the current file information.
  105414. * @param extension defines the file extension of the file being loaded
  105415. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105416. * @param fallback defines the fallback internal texture if any
  105417. * @param isBase64 defines whether the texture is encoded as a base64
  105418. * @param isBuffer defines whether the texture data are stored as a buffer
  105419. * @returns true if the loader can load the specified file
  105420. */
  105421. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105422. /**
  105423. * Transform the url before loading if required.
  105424. * @param rootUrl the url of the texture
  105425. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105426. * @returns the transformed texture
  105427. */
  105428. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105429. /**
  105430. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105431. * @param rootUrl the url of the texture
  105432. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105433. * @returns the fallback texture
  105434. */
  105435. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105436. /**
  105437. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105438. * @param data contains the texture data
  105439. * @param texture defines the BabylonJS internal texture
  105440. * @param createPolynomials will be true if polynomials have been requested
  105441. * @param onLoad defines the callback to trigger once the texture is ready
  105442. * @param onError defines the callback to trigger in case of error
  105443. */
  105444. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105445. /**
  105446. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105447. * @param data contains the texture data
  105448. * @param texture defines the BabylonJS internal texture
  105449. * @param callback defines the method to call once ready to upload
  105450. */
  105451. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  105452. }
  105453. }
  105454. declare module BABYLON {
  105455. /** @hidden */
  105456. export var _forceSceneHelpersToBundle: boolean;
  105457. interface Scene {
  105458. /**
  105459. * Creates a default light for the scene.
  105460. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  105461. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  105462. */
  105463. createDefaultLight(replace?: boolean): void;
  105464. /**
  105465. * Creates a default camera for the scene.
  105466. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  105467. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105468. * @param replace has default false, when true replaces the active camera in the scene
  105469. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  105470. */
  105471. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105472. /**
  105473. * Creates a default camera and a default light.
  105474. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  105475. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105476. * @param replace has the default false, when true replaces the active camera/light in the scene
  105477. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  105478. */
  105479. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105480. /**
  105481. * Creates a new sky box
  105482. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  105483. * @param environmentTexture defines the texture to use as environment texture
  105484. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  105485. * @param scale defines the overall scale of the skybox
  105486. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  105487. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  105488. * @returns a new mesh holding the sky box
  105489. */
  105490. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  105491. /**
  105492. * Creates a new environment
  105493. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  105494. * @param options defines the options you can use to configure the environment
  105495. * @returns the new EnvironmentHelper
  105496. */
  105497. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  105498. /**
  105499. * Creates a new VREXperienceHelper
  105500. * @see http://doc.babylonjs.com/how_to/webvr_helper
  105501. * @param webVROptions defines the options used to create the new VREXperienceHelper
  105502. * @returns a new VREXperienceHelper
  105503. */
  105504. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  105505. /**
  105506. * Creates a new XREXperienceHelper
  105507. * @see http://doc.babylonjs.com/how_to/webxr
  105508. * @returns a promise for a new XREXperienceHelper
  105509. */
  105510. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  105511. }
  105512. }
  105513. declare module BABYLON {
  105514. /**
  105515. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  105516. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  105517. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  105518. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  105519. */
  105520. export class VideoDome extends TransformNode {
  105521. /**
  105522. * Define the video source as a Monoscopic panoramic 360 video.
  105523. */
  105524. static readonly MODE_MONOSCOPIC: number;
  105525. /**
  105526. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105527. */
  105528. static readonly MODE_TOPBOTTOM: number;
  105529. /**
  105530. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105531. */
  105532. static readonly MODE_SIDEBYSIDE: number;
  105533. private _useDirectMapping;
  105534. /**
  105535. * The video texture being displayed on the sphere
  105536. */
  105537. protected _videoTexture: VideoTexture;
  105538. /**
  105539. * Gets the video texture being displayed on the sphere
  105540. */
  105541. readonly videoTexture: VideoTexture;
  105542. /**
  105543. * The skybox material
  105544. */
  105545. protected _material: BackgroundMaterial;
  105546. /**
  105547. * The surface used for the skybox
  105548. */
  105549. protected _mesh: Mesh;
  105550. /**
  105551. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  105552. * Also see the options.resolution property.
  105553. */
  105554. fovMultiplier: number;
  105555. private _videoMode;
  105556. /**
  105557. * Gets or set the current video mode for the video. It can be:
  105558. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  105559. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105560. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105561. */
  105562. videoMode: number;
  105563. /**
  105564. * Oberserver used in Stereoscopic VR Mode.
  105565. */
  105566. private _onBeforeCameraRenderObserver;
  105567. /**
  105568. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  105569. * @param name Element's name, child elements will append suffixes for their own names.
  105570. * @param urlsOrVideo defines the url(s) or the video element to use
  105571. * @param options An object containing optional or exposed sub element properties
  105572. */
  105573. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  105574. resolution?: number;
  105575. clickToPlay?: boolean;
  105576. autoPlay?: boolean;
  105577. loop?: boolean;
  105578. size?: number;
  105579. poster?: string;
  105580. faceForward?: boolean;
  105581. useDirectMapping?: boolean;
  105582. }, scene: Scene);
  105583. private _changeVideoMode;
  105584. /**
  105585. * Releases resources associated with this node.
  105586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105588. */
  105589. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105590. }
  105591. }
  105592. declare module BABYLON {
  105593. /**
  105594. * This class can be used to get instrumentation data from a Babylon engine
  105595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105596. */
  105597. export class EngineInstrumentation implements IDisposable {
  105598. /**
  105599. * Define the instrumented engine.
  105600. */
  105601. engine: Engine;
  105602. private _captureGPUFrameTime;
  105603. private _gpuFrameTimeToken;
  105604. private _gpuFrameTime;
  105605. private _captureShaderCompilationTime;
  105606. private _shaderCompilationTime;
  105607. private _onBeginFrameObserver;
  105608. private _onEndFrameObserver;
  105609. private _onBeforeShaderCompilationObserver;
  105610. private _onAfterShaderCompilationObserver;
  105611. /**
  105612. * Gets the perf counter used for GPU frame time
  105613. */
  105614. readonly gpuFrameTimeCounter: PerfCounter;
  105615. /**
  105616. * Gets the GPU frame time capture status
  105617. */
  105618. /**
  105619. * Enable or disable the GPU frame time capture
  105620. */
  105621. captureGPUFrameTime: boolean;
  105622. /**
  105623. * Gets the perf counter used for shader compilation time
  105624. */
  105625. readonly shaderCompilationTimeCounter: PerfCounter;
  105626. /**
  105627. * Gets the shader compilation time capture status
  105628. */
  105629. /**
  105630. * Enable or disable the shader compilation time capture
  105631. */
  105632. captureShaderCompilationTime: boolean;
  105633. /**
  105634. * Instantiates a new engine instrumentation.
  105635. * This class can be used to get instrumentation data from a Babylon engine
  105636. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105637. * @param engine Defines the engine to instrument
  105638. */
  105639. constructor(
  105640. /**
  105641. * Define the instrumented engine.
  105642. */
  105643. engine: Engine);
  105644. /**
  105645. * Dispose and release associated resources.
  105646. */
  105647. dispose(): void;
  105648. }
  105649. }
  105650. declare module BABYLON {
  105651. /**
  105652. * This class can be used to get instrumentation data from a Babylon engine
  105653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105654. */
  105655. export class SceneInstrumentation implements IDisposable {
  105656. /**
  105657. * Defines the scene to instrument
  105658. */
  105659. scene: Scene;
  105660. private _captureActiveMeshesEvaluationTime;
  105661. private _activeMeshesEvaluationTime;
  105662. private _captureRenderTargetsRenderTime;
  105663. private _renderTargetsRenderTime;
  105664. private _captureFrameTime;
  105665. private _frameTime;
  105666. private _captureRenderTime;
  105667. private _renderTime;
  105668. private _captureInterFrameTime;
  105669. private _interFrameTime;
  105670. private _captureParticlesRenderTime;
  105671. private _particlesRenderTime;
  105672. private _captureSpritesRenderTime;
  105673. private _spritesRenderTime;
  105674. private _capturePhysicsTime;
  105675. private _physicsTime;
  105676. private _captureAnimationsTime;
  105677. private _animationsTime;
  105678. private _captureCameraRenderTime;
  105679. private _cameraRenderTime;
  105680. private _onBeforeActiveMeshesEvaluationObserver;
  105681. private _onAfterActiveMeshesEvaluationObserver;
  105682. private _onBeforeRenderTargetsRenderObserver;
  105683. private _onAfterRenderTargetsRenderObserver;
  105684. private _onAfterRenderObserver;
  105685. private _onBeforeDrawPhaseObserver;
  105686. private _onAfterDrawPhaseObserver;
  105687. private _onBeforeAnimationsObserver;
  105688. private _onBeforeParticlesRenderingObserver;
  105689. private _onAfterParticlesRenderingObserver;
  105690. private _onBeforeSpritesRenderingObserver;
  105691. private _onAfterSpritesRenderingObserver;
  105692. private _onBeforePhysicsObserver;
  105693. private _onAfterPhysicsObserver;
  105694. private _onAfterAnimationsObserver;
  105695. private _onBeforeCameraRenderObserver;
  105696. private _onAfterCameraRenderObserver;
  105697. /**
  105698. * Gets the perf counter used for active meshes evaluation time
  105699. */
  105700. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  105701. /**
  105702. * Gets the active meshes evaluation time capture status
  105703. */
  105704. /**
  105705. * Enable or disable the active meshes evaluation time capture
  105706. */
  105707. captureActiveMeshesEvaluationTime: boolean;
  105708. /**
  105709. * Gets the perf counter used for render targets render time
  105710. */
  105711. readonly renderTargetsRenderTimeCounter: PerfCounter;
  105712. /**
  105713. * Gets the render targets render time capture status
  105714. */
  105715. /**
  105716. * Enable or disable the render targets render time capture
  105717. */
  105718. captureRenderTargetsRenderTime: boolean;
  105719. /**
  105720. * Gets the perf counter used for particles render time
  105721. */
  105722. readonly particlesRenderTimeCounter: PerfCounter;
  105723. /**
  105724. * Gets the particles render time capture status
  105725. */
  105726. /**
  105727. * Enable or disable the particles render time capture
  105728. */
  105729. captureParticlesRenderTime: boolean;
  105730. /**
  105731. * Gets the perf counter used for sprites render time
  105732. */
  105733. readonly spritesRenderTimeCounter: PerfCounter;
  105734. /**
  105735. * Gets the sprites render time capture status
  105736. */
  105737. /**
  105738. * Enable or disable the sprites render time capture
  105739. */
  105740. captureSpritesRenderTime: boolean;
  105741. /**
  105742. * Gets the perf counter used for physics time
  105743. */
  105744. readonly physicsTimeCounter: PerfCounter;
  105745. /**
  105746. * Gets the physics time capture status
  105747. */
  105748. /**
  105749. * Enable or disable the physics time capture
  105750. */
  105751. capturePhysicsTime: boolean;
  105752. /**
  105753. * Gets the perf counter used for animations time
  105754. */
  105755. readonly animationsTimeCounter: PerfCounter;
  105756. /**
  105757. * Gets the animations time capture status
  105758. */
  105759. /**
  105760. * Enable or disable the animations time capture
  105761. */
  105762. captureAnimationsTime: boolean;
  105763. /**
  105764. * Gets the perf counter used for frame time capture
  105765. */
  105766. readonly frameTimeCounter: PerfCounter;
  105767. /**
  105768. * Gets the frame time capture status
  105769. */
  105770. /**
  105771. * Enable or disable the frame time capture
  105772. */
  105773. captureFrameTime: boolean;
  105774. /**
  105775. * Gets the perf counter used for inter-frames time capture
  105776. */
  105777. readonly interFrameTimeCounter: PerfCounter;
  105778. /**
  105779. * Gets the inter-frames time capture status
  105780. */
  105781. /**
  105782. * Enable or disable the inter-frames time capture
  105783. */
  105784. captureInterFrameTime: boolean;
  105785. /**
  105786. * Gets the perf counter used for render time capture
  105787. */
  105788. readonly renderTimeCounter: PerfCounter;
  105789. /**
  105790. * Gets the render time capture status
  105791. */
  105792. /**
  105793. * Enable or disable the render time capture
  105794. */
  105795. captureRenderTime: boolean;
  105796. /**
  105797. * Gets the perf counter used for camera render time capture
  105798. */
  105799. readonly cameraRenderTimeCounter: PerfCounter;
  105800. /**
  105801. * Gets the camera render time capture status
  105802. */
  105803. /**
  105804. * Enable or disable the camera render time capture
  105805. */
  105806. captureCameraRenderTime: boolean;
  105807. /**
  105808. * Gets the perf counter used for draw calls
  105809. */
  105810. readonly drawCallsCounter: PerfCounter;
  105811. /**
  105812. * Instantiates a new scene instrumentation.
  105813. * This class can be used to get instrumentation data from a Babylon engine
  105814. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105815. * @param scene Defines the scene to instrument
  105816. */
  105817. constructor(
  105818. /**
  105819. * Defines the scene to instrument
  105820. */
  105821. scene: Scene);
  105822. /**
  105823. * Dispose and release associated resources.
  105824. */
  105825. dispose(): void;
  105826. }
  105827. }
  105828. declare module BABYLON {
  105829. /** @hidden */
  105830. export var glowMapGenerationPixelShader: {
  105831. name: string;
  105832. shader: string;
  105833. };
  105834. }
  105835. declare module BABYLON {
  105836. /** @hidden */
  105837. export var glowMapGenerationVertexShader: {
  105838. name: string;
  105839. shader: string;
  105840. };
  105841. }
  105842. declare module BABYLON {
  105843. /**
  105844. * Effect layer options. This helps customizing the behaviour
  105845. * of the effect layer.
  105846. */
  105847. export interface IEffectLayerOptions {
  105848. /**
  105849. * Multiplication factor apply to the canvas size to compute the render target size
  105850. * used to generated the objects (the smaller the faster).
  105851. */
  105852. mainTextureRatio: number;
  105853. /**
  105854. * Enforces a fixed size texture to ensure effect stability across devices.
  105855. */
  105856. mainTextureFixedSize?: number;
  105857. /**
  105858. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  105859. */
  105860. alphaBlendingMode: number;
  105861. /**
  105862. * The camera attached to the layer.
  105863. */
  105864. camera: Nullable<Camera>;
  105865. /**
  105866. * The rendering group to draw the layer in.
  105867. */
  105868. renderingGroupId: number;
  105869. }
  105870. /**
  105871. * The effect layer Helps adding post process effect blended with the main pass.
  105872. *
  105873. * This can be for instance use to generate glow or higlight effects on the scene.
  105874. *
  105875. * The effect layer class can not be used directly and is intented to inherited from to be
  105876. * customized per effects.
  105877. */
  105878. export abstract class EffectLayer {
  105879. private _vertexBuffers;
  105880. private _indexBuffer;
  105881. private _cachedDefines;
  105882. private _effectLayerMapGenerationEffect;
  105883. private _effectLayerOptions;
  105884. private _mergeEffect;
  105885. protected _scene: Scene;
  105886. protected _engine: Engine;
  105887. protected _maxSize: number;
  105888. protected _mainTextureDesiredSize: ISize;
  105889. protected _mainTexture: RenderTargetTexture;
  105890. protected _shouldRender: boolean;
  105891. protected _postProcesses: PostProcess[];
  105892. protected _textures: BaseTexture[];
  105893. protected _emissiveTextureAndColor: {
  105894. texture: Nullable<BaseTexture>;
  105895. color: Color4;
  105896. };
  105897. /**
  105898. * The name of the layer
  105899. */
  105900. name: string;
  105901. /**
  105902. * The clear color of the texture used to generate the glow map.
  105903. */
  105904. neutralColor: Color4;
  105905. /**
  105906. * Specifies wether the highlight layer is enabled or not.
  105907. */
  105908. isEnabled: boolean;
  105909. /**
  105910. * Gets the camera attached to the layer.
  105911. */
  105912. readonly camera: Nullable<Camera>;
  105913. /**
  105914. * Gets the rendering group id the layer should render in.
  105915. */
  105916. readonly renderingGroupId: number;
  105917. /**
  105918. * An event triggered when the effect layer has been disposed.
  105919. */
  105920. onDisposeObservable: Observable<EffectLayer>;
  105921. /**
  105922. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  105923. */
  105924. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  105925. /**
  105926. * An event triggered when the generated texture is being merged in the scene.
  105927. */
  105928. onBeforeComposeObservable: Observable<EffectLayer>;
  105929. /**
  105930. * An event triggered when the generated texture has been merged in the scene.
  105931. */
  105932. onAfterComposeObservable: Observable<EffectLayer>;
  105933. /**
  105934. * An event triggered when the efffect layer changes its size.
  105935. */
  105936. onSizeChangedObservable: Observable<EffectLayer>;
  105937. /** @hidden */
  105938. static _SceneComponentInitialization: (scene: Scene) => void;
  105939. /**
  105940. * Instantiates a new effect Layer and references it in the scene.
  105941. * @param name The name of the layer
  105942. * @param scene The scene to use the layer in
  105943. */
  105944. constructor(
  105945. /** The Friendly of the effect in the scene */
  105946. name: string, scene: Scene);
  105947. /**
  105948. * Get the effect name of the layer.
  105949. * @return The effect name
  105950. */
  105951. abstract getEffectName(): string;
  105952. /**
  105953. * Checks for the readiness of the element composing the layer.
  105954. * @param subMesh the mesh to check for
  105955. * @param useInstances specify wether or not to use instances to render the mesh
  105956. * @return true if ready otherwise, false
  105957. */
  105958. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105959. /**
  105960. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105961. * @returns true if the effect requires stencil during the main canvas render pass.
  105962. */
  105963. abstract needStencil(): boolean;
  105964. /**
  105965. * Create the merge effect. This is the shader use to blit the information back
  105966. * to the main canvas at the end of the scene rendering.
  105967. * @returns The effect containing the shader used to merge the effect on the main canvas
  105968. */
  105969. protected abstract _createMergeEffect(): Effect;
  105970. /**
  105971. * Creates the render target textures and post processes used in the effect layer.
  105972. */
  105973. protected abstract _createTextureAndPostProcesses(): void;
  105974. /**
  105975. * Implementation specific of rendering the generating effect on the main canvas.
  105976. * @param effect The effect used to render through
  105977. */
  105978. protected abstract _internalRender(effect: Effect): void;
  105979. /**
  105980. * Sets the required values for both the emissive texture and and the main color.
  105981. */
  105982. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105983. /**
  105984. * Free any resources and references associated to a mesh.
  105985. * Internal use
  105986. * @param mesh The mesh to free.
  105987. */
  105988. abstract _disposeMesh(mesh: Mesh): void;
  105989. /**
  105990. * Serializes this layer (Glow or Highlight for example)
  105991. * @returns a serialized layer object
  105992. */
  105993. abstract serialize?(): any;
  105994. /**
  105995. * Initializes the effect layer with the required options.
  105996. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  105997. */
  105998. protected _init(options: Partial<IEffectLayerOptions>): void;
  105999. /**
  106000. * Generates the index buffer of the full screen quad blending to the main canvas.
  106001. */
  106002. private _generateIndexBuffer;
  106003. /**
  106004. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106005. */
  106006. private _genrateVertexBuffer;
  106007. /**
  106008. * Sets the main texture desired size which is the closest power of two
  106009. * of the engine canvas size.
  106010. */
  106011. private _setMainTextureSize;
  106012. /**
  106013. * Creates the main texture for the effect layer.
  106014. */
  106015. protected _createMainTexture(): void;
  106016. /**
  106017. * Adds specific effects defines.
  106018. * @param defines The defines to add specifics to.
  106019. */
  106020. protected _addCustomEffectDefines(defines: string[]): void;
  106021. /**
  106022. * Checks for the readiness of the element composing the layer.
  106023. * @param subMesh the mesh to check for
  106024. * @param useInstances specify wether or not to use instances to render the mesh
  106025. * @param emissiveTexture the associated emissive texture used to generate the glow
  106026. * @return true if ready otherwise, false
  106027. */
  106028. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106029. /**
  106030. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106031. */
  106032. render(): void;
  106033. /**
  106034. * Determine if a given mesh will be used in the current effect.
  106035. * @param mesh mesh to test
  106036. * @returns true if the mesh will be used
  106037. */
  106038. hasMesh(mesh: AbstractMesh): boolean;
  106039. /**
  106040. * Returns true if the layer contains information to display, otherwise false.
  106041. * @returns true if the glow layer should be rendered
  106042. */
  106043. shouldRender(): boolean;
  106044. /**
  106045. * Returns true if the mesh should render, otherwise false.
  106046. * @param mesh The mesh to render
  106047. * @returns true if it should render otherwise false
  106048. */
  106049. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106050. /**
  106051. * Returns true if the mesh can be rendered, otherwise false.
  106052. * @param mesh The mesh to render
  106053. * @param material The material used on the mesh
  106054. * @returns true if it can be rendered otherwise false
  106055. */
  106056. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106057. /**
  106058. * Returns true if the mesh should render, otherwise false.
  106059. * @param mesh The mesh to render
  106060. * @returns true if it should render otherwise false
  106061. */
  106062. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106063. /**
  106064. * Renders the submesh passed in parameter to the generation map.
  106065. */
  106066. protected _renderSubMesh(subMesh: SubMesh): void;
  106067. /**
  106068. * Rebuild the required buffers.
  106069. * @hidden Internal use only.
  106070. */
  106071. _rebuild(): void;
  106072. /**
  106073. * Dispose only the render target textures and post process.
  106074. */
  106075. private _disposeTextureAndPostProcesses;
  106076. /**
  106077. * Dispose the highlight layer and free resources.
  106078. */
  106079. dispose(): void;
  106080. /**
  106081. * Gets the class name of the effect layer
  106082. * @returns the string with the class name of the effect layer
  106083. */
  106084. getClassName(): string;
  106085. /**
  106086. * Creates an effect layer from parsed effect layer data
  106087. * @param parsedEffectLayer defines effect layer data
  106088. * @param scene defines the current scene
  106089. * @param rootUrl defines the root URL containing the effect layer information
  106090. * @returns a parsed effect Layer
  106091. */
  106092. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106093. }
  106094. }
  106095. declare module BABYLON {
  106096. interface AbstractScene {
  106097. /**
  106098. * The list of effect layers (highlights/glow) added to the scene
  106099. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106100. * @see http://doc.babylonjs.com/how_to/glow_layer
  106101. */
  106102. effectLayers: Array<EffectLayer>;
  106103. /**
  106104. * Removes the given effect layer from this scene.
  106105. * @param toRemove defines the effect layer to remove
  106106. * @returns the index of the removed effect layer
  106107. */
  106108. removeEffectLayer(toRemove: EffectLayer): number;
  106109. /**
  106110. * Adds the given effect layer to this scene
  106111. * @param newEffectLayer defines the effect layer to add
  106112. */
  106113. addEffectLayer(newEffectLayer: EffectLayer): void;
  106114. }
  106115. /**
  106116. * Defines the layer scene component responsible to manage any effect layers
  106117. * in a given scene.
  106118. */
  106119. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106120. /**
  106121. * The component name helpfull to identify the component in the list of scene components.
  106122. */
  106123. readonly name: string;
  106124. /**
  106125. * The scene the component belongs to.
  106126. */
  106127. scene: Scene;
  106128. private _engine;
  106129. private _renderEffects;
  106130. private _needStencil;
  106131. private _previousStencilState;
  106132. /**
  106133. * Creates a new instance of the component for the given scene
  106134. * @param scene Defines the scene to register the component in
  106135. */
  106136. constructor(scene: Scene);
  106137. /**
  106138. * Registers the component in a given scene
  106139. */
  106140. register(): void;
  106141. /**
  106142. * Rebuilds the elements related to this component in case of
  106143. * context lost for instance.
  106144. */
  106145. rebuild(): void;
  106146. /**
  106147. * Serializes the component data to the specified json object
  106148. * @param serializationObject The object to serialize to
  106149. */
  106150. serialize(serializationObject: any): void;
  106151. /**
  106152. * Adds all the element from the container to the scene
  106153. * @param container the container holding the elements
  106154. */
  106155. addFromContainer(container: AbstractScene): void;
  106156. /**
  106157. * Removes all the elements in the container from the scene
  106158. * @param container contains the elements to remove
  106159. * @param dispose if the removed element should be disposed (default: false)
  106160. */
  106161. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106162. /**
  106163. * Disposes the component and the associated ressources.
  106164. */
  106165. dispose(): void;
  106166. private _isReadyForMesh;
  106167. private _renderMainTexture;
  106168. private _setStencil;
  106169. private _setStencilBack;
  106170. private _draw;
  106171. private _drawCamera;
  106172. private _drawRenderingGroup;
  106173. }
  106174. }
  106175. declare module BABYLON {
  106176. /** @hidden */
  106177. export var glowMapMergePixelShader: {
  106178. name: string;
  106179. shader: string;
  106180. };
  106181. }
  106182. declare module BABYLON {
  106183. /** @hidden */
  106184. export var glowMapMergeVertexShader: {
  106185. name: string;
  106186. shader: string;
  106187. };
  106188. }
  106189. declare module BABYLON {
  106190. interface AbstractScene {
  106191. /**
  106192. * Return a the first highlight layer of the scene with a given name.
  106193. * @param name The name of the highlight layer to look for.
  106194. * @return The highlight layer if found otherwise null.
  106195. */
  106196. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  106197. }
  106198. /**
  106199. * Glow layer options. This helps customizing the behaviour
  106200. * of the glow layer.
  106201. */
  106202. export interface IGlowLayerOptions {
  106203. /**
  106204. * Multiplication factor apply to the canvas size to compute the render target size
  106205. * used to generated the glowing objects (the smaller the faster).
  106206. */
  106207. mainTextureRatio: number;
  106208. /**
  106209. * Enforces a fixed size texture to ensure resize independant blur.
  106210. */
  106211. mainTextureFixedSize?: number;
  106212. /**
  106213. * How big is the kernel of the blur texture.
  106214. */
  106215. blurKernelSize: number;
  106216. /**
  106217. * The camera attached to the layer.
  106218. */
  106219. camera: Nullable<Camera>;
  106220. /**
  106221. * Enable MSAA by chosing the number of samples.
  106222. */
  106223. mainTextureSamples?: number;
  106224. /**
  106225. * The rendering group to draw the layer in.
  106226. */
  106227. renderingGroupId: number;
  106228. }
  106229. /**
  106230. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  106231. *
  106232. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106233. * glowy meshes to your scene.
  106234. *
  106235. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  106236. */
  106237. export class GlowLayer extends EffectLayer {
  106238. /**
  106239. * Effect Name of the layer.
  106240. */
  106241. static readonly EffectName: string;
  106242. /**
  106243. * The default blur kernel size used for the glow.
  106244. */
  106245. static DefaultBlurKernelSize: number;
  106246. /**
  106247. * The default texture size ratio used for the glow.
  106248. */
  106249. static DefaultTextureRatio: number;
  106250. /**
  106251. * Sets the kernel size of the blur.
  106252. */
  106253. /**
  106254. * Gets the kernel size of the blur.
  106255. */
  106256. blurKernelSize: number;
  106257. /**
  106258. * Sets the glow intensity.
  106259. */
  106260. /**
  106261. * Gets the glow intensity.
  106262. */
  106263. intensity: number;
  106264. private _options;
  106265. private _intensity;
  106266. private _horizontalBlurPostprocess1;
  106267. private _verticalBlurPostprocess1;
  106268. private _horizontalBlurPostprocess2;
  106269. private _verticalBlurPostprocess2;
  106270. private _blurTexture1;
  106271. private _blurTexture2;
  106272. private _postProcesses1;
  106273. private _postProcesses2;
  106274. private _includedOnlyMeshes;
  106275. private _excludedMeshes;
  106276. /**
  106277. * Callback used to let the user override the color selection on a per mesh basis
  106278. */
  106279. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  106280. /**
  106281. * Callback used to let the user override the texture selection on a per mesh basis
  106282. */
  106283. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  106284. /**
  106285. * Instantiates a new glow Layer and references it to the scene.
  106286. * @param name The name of the layer
  106287. * @param scene The scene to use the layer in
  106288. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  106289. */
  106290. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  106291. /**
  106292. * Get the effect name of the layer.
  106293. * @return The effect name
  106294. */
  106295. getEffectName(): string;
  106296. /**
  106297. * Create the merge effect. This is the shader use to blit the information back
  106298. * to the main canvas at the end of the scene rendering.
  106299. */
  106300. protected _createMergeEffect(): Effect;
  106301. /**
  106302. * Creates the render target textures and post processes used in the glow layer.
  106303. */
  106304. protected _createTextureAndPostProcesses(): void;
  106305. /**
  106306. * Checks for the readiness of the element composing the layer.
  106307. * @param subMesh the mesh to check for
  106308. * @param useInstances specify wether or not to use instances to render the mesh
  106309. * @param emissiveTexture the associated emissive texture used to generate the glow
  106310. * @return true if ready otherwise, false
  106311. */
  106312. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106313. /**
  106314. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106315. */
  106316. needStencil(): boolean;
  106317. /**
  106318. * Returns true if the mesh can be rendered, otherwise false.
  106319. * @param mesh The mesh to render
  106320. * @param material The material used on the mesh
  106321. * @returns true if it can be rendered otherwise false
  106322. */
  106323. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106324. /**
  106325. * Implementation specific of rendering the generating effect on the main canvas.
  106326. * @param effect The effect used to render through
  106327. */
  106328. protected _internalRender(effect: Effect): void;
  106329. /**
  106330. * Sets the required values for both the emissive texture and and the main color.
  106331. */
  106332. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106333. /**
  106334. * Returns true if the mesh should render, otherwise false.
  106335. * @param mesh The mesh to render
  106336. * @returns true if it should render otherwise false
  106337. */
  106338. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106339. /**
  106340. * Adds specific effects defines.
  106341. * @param defines The defines to add specifics to.
  106342. */
  106343. protected _addCustomEffectDefines(defines: string[]): void;
  106344. /**
  106345. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  106346. * @param mesh The mesh to exclude from the glow layer
  106347. */
  106348. addExcludedMesh(mesh: Mesh): void;
  106349. /**
  106350. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  106351. * @param mesh The mesh to remove
  106352. */
  106353. removeExcludedMesh(mesh: Mesh): void;
  106354. /**
  106355. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  106356. * @param mesh The mesh to include in the glow layer
  106357. */
  106358. addIncludedOnlyMesh(mesh: Mesh): void;
  106359. /**
  106360. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  106361. * @param mesh The mesh to remove
  106362. */
  106363. removeIncludedOnlyMesh(mesh: Mesh): void;
  106364. /**
  106365. * Determine if a given mesh will be used in the glow layer
  106366. * @param mesh The mesh to test
  106367. * @returns true if the mesh will be highlighted by the current glow layer
  106368. */
  106369. hasMesh(mesh: AbstractMesh): boolean;
  106370. /**
  106371. * Free any resources and references associated to a mesh.
  106372. * Internal use
  106373. * @param mesh The mesh to free.
  106374. * @hidden
  106375. */
  106376. _disposeMesh(mesh: Mesh): void;
  106377. /**
  106378. * Gets the class name of the effect layer
  106379. * @returns the string with the class name of the effect layer
  106380. */
  106381. getClassName(): string;
  106382. /**
  106383. * Serializes this glow layer
  106384. * @returns a serialized glow layer object
  106385. */
  106386. serialize(): any;
  106387. /**
  106388. * Creates a Glow Layer from parsed glow layer data
  106389. * @param parsedGlowLayer defines glow layer data
  106390. * @param scene defines the current scene
  106391. * @param rootUrl defines the root URL containing the glow layer information
  106392. * @returns a parsed Glow Layer
  106393. */
  106394. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  106395. }
  106396. }
  106397. declare module BABYLON {
  106398. /** @hidden */
  106399. export var glowBlurPostProcessPixelShader: {
  106400. name: string;
  106401. shader: string;
  106402. };
  106403. }
  106404. declare module BABYLON {
  106405. interface AbstractScene {
  106406. /**
  106407. * Return a the first highlight layer of the scene with a given name.
  106408. * @param name The name of the highlight layer to look for.
  106409. * @return The highlight layer if found otherwise null.
  106410. */
  106411. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  106412. }
  106413. /**
  106414. * Highlight layer options. This helps customizing the behaviour
  106415. * of the highlight layer.
  106416. */
  106417. export interface IHighlightLayerOptions {
  106418. /**
  106419. * Multiplication factor apply to the canvas size to compute the render target size
  106420. * used to generated the glowing objects (the smaller the faster).
  106421. */
  106422. mainTextureRatio: number;
  106423. /**
  106424. * Enforces a fixed size texture to ensure resize independant blur.
  106425. */
  106426. mainTextureFixedSize?: number;
  106427. /**
  106428. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  106429. * of the picture to blur (the smaller the faster).
  106430. */
  106431. blurTextureSizeRatio: number;
  106432. /**
  106433. * How big in texel of the blur texture is the vertical blur.
  106434. */
  106435. blurVerticalSize: number;
  106436. /**
  106437. * How big in texel of the blur texture is the horizontal blur.
  106438. */
  106439. blurHorizontalSize: number;
  106440. /**
  106441. * Alpha blending mode used to apply the blur. Default is combine.
  106442. */
  106443. alphaBlendingMode: number;
  106444. /**
  106445. * The camera attached to the layer.
  106446. */
  106447. camera: Nullable<Camera>;
  106448. /**
  106449. * Should we display highlight as a solid stroke?
  106450. */
  106451. isStroke?: boolean;
  106452. /**
  106453. * The rendering group to draw the layer in.
  106454. */
  106455. renderingGroupId: number;
  106456. }
  106457. /**
  106458. * The highlight layer Helps adding a glow effect around a mesh.
  106459. *
  106460. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106461. * glowy meshes to your scene.
  106462. *
  106463. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  106464. */
  106465. export class HighlightLayer extends EffectLayer {
  106466. name: string;
  106467. /**
  106468. * Effect Name of the highlight layer.
  106469. */
  106470. static readonly EffectName: string;
  106471. /**
  106472. * The neutral color used during the preparation of the glow effect.
  106473. * This is black by default as the blend operation is a blend operation.
  106474. */
  106475. static NeutralColor: Color4;
  106476. /**
  106477. * Stencil value used for glowing meshes.
  106478. */
  106479. static GlowingMeshStencilReference: number;
  106480. /**
  106481. * Stencil value used for the other meshes in the scene.
  106482. */
  106483. static NormalMeshStencilReference: number;
  106484. /**
  106485. * Specifies whether or not the inner glow is ACTIVE in the layer.
  106486. */
  106487. innerGlow: boolean;
  106488. /**
  106489. * Specifies whether or not the outer glow is ACTIVE in the layer.
  106490. */
  106491. outerGlow: boolean;
  106492. /**
  106493. * Specifies the horizontal size of the blur.
  106494. */
  106495. /**
  106496. * Gets the horizontal size of the blur.
  106497. */
  106498. blurHorizontalSize: number;
  106499. /**
  106500. * Specifies the vertical size of the blur.
  106501. */
  106502. /**
  106503. * Gets the vertical size of the blur.
  106504. */
  106505. blurVerticalSize: number;
  106506. /**
  106507. * An event triggered when the highlight layer is being blurred.
  106508. */
  106509. onBeforeBlurObservable: Observable<HighlightLayer>;
  106510. /**
  106511. * An event triggered when the highlight layer has been blurred.
  106512. */
  106513. onAfterBlurObservable: Observable<HighlightLayer>;
  106514. private _instanceGlowingMeshStencilReference;
  106515. private _options;
  106516. private _downSamplePostprocess;
  106517. private _horizontalBlurPostprocess;
  106518. private _verticalBlurPostprocess;
  106519. private _blurTexture;
  106520. private _meshes;
  106521. private _excludedMeshes;
  106522. /**
  106523. * Instantiates a new highlight Layer and references it to the scene..
  106524. * @param name The name of the layer
  106525. * @param scene The scene to use the layer in
  106526. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  106527. */
  106528. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  106529. /**
  106530. * Get the effect name of the layer.
  106531. * @return The effect name
  106532. */
  106533. getEffectName(): string;
  106534. /**
  106535. * Create the merge effect. This is the shader use to blit the information back
  106536. * to the main canvas at the end of the scene rendering.
  106537. */
  106538. protected _createMergeEffect(): Effect;
  106539. /**
  106540. * Creates the render target textures and post processes used in the highlight layer.
  106541. */
  106542. protected _createTextureAndPostProcesses(): void;
  106543. /**
  106544. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106545. */
  106546. needStencil(): boolean;
  106547. /**
  106548. * Checks for the readiness of the element composing the layer.
  106549. * @param subMesh the mesh to check for
  106550. * @param useInstances specify wether or not to use instances to render the mesh
  106551. * @param emissiveTexture the associated emissive texture used to generate the glow
  106552. * @return true if ready otherwise, false
  106553. */
  106554. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106555. /**
  106556. * Implementation specific of rendering the generating effect on the main canvas.
  106557. * @param effect The effect used to render through
  106558. */
  106559. protected _internalRender(effect: Effect): void;
  106560. /**
  106561. * Returns true if the layer contains information to display, otherwise false.
  106562. */
  106563. shouldRender(): boolean;
  106564. /**
  106565. * Returns true if the mesh should render, otherwise false.
  106566. * @param mesh The mesh to render
  106567. * @returns true if it should render otherwise false
  106568. */
  106569. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106570. /**
  106571. * Sets the required values for both the emissive texture and and the main color.
  106572. */
  106573. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106574. /**
  106575. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  106576. * @param mesh The mesh to exclude from the highlight layer
  106577. */
  106578. addExcludedMesh(mesh: Mesh): void;
  106579. /**
  106580. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  106581. * @param mesh The mesh to highlight
  106582. */
  106583. removeExcludedMesh(mesh: Mesh): void;
  106584. /**
  106585. * Determine if a given mesh will be highlighted by the current HighlightLayer
  106586. * @param mesh mesh to test
  106587. * @returns true if the mesh will be highlighted by the current HighlightLayer
  106588. */
  106589. hasMesh(mesh: AbstractMesh): boolean;
  106590. /**
  106591. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  106592. * @param mesh The mesh to highlight
  106593. * @param color The color of the highlight
  106594. * @param glowEmissiveOnly Extract the glow from the emissive texture
  106595. */
  106596. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  106597. /**
  106598. * Remove a mesh from the highlight layer in order to make it stop glowing.
  106599. * @param mesh The mesh to highlight
  106600. */
  106601. removeMesh(mesh: Mesh): void;
  106602. /**
  106603. * Force the stencil to the normal expected value for none glowing parts
  106604. */
  106605. private _defaultStencilReference;
  106606. /**
  106607. * Free any resources and references associated to a mesh.
  106608. * Internal use
  106609. * @param mesh The mesh to free.
  106610. * @hidden
  106611. */
  106612. _disposeMesh(mesh: Mesh): void;
  106613. /**
  106614. * Dispose the highlight layer and free resources.
  106615. */
  106616. dispose(): void;
  106617. /**
  106618. * Gets the class name of the effect layer
  106619. * @returns the string with the class name of the effect layer
  106620. */
  106621. getClassName(): string;
  106622. /**
  106623. * Serializes this Highlight layer
  106624. * @returns a serialized Highlight layer object
  106625. */
  106626. serialize(): any;
  106627. /**
  106628. * Creates a Highlight layer from parsed Highlight layer data
  106629. * @param parsedHightlightLayer defines the Highlight layer data
  106630. * @param scene defines the current scene
  106631. * @param rootUrl defines the root URL containing the Highlight layer information
  106632. * @returns a parsed Highlight layer
  106633. */
  106634. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  106635. }
  106636. }
  106637. declare module BABYLON {
  106638. /** @hidden */
  106639. export var lensFlarePixelShader: {
  106640. name: string;
  106641. shader: string;
  106642. };
  106643. }
  106644. declare module BABYLON {
  106645. /** @hidden */
  106646. export var lensFlareVertexShader: {
  106647. name: string;
  106648. shader: string;
  106649. };
  106650. }
  106651. declare module BABYLON {
  106652. /**
  106653. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106654. * It is usually composed of several `lensFlare`.
  106655. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106656. */
  106657. export class LensFlareSystem {
  106658. /**
  106659. * Define the name of the lens flare system
  106660. */
  106661. name: string;
  106662. /**
  106663. * List of lens flares used in this system.
  106664. */
  106665. lensFlares: LensFlare[];
  106666. /**
  106667. * Define a limit from the border the lens flare can be visible.
  106668. */
  106669. borderLimit: number;
  106670. /**
  106671. * Define a viewport border we do not want to see the lens flare in.
  106672. */
  106673. viewportBorder: number;
  106674. /**
  106675. * Define a predicate which could limit the list of meshes able to occlude the effect.
  106676. */
  106677. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106678. /**
  106679. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  106680. */
  106681. layerMask: number;
  106682. /**
  106683. * Define the id of the lens flare system in the scene.
  106684. * (equal to name by default)
  106685. */
  106686. id: string;
  106687. private _scene;
  106688. private _emitter;
  106689. private _vertexBuffers;
  106690. private _indexBuffer;
  106691. private _effect;
  106692. private _positionX;
  106693. private _positionY;
  106694. private _isEnabled;
  106695. /** @hidden */
  106696. static _SceneComponentInitialization: (scene: Scene) => void;
  106697. /**
  106698. * Instantiates a lens flare system.
  106699. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106700. * It is usually composed of several `lensFlare`.
  106701. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106702. * @param name Define the name of the lens flare system in the scene
  106703. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  106704. * @param scene Define the scene the lens flare system belongs to
  106705. */
  106706. constructor(
  106707. /**
  106708. * Define the name of the lens flare system
  106709. */
  106710. name: string, emitter: any, scene: Scene);
  106711. /**
  106712. * Define if the lens flare system is enabled.
  106713. */
  106714. isEnabled: boolean;
  106715. /**
  106716. * Get the scene the effects belongs to.
  106717. * @returns the scene holding the lens flare system
  106718. */
  106719. getScene(): Scene;
  106720. /**
  106721. * Get the emitter of the lens flare system.
  106722. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106723. * @returns the emitter of the lens flare system
  106724. */
  106725. getEmitter(): any;
  106726. /**
  106727. * Set the emitter of the lens flare system.
  106728. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106729. * @param newEmitter Define the new emitter of the system
  106730. */
  106731. setEmitter(newEmitter: any): void;
  106732. /**
  106733. * Get the lens flare system emitter position.
  106734. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  106735. * @returns the position
  106736. */
  106737. getEmitterPosition(): Vector3;
  106738. /**
  106739. * @hidden
  106740. */
  106741. computeEffectivePosition(globalViewport: Viewport): boolean;
  106742. /** @hidden */
  106743. _isVisible(): boolean;
  106744. /**
  106745. * @hidden
  106746. */
  106747. render(): boolean;
  106748. /**
  106749. * Dispose and release the lens flare with its associated resources.
  106750. */
  106751. dispose(): void;
  106752. /**
  106753. * Parse a lens flare system from a JSON repressentation
  106754. * @param parsedLensFlareSystem Define the JSON to parse
  106755. * @param scene Define the scene the parsed system should be instantiated in
  106756. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  106757. * @returns the parsed system
  106758. */
  106759. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  106760. /**
  106761. * Serialize the current Lens Flare System into a JSON representation.
  106762. * @returns the serialized JSON
  106763. */
  106764. serialize(): any;
  106765. }
  106766. }
  106767. declare module BABYLON {
  106768. /**
  106769. * This represents one of the lens effect in a `lensFlareSystem`.
  106770. * It controls one of the indiviual texture used in the effect.
  106771. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106772. */
  106773. export class LensFlare {
  106774. /**
  106775. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106776. */
  106777. size: number;
  106778. /**
  106779. * 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.
  106780. */
  106781. position: number;
  106782. /**
  106783. * Define the lens color.
  106784. */
  106785. color: Color3;
  106786. /**
  106787. * Define the lens texture.
  106788. */
  106789. texture: Nullable<Texture>;
  106790. /**
  106791. * Define the alpha mode to render this particular lens.
  106792. */
  106793. alphaMode: number;
  106794. private _system;
  106795. /**
  106796. * Creates a new Lens Flare.
  106797. * This represents one of the lens effect in a `lensFlareSystem`.
  106798. * It controls one of the indiviual texture used in the effect.
  106799. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106800. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  106801. * @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.
  106802. * @param color Define the lens color
  106803. * @param imgUrl Define the lens texture url
  106804. * @param system Define the `lensFlareSystem` this flare is part of
  106805. * @returns The newly created Lens Flare
  106806. */
  106807. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  106808. /**
  106809. * Instantiates a new Lens Flare.
  106810. * This represents one of the lens effect in a `lensFlareSystem`.
  106811. * It controls one of the indiviual texture used in the effect.
  106812. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106813. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  106814. * @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.
  106815. * @param color Define the lens color
  106816. * @param imgUrl Define the lens texture url
  106817. * @param system Define the `lensFlareSystem` this flare is part of
  106818. */
  106819. constructor(
  106820. /**
  106821. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106822. */
  106823. size: number,
  106824. /**
  106825. * 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.
  106826. */
  106827. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  106828. /**
  106829. * Dispose and release the lens flare with its associated resources.
  106830. */
  106831. dispose(): void;
  106832. }
  106833. }
  106834. declare module BABYLON {
  106835. interface AbstractScene {
  106836. /**
  106837. * The list of lens flare system added to the scene
  106838. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106839. */
  106840. lensFlareSystems: Array<LensFlareSystem>;
  106841. /**
  106842. * Removes the given lens flare system from this scene.
  106843. * @param toRemove The lens flare system to remove
  106844. * @returns The index of the removed lens flare system
  106845. */
  106846. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  106847. /**
  106848. * Adds the given lens flare system to this scene
  106849. * @param newLensFlareSystem The lens flare system to add
  106850. */
  106851. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  106852. /**
  106853. * Gets a lens flare system using its name
  106854. * @param name defines the name to look for
  106855. * @returns the lens flare system or null if not found
  106856. */
  106857. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  106858. /**
  106859. * Gets a lens flare system using its id
  106860. * @param id defines the id to look for
  106861. * @returns the lens flare system or null if not found
  106862. */
  106863. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  106864. }
  106865. /**
  106866. * Defines the lens flare scene component responsible to manage any lens flares
  106867. * in a given scene.
  106868. */
  106869. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  106870. /**
  106871. * The component name helpfull to identify the component in the list of scene components.
  106872. */
  106873. readonly name: string;
  106874. /**
  106875. * The scene the component belongs to.
  106876. */
  106877. scene: Scene;
  106878. /**
  106879. * Creates a new instance of the component for the given scene
  106880. * @param scene Defines the scene to register the component in
  106881. */
  106882. constructor(scene: Scene);
  106883. /**
  106884. * Registers the component in a given scene
  106885. */
  106886. register(): void;
  106887. /**
  106888. * Rebuilds the elements related to this component in case of
  106889. * context lost for instance.
  106890. */
  106891. rebuild(): void;
  106892. /**
  106893. * Adds all the element from the container to the scene
  106894. * @param container the container holding the elements
  106895. */
  106896. addFromContainer(container: AbstractScene): void;
  106897. /**
  106898. * Removes all the elements in the container from the scene
  106899. * @param container contains the elements to remove
  106900. * @param dispose if the removed element should be disposed (default: false)
  106901. */
  106902. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106903. /**
  106904. * Serializes the component data to the specified json object
  106905. * @param serializationObject The object to serialize to
  106906. */
  106907. serialize(serializationObject: any): void;
  106908. /**
  106909. * Disposes the component and the associated ressources.
  106910. */
  106911. dispose(): void;
  106912. private _draw;
  106913. }
  106914. }
  106915. declare module BABYLON {
  106916. /**
  106917. * Defines the shadow generator component responsible to manage any shadow generators
  106918. * in a given scene.
  106919. */
  106920. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  106921. /**
  106922. * The component name helpfull to identify the component in the list of scene components.
  106923. */
  106924. readonly name: string;
  106925. /**
  106926. * The scene the component belongs to.
  106927. */
  106928. scene: Scene;
  106929. /**
  106930. * Creates a new instance of the component for the given scene
  106931. * @param scene Defines the scene to register the component in
  106932. */
  106933. constructor(scene: Scene);
  106934. /**
  106935. * Registers the component in a given scene
  106936. */
  106937. register(): void;
  106938. /**
  106939. * Rebuilds the elements related to this component in case of
  106940. * context lost for instance.
  106941. */
  106942. rebuild(): void;
  106943. /**
  106944. * Serializes the component data to the specified json object
  106945. * @param serializationObject The object to serialize to
  106946. */
  106947. serialize(serializationObject: any): void;
  106948. /**
  106949. * Adds all the element from the container to the scene
  106950. * @param container the container holding the elements
  106951. */
  106952. addFromContainer(container: AbstractScene): void;
  106953. /**
  106954. * Removes all the elements in the container from the scene
  106955. * @param container contains the elements to remove
  106956. * @param dispose if the removed element should be disposed (default: false)
  106957. */
  106958. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106959. /**
  106960. * Rebuilds the elements related to this component in case of
  106961. * context lost for instance.
  106962. */
  106963. dispose(): void;
  106964. private _gatherRenderTargets;
  106965. }
  106966. }
  106967. declare module BABYLON {
  106968. /**
  106969. * A point light is a light defined by an unique point in world space.
  106970. * The light is emitted in every direction from this point.
  106971. * A good example of a point light is a standard light bulb.
  106972. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106973. */
  106974. export class PointLight extends ShadowLight {
  106975. private _shadowAngle;
  106976. /**
  106977. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106978. * This specifies what angle the shadow will use to be created.
  106979. *
  106980. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106981. */
  106982. /**
  106983. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106984. * This specifies what angle the shadow will use to be created.
  106985. *
  106986. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106987. */
  106988. shadowAngle: number;
  106989. /**
  106990. * Gets the direction if it has been set.
  106991. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106992. */
  106993. /**
  106994. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106995. */
  106996. direction: Vector3;
  106997. /**
  106998. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  106999. * A PointLight emits the light in every direction.
  107000. * It can cast shadows.
  107001. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107002. * ```javascript
  107003. * var pointLight = new PointLight("pl", camera.position, scene);
  107004. * ```
  107005. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107006. * @param name The light friendly name
  107007. * @param position The position of the point light in the scene
  107008. * @param scene The scene the lights belongs to
  107009. */
  107010. constructor(name: string, position: Vector3, scene: Scene);
  107011. /**
  107012. * Returns the string "PointLight"
  107013. * @returns the class name
  107014. */
  107015. getClassName(): string;
  107016. /**
  107017. * Returns the integer 0.
  107018. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107019. */
  107020. getTypeID(): number;
  107021. /**
  107022. * Specifies wether or not the shadowmap should be a cube texture.
  107023. * @returns true if the shadowmap needs to be a cube texture.
  107024. */
  107025. needCube(): boolean;
  107026. /**
  107027. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107028. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107029. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107030. */
  107031. getShadowDirection(faceIndex?: number): Vector3;
  107032. /**
  107033. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107034. * - fov = PI / 2
  107035. * - aspect ratio : 1.0
  107036. * - z-near and far equal to the active camera minZ and maxZ.
  107037. * Returns the PointLight.
  107038. */
  107039. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107040. protected _buildUniformLayout(): void;
  107041. /**
  107042. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107043. * @param effect The effect to update
  107044. * @param lightIndex The index of the light in the effect to update
  107045. * @returns The point light
  107046. */
  107047. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107048. /**
  107049. * Prepares the list of defines specific to the light type.
  107050. * @param defines the list of defines
  107051. * @param lightIndex defines the index of the light for the effect
  107052. */
  107053. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107054. }
  107055. }
  107056. declare module BABYLON {
  107057. /**
  107058. * Header information of HDR texture files.
  107059. */
  107060. export interface HDRInfo {
  107061. /**
  107062. * The height of the texture in pixels.
  107063. */
  107064. height: number;
  107065. /**
  107066. * The width of the texture in pixels.
  107067. */
  107068. width: number;
  107069. /**
  107070. * The index of the beginning of the data in the binary file.
  107071. */
  107072. dataPosition: number;
  107073. }
  107074. /**
  107075. * This groups tools to convert HDR texture to native colors array.
  107076. */
  107077. export class HDRTools {
  107078. private static Ldexp;
  107079. private static Rgbe2float;
  107080. private static readStringLine;
  107081. /**
  107082. * Reads header information from an RGBE texture stored in a native array.
  107083. * More information on this format are available here:
  107084. * https://en.wikipedia.org/wiki/RGBE_image_format
  107085. *
  107086. * @param uint8array The binary file stored in native array.
  107087. * @return The header information.
  107088. */
  107089. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107090. /**
  107091. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107092. * This RGBE texture needs to store the information as a panorama.
  107093. *
  107094. * More information on this format are available here:
  107095. * https://en.wikipedia.org/wiki/RGBE_image_format
  107096. *
  107097. * @param buffer The binary file stored in an array buffer.
  107098. * @param size The expected size of the extracted cubemap.
  107099. * @return The Cube Map information.
  107100. */
  107101. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107102. /**
  107103. * Returns the pixels data extracted from an RGBE texture.
  107104. * This pixels will be stored left to right up to down in the R G B order in one array.
  107105. *
  107106. * More information on this format are available here:
  107107. * https://en.wikipedia.org/wiki/RGBE_image_format
  107108. *
  107109. * @param uint8array The binary file stored in an array buffer.
  107110. * @param hdrInfo The header information of the file.
  107111. * @return The pixels data in RGB right to left up to down order.
  107112. */
  107113. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107114. private static RGBE_ReadPixels_RLE;
  107115. }
  107116. }
  107117. declare module BABYLON {
  107118. /**
  107119. * This represents a texture coming from an HDR input.
  107120. *
  107121. * The only supported format is currently panorama picture stored in RGBE format.
  107122. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107123. */
  107124. export class HDRCubeTexture extends BaseTexture {
  107125. private static _facesMapping;
  107126. private _generateHarmonics;
  107127. private _noMipmap;
  107128. private _textureMatrix;
  107129. private _size;
  107130. private _onLoad;
  107131. private _onError;
  107132. /**
  107133. * The texture URL.
  107134. */
  107135. url: string;
  107136. /**
  107137. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  107138. */
  107139. coordinatesMode: number;
  107140. protected _isBlocking: boolean;
  107141. /**
  107142. * Sets wether or not the texture is blocking during loading.
  107143. */
  107144. /**
  107145. * Gets wether or not the texture is blocking during loading.
  107146. */
  107147. isBlocking: boolean;
  107148. protected _rotationY: number;
  107149. /**
  107150. * Sets texture matrix rotation angle around Y axis in radians.
  107151. */
  107152. /**
  107153. * Gets texture matrix rotation angle around Y axis radians.
  107154. */
  107155. rotationY: number;
  107156. /**
  107157. * Gets or sets the center of the bounding box associated with the cube texture
  107158. * It must define where the camera used to render the texture was set
  107159. */
  107160. boundingBoxPosition: Vector3;
  107161. private _boundingBoxSize;
  107162. /**
  107163. * Gets or sets the size of the bounding box associated with the cube texture
  107164. * When defined, the cubemap will switch to local mode
  107165. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  107166. * @example https://www.babylonjs-playground.com/#RNASML
  107167. */
  107168. boundingBoxSize: Vector3;
  107169. /**
  107170. * Instantiates an HDRTexture from the following parameters.
  107171. *
  107172. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  107173. * @param scene The scene the texture will be used in
  107174. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107175. * @param noMipmap Forces to not generate the mipmap if true
  107176. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  107177. * @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)
  107178. * @param reserved Reserved flag for internal use.
  107179. */
  107180. 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>);
  107181. /**
  107182. * Get the current class name of the texture useful for serialization or dynamic coding.
  107183. * @returns "HDRCubeTexture"
  107184. */
  107185. getClassName(): string;
  107186. /**
  107187. * Occurs when the file is raw .hdr file.
  107188. */
  107189. private loadTexture;
  107190. clone(): HDRCubeTexture;
  107191. delayLoad(): void;
  107192. /**
  107193. * Get the texture reflection matrix used to rotate/transform the reflection.
  107194. * @returns the reflection matrix
  107195. */
  107196. getReflectionTextureMatrix(): Matrix;
  107197. /**
  107198. * Set the texture reflection matrix used to rotate/transform the reflection.
  107199. * @param value Define the reflection matrix to set
  107200. */
  107201. setReflectionTextureMatrix(value: Matrix): void;
  107202. /**
  107203. * Parses a JSON representation of an HDR Texture in order to create the texture
  107204. * @param parsedTexture Define the JSON representation
  107205. * @param scene Define the scene the texture should be created in
  107206. * @param rootUrl Define the root url in case we need to load relative dependencies
  107207. * @returns the newly created texture after parsing
  107208. */
  107209. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  107210. serialize(): any;
  107211. }
  107212. }
  107213. declare module BABYLON {
  107214. /**
  107215. * Class used to control physics engine
  107216. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107217. */
  107218. export class PhysicsEngine implements IPhysicsEngine {
  107219. private _physicsPlugin;
  107220. /**
  107221. * Global value used to control the smallest number supported by the simulation
  107222. */
  107223. static Epsilon: number;
  107224. private _impostors;
  107225. private _joints;
  107226. /**
  107227. * Gets the gravity vector used by the simulation
  107228. */
  107229. gravity: Vector3;
  107230. /**
  107231. * Factory used to create the default physics plugin.
  107232. * @returns The default physics plugin
  107233. */
  107234. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  107235. /**
  107236. * Creates a new Physics Engine
  107237. * @param gravity defines the gravity vector used by the simulation
  107238. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  107239. */
  107240. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  107241. /**
  107242. * Sets the gravity vector used by the simulation
  107243. * @param gravity defines the gravity vector to use
  107244. */
  107245. setGravity(gravity: Vector3): void;
  107246. /**
  107247. * Set the time step of the physics engine.
  107248. * Default is 1/60.
  107249. * To slow it down, enter 1/600 for example.
  107250. * To speed it up, 1/30
  107251. * @param newTimeStep defines the new timestep to apply to this world.
  107252. */
  107253. setTimeStep(newTimeStep?: number): void;
  107254. /**
  107255. * Get the time step of the physics engine.
  107256. * @returns the current time step
  107257. */
  107258. getTimeStep(): number;
  107259. /**
  107260. * Release all resources
  107261. */
  107262. dispose(): void;
  107263. /**
  107264. * Gets the name of the current physics plugin
  107265. * @returns the name of the plugin
  107266. */
  107267. getPhysicsPluginName(): string;
  107268. /**
  107269. * Adding a new impostor for the impostor tracking.
  107270. * This will be done by the impostor itself.
  107271. * @param impostor the impostor to add
  107272. */
  107273. addImpostor(impostor: PhysicsImpostor): void;
  107274. /**
  107275. * Remove an impostor from the engine.
  107276. * This impostor and its mesh will not longer be updated by the physics engine.
  107277. * @param impostor the impostor to remove
  107278. */
  107279. removeImpostor(impostor: PhysicsImpostor): void;
  107280. /**
  107281. * Add a joint to the physics engine
  107282. * @param mainImpostor defines the main impostor to which the joint is added.
  107283. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107284. * @param joint defines the joint that will connect both impostors.
  107285. */
  107286. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107287. /**
  107288. * Removes a joint from the simulation
  107289. * @param mainImpostor defines the impostor used with the joint
  107290. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107291. * @param joint defines the joint to remove
  107292. */
  107293. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107294. /**
  107295. * Called by the scene. No need to call it.
  107296. * @param delta defines the timespam between frames
  107297. */
  107298. _step(delta: number): void;
  107299. /**
  107300. * Gets the current plugin used to run the simulation
  107301. * @returns current plugin
  107302. */
  107303. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107304. /**
  107305. * Gets the list of physic impostors
  107306. * @returns an array of PhysicsImpostor
  107307. */
  107308. getImpostors(): Array<PhysicsImpostor>;
  107309. /**
  107310. * Gets the impostor for a physics enabled object
  107311. * @param object defines the object impersonated by the impostor
  107312. * @returns the PhysicsImpostor or null if not found
  107313. */
  107314. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107315. /**
  107316. * Gets the impostor for a physics body object
  107317. * @param body defines physics body used by the impostor
  107318. * @returns the PhysicsImpostor or null if not found
  107319. */
  107320. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107321. /**
  107322. * Does a raycast in the physics world
  107323. * @param from when should the ray start?
  107324. * @param to when should the ray end?
  107325. * @returns PhysicsRaycastResult
  107326. */
  107327. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107328. }
  107329. }
  107330. declare module BABYLON {
  107331. /** @hidden */
  107332. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  107333. private _useDeltaForWorldStep;
  107334. world: any;
  107335. name: string;
  107336. private _physicsMaterials;
  107337. private _fixedTimeStep;
  107338. private _cannonRaycastResult;
  107339. private _raycastResult;
  107340. private _removeAfterStep;
  107341. BJSCANNON: any;
  107342. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  107343. setGravity(gravity: Vector3): void;
  107344. setTimeStep(timeStep: number): void;
  107345. getTimeStep(): number;
  107346. executeStep(delta: number): void;
  107347. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107348. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107349. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107350. private _processChildMeshes;
  107351. removePhysicsBody(impostor: PhysicsImpostor): void;
  107352. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107353. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107354. private _addMaterial;
  107355. private _checkWithEpsilon;
  107356. private _createShape;
  107357. private _createHeightmap;
  107358. private _minus90X;
  107359. private _plus90X;
  107360. private _tmpPosition;
  107361. private _tmpDeltaPosition;
  107362. private _tmpUnityRotation;
  107363. private _updatePhysicsBodyTransformation;
  107364. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107365. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107366. isSupported(): boolean;
  107367. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107368. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107369. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107370. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107371. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107372. getBodyMass(impostor: PhysicsImpostor): number;
  107373. getBodyFriction(impostor: PhysicsImpostor): number;
  107374. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107375. getBodyRestitution(impostor: PhysicsImpostor): number;
  107376. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107377. sleepBody(impostor: PhysicsImpostor): void;
  107378. wakeUpBody(impostor: PhysicsImpostor): void;
  107379. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  107380. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107381. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107382. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107383. getRadius(impostor: PhysicsImpostor): number;
  107384. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107385. dispose(): void;
  107386. private _extendNamespace;
  107387. /**
  107388. * Does a raycast in the physics world
  107389. * @param from when should the ray start?
  107390. * @param to when should the ray end?
  107391. * @returns PhysicsRaycastResult
  107392. */
  107393. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107394. }
  107395. }
  107396. declare module BABYLON {
  107397. /** @hidden */
  107398. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  107399. world: any;
  107400. name: string;
  107401. BJSOIMO: any;
  107402. private _raycastResult;
  107403. constructor(iterations?: number, oimoInjection?: any);
  107404. setGravity(gravity: Vector3): void;
  107405. setTimeStep(timeStep: number): void;
  107406. getTimeStep(): number;
  107407. private _tmpImpostorsArray;
  107408. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107409. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107410. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107411. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107412. private _tmpPositionVector;
  107413. removePhysicsBody(impostor: PhysicsImpostor): void;
  107414. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107415. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107416. isSupported(): boolean;
  107417. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107418. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107419. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107420. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107421. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107422. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107423. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107424. getBodyMass(impostor: PhysicsImpostor): number;
  107425. getBodyFriction(impostor: PhysicsImpostor): number;
  107426. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107427. getBodyRestitution(impostor: PhysicsImpostor): number;
  107428. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107429. sleepBody(impostor: PhysicsImpostor): void;
  107430. wakeUpBody(impostor: PhysicsImpostor): void;
  107431. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107432. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  107433. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107434. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107435. getRadius(impostor: PhysicsImpostor): number;
  107436. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107437. dispose(): void;
  107438. /**
  107439. * Does a raycast in the physics world
  107440. * @param from when should the ray start?
  107441. * @param to when should the ray end?
  107442. * @returns PhysicsRaycastResult
  107443. */
  107444. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107445. }
  107446. }
  107447. declare module BABYLON {
  107448. /**
  107449. * Class containing static functions to help procedurally build meshes
  107450. */
  107451. export class RibbonBuilder {
  107452. /**
  107453. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107454. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107455. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107456. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107457. * * 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
  107458. * * 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
  107459. * * 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
  107460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107462. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107463. * * 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
  107464. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107465. * * 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
  107466. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107468. * @param name defines the name of the mesh
  107469. * @param options defines the options used to create the mesh
  107470. * @param scene defines the hosting scene
  107471. * @returns the ribbon mesh
  107472. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107473. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107474. */
  107475. static CreateRibbon(name: string, options: {
  107476. pathArray: Vector3[][];
  107477. closeArray?: boolean;
  107478. closePath?: boolean;
  107479. offset?: number;
  107480. updatable?: boolean;
  107481. sideOrientation?: number;
  107482. frontUVs?: Vector4;
  107483. backUVs?: Vector4;
  107484. instance?: Mesh;
  107485. invertUV?: boolean;
  107486. uvs?: Vector2[];
  107487. colors?: Color4[];
  107488. }, scene?: Nullable<Scene>): Mesh;
  107489. }
  107490. }
  107491. declare module BABYLON {
  107492. /**
  107493. * Class containing static functions to help procedurally build meshes
  107494. */
  107495. export class ShapeBuilder {
  107496. /**
  107497. * 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.
  107498. * * 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.
  107499. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107500. * * 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.
  107501. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107502. * * 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
  107503. * * 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
  107504. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107507. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107509. * @param name defines the name of the mesh
  107510. * @param options defines the options used to create the mesh
  107511. * @param scene defines the hosting scene
  107512. * @returns the extruded shape mesh
  107513. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107515. */
  107516. static ExtrudeShape(name: string, options: {
  107517. shape: Vector3[];
  107518. path: Vector3[];
  107519. scale?: number;
  107520. rotation?: number;
  107521. cap?: number;
  107522. updatable?: boolean;
  107523. sideOrientation?: number;
  107524. frontUVs?: Vector4;
  107525. backUVs?: Vector4;
  107526. instance?: Mesh;
  107527. invertUV?: boolean;
  107528. }, scene?: Nullable<Scene>): Mesh;
  107529. /**
  107530. * Creates an custom extruded shape mesh.
  107531. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107532. * * 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.
  107533. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107534. * * 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
  107535. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107536. * * 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
  107537. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107538. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107539. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107540. * * 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
  107541. * * 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
  107542. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107545. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107547. * @param name defines the name of the mesh
  107548. * @param options defines the options used to create the mesh
  107549. * @param scene defines the hosting scene
  107550. * @returns the custom extruded shape mesh
  107551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107552. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107554. */
  107555. static ExtrudeShapeCustom(name: string, options: {
  107556. shape: Vector3[];
  107557. path: Vector3[];
  107558. scaleFunction?: any;
  107559. rotationFunction?: any;
  107560. ribbonCloseArray?: boolean;
  107561. ribbonClosePath?: boolean;
  107562. cap?: number;
  107563. updatable?: boolean;
  107564. sideOrientation?: number;
  107565. frontUVs?: Vector4;
  107566. backUVs?: Vector4;
  107567. instance?: Mesh;
  107568. invertUV?: boolean;
  107569. }, scene?: Nullable<Scene>): Mesh;
  107570. private static _ExtrudeShapeGeneric;
  107571. }
  107572. }
  107573. declare module BABYLON {
  107574. /**
  107575. * AmmoJS Physics plugin
  107576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107577. * @see https://github.com/kripken/ammo.js/
  107578. */
  107579. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107580. private _useDeltaForWorldStep;
  107581. /**
  107582. * Reference to the Ammo library
  107583. */
  107584. bjsAMMO: any;
  107585. /**
  107586. * Created ammoJS world which physics bodies are added to
  107587. */
  107588. world: any;
  107589. /**
  107590. * Name of the plugin
  107591. */
  107592. name: string;
  107593. private _timeStep;
  107594. private _fixedTimeStep;
  107595. private _maxSteps;
  107596. private _tmpQuaternion;
  107597. private _tmpAmmoTransform;
  107598. private _tmpAmmoQuaternion;
  107599. private _tmpAmmoConcreteContactResultCallback;
  107600. private _collisionConfiguration;
  107601. private _dispatcher;
  107602. private _overlappingPairCache;
  107603. private _solver;
  107604. private _softBodySolver;
  107605. private _tmpAmmoVectorA;
  107606. private _tmpAmmoVectorB;
  107607. private _tmpAmmoVectorC;
  107608. private _tmpAmmoVectorD;
  107609. private _tmpContactCallbackResult;
  107610. private _tmpAmmoVectorRCA;
  107611. private _tmpAmmoVectorRCB;
  107612. private _raycastResult;
  107613. private static readonly DISABLE_COLLISION_FLAG;
  107614. private static readonly KINEMATIC_FLAG;
  107615. private static readonly DISABLE_DEACTIVATION_FLAG;
  107616. /**
  107617. * Initializes the ammoJS plugin
  107618. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107619. * @param ammoInjection can be used to inject your own ammo reference
  107620. */
  107621. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107622. /**
  107623. * Sets the gravity of the physics world (m/(s^2))
  107624. * @param gravity Gravity to set
  107625. */
  107626. setGravity(gravity: Vector3): void;
  107627. /**
  107628. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107629. * @param timeStep timestep to use in seconds
  107630. */
  107631. setTimeStep(timeStep: number): void;
  107632. /**
  107633. * 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)
  107634. * @param fixedTimeStep fixedTimeStep to use in seconds
  107635. */
  107636. setFixedTimeStep(fixedTimeStep: number): void;
  107637. /**
  107638. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107639. * @param maxSteps the maximum number of steps by the physics engine per frame
  107640. */
  107641. setMaxSteps(maxSteps: number): void;
  107642. /**
  107643. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107644. * @returns the current timestep in seconds
  107645. */
  107646. getTimeStep(): number;
  107647. private _isImpostorInContact;
  107648. private _isImpostorPairInContact;
  107649. private _stepSimulation;
  107650. /**
  107651. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107652. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107653. * After the step the babylon meshes are set to the position of the physics imposters
  107654. * @param delta amount of time to step forward
  107655. * @param impostors array of imposters to update before/after the step
  107656. */
  107657. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107658. /**
  107659. * Update babylon mesh to match physics world object
  107660. * @param impostor imposter to match
  107661. */
  107662. private _afterSoftStep;
  107663. /**
  107664. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107665. * @param impostor imposter to match
  107666. */
  107667. private _ropeStep;
  107668. /**
  107669. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107670. * @param impostor imposter to match
  107671. */
  107672. private _softbodyOrClothStep;
  107673. private _tmpVector;
  107674. private _tmpMatrix;
  107675. /**
  107676. * Applies an impulse on the imposter
  107677. * @param impostor imposter to apply impulse to
  107678. * @param force amount of force to be applied to the imposter
  107679. * @param contactPoint the location to apply the impulse on the imposter
  107680. */
  107681. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107682. /**
  107683. * Applies a force on the imposter
  107684. * @param impostor imposter to apply force
  107685. * @param force amount of force to be applied to the imposter
  107686. * @param contactPoint the location to apply the force on the imposter
  107687. */
  107688. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107689. /**
  107690. * Creates a physics body using the plugin
  107691. * @param impostor the imposter to create the physics body on
  107692. */
  107693. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107694. /**
  107695. * Removes the physics body from the imposter and disposes of the body's memory
  107696. * @param impostor imposter to remove the physics body from
  107697. */
  107698. removePhysicsBody(impostor: PhysicsImpostor): void;
  107699. /**
  107700. * Generates a joint
  107701. * @param impostorJoint the imposter joint to create the joint with
  107702. */
  107703. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107704. /**
  107705. * Removes a joint
  107706. * @param impostorJoint the imposter joint to remove the joint from
  107707. */
  107708. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107709. private _addMeshVerts;
  107710. /**
  107711. * Initialise the soft body vertices to match its object's (mesh) vertices
  107712. * Softbody vertices (nodes) are in world space and to match this
  107713. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  107714. * @param impostor to create the softbody for
  107715. */
  107716. private _softVertexData;
  107717. /**
  107718. * Create an impostor's soft body
  107719. * @param impostor to create the softbody for
  107720. */
  107721. private _createSoftbody;
  107722. /**
  107723. * Create cloth for an impostor
  107724. * @param impostor to create the softbody for
  107725. */
  107726. private _createCloth;
  107727. /**
  107728. * Create rope for an impostor
  107729. * @param impostor to create the softbody for
  107730. */
  107731. private _createRope;
  107732. private _addHullVerts;
  107733. private _createShape;
  107734. /**
  107735. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107736. * @param impostor imposter containing the physics body and babylon object
  107737. */
  107738. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107739. /**
  107740. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107741. * @param impostor imposter containing the physics body and babylon object
  107742. * @param newPosition new position
  107743. * @param newRotation new rotation
  107744. */
  107745. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107746. /**
  107747. * If this plugin is supported
  107748. * @returns true if its supported
  107749. */
  107750. isSupported(): boolean;
  107751. /**
  107752. * Sets the linear velocity of the physics body
  107753. * @param impostor imposter to set the velocity on
  107754. * @param velocity velocity to set
  107755. */
  107756. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107757. /**
  107758. * Sets the angular velocity of the physics body
  107759. * @param impostor imposter to set the velocity on
  107760. * @param velocity velocity to set
  107761. */
  107762. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107763. /**
  107764. * gets the linear velocity
  107765. * @param impostor imposter to get linear velocity from
  107766. * @returns linear velocity
  107767. */
  107768. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107769. /**
  107770. * gets the angular velocity
  107771. * @param impostor imposter to get angular velocity from
  107772. * @returns angular velocity
  107773. */
  107774. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107775. /**
  107776. * Sets the mass of physics body
  107777. * @param impostor imposter to set the mass on
  107778. * @param mass mass to set
  107779. */
  107780. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107781. /**
  107782. * Gets the mass of the physics body
  107783. * @param impostor imposter to get the mass from
  107784. * @returns mass
  107785. */
  107786. getBodyMass(impostor: PhysicsImpostor): number;
  107787. /**
  107788. * Gets friction of the impostor
  107789. * @param impostor impostor to get friction from
  107790. * @returns friction value
  107791. */
  107792. getBodyFriction(impostor: PhysicsImpostor): number;
  107793. /**
  107794. * Sets friction of the impostor
  107795. * @param impostor impostor to set friction on
  107796. * @param friction friction value
  107797. */
  107798. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107799. /**
  107800. * Gets restitution of the impostor
  107801. * @param impostor impostor to get restitution from
  107802. * @returns restitution value
  107803. */
  107804. getBodyRestitution(impostor: PhysicsImpostor): number;
  107805. /**
  107806. * Sets resitution of the impostor
  107807. * @param impostor impostor to set resitution on
  107808. * @param restitution resitution value
  107809. */
  107810. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107811. /**
  107812. * Gets pressure inside the impostor
  107813. * @param impostor impostor to get pressure from
  107814. * @returns pressure value
  107815. */
  107816. getBodyPressure(impostor: PhysicsImpostor): number;
  107817. /**
  107818. * Sets pressure inside a soft body impostor
  107819. * Cloth and rope must remain 0 pressure
  107820. * @param impostor impostor to set pressure on
  107821. * @param pressure pressure value
  107822. */
  107823. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  107824. /**
  107825. * Gets stiffness of the impostor
  107826. * @param impostor impostor to get stiffness from
  107827. * @returns pressure value
  107828. */
  107829. getBodyStiffness(impostor: PhysicsImpostor): number;
  107830. /**
  107831. * Sets stiffness of the impostor
  107832. * @param impostor impostor to set stiffness on
  107833. * @param stiffness stiffness value from 0 to 1
  107834. */
  107835. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  107836. /**
  107837. * Gets velocityIterations of the impostor
  107838. * @param impostor impostor to get velocity iterations from
  107839. * @returns velocityIterations value
  107840. */
  107841. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  107842. /**
  107843. * Sets velocityIterations of the impostor
  107844. * @param impostor impostor to set velocity iterations on
  107845. * @param velocityIterations velocityIterations value
  107846. */
  107847. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  107848. /**
  107849. * Gets positionIterations of the impostor
  107850. * @param impostor impostor to get position iterations from
  107851. * @returns positionIterations value
  107852. */
  107853. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  107854. /**
  107855. * Sets positionIterations of the impostor
  107856. * @param impostor impostor to set position on
  107857. * @param positionIterations positionIterations value
  107858. */
  107859. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  107860. /**
  107861. * Append an anchor to a cloth object
  107862. * @param impostor is the cloth impostor to add anchor to
  107863. * @param otherImpostor is the rigid impostor to anchor to
  107864. * @param width ratio across width from 0 to 1
  107865. * @param height ratio up height from 0 to 1
  107866. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107867. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107868. */
  107869. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107870. /**
  107871. * Append an hook to a rope object
  107872. * @param impostor is the rope impostor to add hook to
  107873. * @param otherImpostor is the rigid impostor to hook to
  107874. * @param length ratio along the rope from 0 to 1
  107875. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  107876. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107877. */
  107878. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107879. /**
  107880. * Sleeps the physics body and stops it from being active
  107881. * @param impostor impostor to sleep
  107882. */
  107883. sleepBody(impostor: PhysicsImpostor): void;
  107884. /**
  107885. * Activates the physics body
  107886. * @param impostor impostor to activate
  107887. */
  107888. wakeUpBody(impostor: PhysicsImpostor): void;
  107889. /**
  107890. * Updates the distance parameters of the joint
  107891. * @param joint joint to update
  107892. * @param maxDistance maximum distance of the joint
  107893. * @param minDistance minimum distance of the joint
  107894. */
  107895. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107896. /**
  107897. * Sets a motor on the joint
  107898. * @param joint joint to set motor on
  107899. * @param speed speed of the motor
  107900. * @param maxForce maximum force of the motor
  107901. * @param motorIndex index of the motor
  107902. */
  107903. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107904. /**
  107905. * Sets the motors limit
  107906. * @param joint joint to set limit on
  107907. * @param upperLimit upper limit
  107908. * @param lowerLimit lower limit
  107909. */
  107910. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107911. /**
  107912. * Syncs the position and rotation of a mesh with the impostor
  107913. * @param mesh mesh to sync
  107914. * @param impostor impostor to update the mesh with
  107915. */
  107916. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107917. /**
  107918. * Gets the radius of the impostor
  107919. * @param impostor impostor to get radius from
  107920. * @returns the radius
  107921. */
  107922. getRadius(impostor: PhysicsImpostor): number;
  107923. /**
  107924. * Gets the box size of the impostor
  107925. * @param impostor impostor to get box size from
  107926. * @param result the resulting box size
  107927. */
  107928. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107929. /**
  107930. * Disposes of the impostor
  107931. */
  107932. dispose(): void;
  107933. /**
  107934. * Does a raycast in the physics world
  107935. * @param from when should the ray start?
  107936. * @param to when should the ray end?
  107937. * @returns PhysicsRaycastResult
  107938. */
  107939. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107940. }
  107941. }
  107942. declare module BABYLON {
  107943. interface AbstractScene {
  107944. /**
  107945. * The list of reflection probes added to the scene
  107946. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107947. */
  107948. reflectionProbes: Array<ReflectionProbe>;
  107949. /**
  107950. * Removes the given reflection probe from this scene.
  107951. * @param toRemove The reflection probe to remove
  107952. * @returns The index of the removed reflection probe
  107953. */
  107954. removeReflectionProbe(toRemove: ReflectionProbe): number;
  107955. /**
  107956. * Adds the given reflection probe to this scene.
  107957. * @param newReflectionProbe The reflection probe to add
  107958. */
  107959. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  107960. }
  107961. /**
  107962. * Class used to generate realtime reflection / refraction cube textures
  107963. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107964. */
  107965. export class ReflectionProbe {
  107966. /** defines the name of the probe */
  107967. name: string;
  107968. private _scene;
  107969. private _renderTargetTexture;
  107970. private _projectionMatrix;
  107971. private _viewMatrix;
  107972. private _target;
  107973. private _add;
  107974. private _attachedMesh;
  107975. private _invertYAxis;
  107976. /** Gets or sets probe position (center of the cube map) */
  107977. position: Vector3;
  107978. /**
  107979. * Creates a new reflection probe
  107980. * @param name defines the name of the probe
  107981. * @param size defines the texture resolution (for each face)
  107982. * @param scene defines the hosting scene
  107983. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  107984. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  107985. */
  107986. constructor(
  107987. /** defines the name of the probe */
  107988. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  107989. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  107990. samples: number;
  107991. /** Gets or sets the refresh rate to use (on every frame by default) */
  107992. refreshRate: number;
  107993. /**
  107994. * Gets the hosting scene
  107995. * @returns a Scene
  107996. */
  107997. getScene(): Scene;
  107998. /** Gets the internal CubeTexture used to render to */
  107999. readonly cubeTexture: RenderTargetTexture;
  108000. /** Gets the list of meshes to render */
  108001. readonly renderList: Nullable<AbstractMesh[]>;
  108002. /**
  108003. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108004. * @param mesh defines the mesh to attach to
  108005. */
  108006. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108007. /**
  108008. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108009. * @param renderingGroupId The rendering group id corresponding to its index
  108010. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108011. */
  108012. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108013. /**
  108014. * Clean all associated resources
  108015. */
  108016. dispose(): void;
  108017. /**
  108018. * Converts the reflection probe information to a readable string for debug purpose.
  108019. * @param fullDetails Supports for multiple levels of logging within scene loading
  108020. * @returns the human readable reflection probe info
  108021. */
  108022. toString(fullDetails?: boolean): string;
  108023. /**
  108024. * Get the class name of the relfection probe.
  108025. * @returns "ReflectionProbe"
  108026. */
  108027. getClassName(): string;
  108028. /**
  108029. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108030. * @returns The JSON representation of the texture
  108031. */
  108032. serialize(): any;
  108033. /**
  108034. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108035. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108036. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108037. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108038. * @returns The parsed reflection probe if successful
  108039. */
  108040. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108041. }
  108042. }
  108043. declare module BABYLON {
  108044. /** @hidden */
  108045. export var _BabylonLoaderRegistered: boolean;
  108046. }
  108047. declare module BABYLON {
  108048. /**
  108049. * The Physically based simple base material of BJS.
  108050. *
  108051. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108052. * It is used as the base class for both the specGloss and metalRough conventions.
  108053. */
  108054. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108055. /**
  108056. * Number of Simultaneous lights allowed on the material.
  108057. */
  108058. maxSimultaneousLights: number;
  108059. /**
  108060. * If sets to true, disables all the lights affecting the material.
  108061. */
  108062. disableLighting: boolean;
  108063. /**
  108064. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108065. */
  108066. environmentTexture: BaseTexture;
  108067. /**
  108068. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108069. */
  108070. invertNormalMapX: boolean;
  108071. /**
  108072. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108073. */
  108074. invertNormalMapY: boolean;
  108075. /**
  108076. * Normal map used in the model.
  108077. */
  108078. normalTexture: BaseTexture;
  108079. /**
  108080. * Emissivie color used to self-illuminate the model.
  108081. */
  108082. emissiveColor: Color3;
  108083. /**
  108084. * Emissivie texture used to self-illuminate the model.
  108085. */
  108086. emissiveTexture: BaseTexture;
  108087. /**
  108088. * Occlusion Channel Strenght.
  108089. */
  108090. occlusionStrength: number;
  108091. /**
  108092. * Occlusion Texture of the material (adding extra occlusion effects).
  108093. */
  108094. occlusionTexture: BaseTexture;
  108095. /**
  108096. * Defines the alpha limits in alpha test mode.
  108097. */
  108098. alphaCutOff: number;
  108099. /**
  108100. * Gets the current double sided mode.
  108101. */
  108102. /**
  108103. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108104. */
  108105. doubleSided: boolean;
  108106. /**
  108107. * Stores the pre-calculated light information of a mesh in a texture.
  108108. */
  108109. lightmapTexture: BaseTexture;
  108110. /**
  108111. * If true, the light map contains occlusion information instead of lighting info.
  108112. */
  108113. useLightmapAsShadowmap: boolean;
  108114. /**
  108115. * Instantiates a new PBRMaterial instance.
  108116. *
  108117. * @param name The material name
  108118. * @param scene The scene the material will be use in.
  108119. */
  108120. constructor(name: string, scene: Scene);
  108121. getClassName(): string;
  108122. }
  108123. }
  108124. declare module BABYLON {
  108125. /**
  108126. * The PBR material of BJS following the metal roughness convention.
  108127. *
  108128. * This fits to the PBR convention in the GLTF definition:
  108129. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108130. */
  108131. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108132. /**
  108133. * The base color has two different interpretations depending on the value of metalness.
  108134. * When the material is a metal, the base color is the specific measured reflectance value
  108135. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108136. * of the material.
  108137. */
  108138. baseColor: Color3;
  108139. /**
  108140. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  108141. * well as opacity information in the alpha channel.
  108142. */
  108143. baseTexture: BaseTexture;
  108144. /**
  108145. * Specifies the metallic scalar value of the material.
  108146. * Can also be used to scale the metalness values of the metallic texture.
  108147. */
  108148. metallic: number;
  108149. /**
  108150. * Specifies the roughness scalar value of the material.
  108151. * Can also be used to scale the roughness values of the metallic texture.
  108152. */
  108153. roughness: number;
  108154. /**
  108155. * Texture containing both the metallic value in the B channel and the
  108156. * roughness value in the G channel to keep better precision.
  108157. */
  108158. metallicRoughnessTexture: BaseTexture;
  108159. /**
  108160. * Instantiates a new PBRMetalRoughnessMaterial instance.
  108161. *
  108162. * @param name The material name
  108163. * @param scene The scene the material will be use in.
  108164. */
  108165. constructor(name: string, scene: Scene);
  108166. /**
  108167. * Return the currrent class name of the material.
  108168. */
  108169. getClassName(): string;
  108170. /**
  108171. * Makes a duplicate of the current material.
  108172. * @param name - name to use for the new material.
  108173. */
  108174. clone(name: string): PBRMetallicRoughnessMaterial;
  108175. /**
  108176. * Serialize the material to a parsable JSON object.
  108177. */
  108178. serialize(): any;
  108179. /**
  108180. * Parses a JSON object correponding to the serialize function.
  108181. */
  108182. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  108183. }
  108184. }
  108185. declare module BABYLON {
  108186. /**
  108187. * The PBR material of BJS following the specular glossiness convention.
  108188. *
  108189. * This fits to the PBR convention in the GLTF definition:
  108190. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  108191. */
  108192. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  108193. /**
  108194. * Specifies the diffuse color of the material.
  108195. */
  108196. diffuseColor: Color3;
  108197. /**
  108198. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  108199. * channel.
  108200. */
  108201. diffuseTexture: BaseTexture;
  108202. /**
  108203. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  108204. */
  108205. specularColor: Color3;
  108206. /**
  108207. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  108208. */
  108209. glossiness: number;
  108210. /**
  108211. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  108212. */
  108213. specularGlossinessTexture: BaseTexture;
  108214. /**
  108215. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  108216. *
  108217. * @param name The material name
  108218. * @param scene The scene the material will be use in.
  108219. */
  108220. constructor(name: string, scene: Scene);
  108221. /**
  108222. * Return the currrent class name of the material.
  108223. */
  108224. getClassName(): string;
  108225. /**
  108226. * Makes a duplicate of the current material.
  108227. * @param name - name to use for the new material.
  108228. */
  108229. clone(name: string): PBRSpecularGlossinessMaterial;
  108230. /**
  108231. * Serialize the material to a parsable JSON object.
  108232. */
  108233. serialize(): any;
  108234. /**
  108235. * Parses a JSON object correponding to the serialize function.
  108236. */
  108237. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  108238. }
  108239. }
  108240. declare module BABYLON {
  108241. /**
  108242. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  108243. * It can help converting any input color in a desired output one. This can then be used to create effects
  108244. * from sepia, black and white to sixties or futuristic rendering...
  108245. *
  108246. * The only supported format is currently 3dl.
  108247. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  108248. */
  108249. export class ColorGradingTexture extends BaseTexture {
  108250. /**
  108251. * The current texture matrix. (will always be identity in color grading texture)
  108252. */
  108253. private _textureMatrix;
  108254. /**
  108255. * The texture URL.
  108256. */
  108257. url: string;
  108258. /**
  108259. * Empty line regex stored for GC.
  108260. */
  108261. private static _noneEmptyLineRegex;
  108262. private _engine;
  108263. /**
  108264. * Instantiates a ColorGradingTexture from the following parameters.
  108265. *
  108266. * @param url The location of the color gradind data (currently only supporting 3dl)
  108267. * @param scene The scene the texture will be used in
  108268. */
  108269. constructor(url: string, scene: Scene);
  108270. /**
  108271. * Returns the texture matrix used in most of the material.
  108272. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  108273. */
  108274. getTextureMatrix(): Matrix;
  108275. /**
  108276. * Occurs when the file being loaded is a .3dl LUT file.
  108277. */
  108278. private load3dlTexture;
  108279. /**
  108280. * Starts the loading process of the texture.
  108281. */
  108282. private loadTexture;
  108283. /**
  108284. * Clones the color gradind texture.
  108285. */
  108286. clone(): ColorGradingTexture;
  108287. /**
  108288. * Called during delayed load for textures.
  108289. */
  108290. delayLoad(): void;
  108291. /**
  108292. * Parses a color grading texture serialized by Babylon.
  108293. * @param parsedTexture The texture information being parsedTexture
  108294. * @param scene The scene to load the texture in
  108295. * @param rootUrl The root url of the data assets to load
  108296. * @return A color gradind texture
  108297. */
  108298. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  108299. /**
  108300. * Serializes the LUT texture to json format.
  108301. */
  108302. serialize(): any;
  108303. }
  108304. }
  108305. declare module BABYLON {
  108306. /**
  108307. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  108308. */
  108309. export class EquiRectangularCubeTexture extends BaseTexture {
  108310. /** The six faces of the cube. */
  108311. private static _FacesMapping;
  108312. private _noMipmap;
  108313. private _onLoad;
  108314. private _onError;
  108315. /** The size of the cubemap. */
  108316. private _size;
  108317. /** The buffer of the image. */
  108318. private _buffer;
  108319. /** The width of the input image. */
  108320. private _width;
  108321. /** The height of the input image. */
  108322. private _height;
  108323. /** The URL to the image. */
  108324. url: string;
  108325. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  108326. coordinatesMode: number;
  108327. /**
  108328. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  108329. * @param url The location of the image
  108330. * @param scene The scene the texture will be used in
  108331. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108332. * @param noMipmap Forces to not generate the mipmap if true
  108333. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  108334. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  108335. * @param onLoad — defines a callback called when texture is loaded
  108336. * @param onError — defines a callback called if there is an error
  108337. */
  108338. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  108339. /**
  108340. * Load the image data, by putting the image on a canvas and extracting its buffer.
  108341. */
  108342. private loadImage;
  108343. /**
  108344. * Convert the image buffer into a cubemap and create a CubeTexture.
  108345. */
  108346. private loadTexture;
  108347. /**
  108348. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  108349. * @param buffer The ArrayBuffer that should be converted.
  108350. * @returns The buffer as Float32Array.
  108351. */
  108352. private getFloat32ArrayFromArrayBuffer;
  108353. /**
  108354. * Get the current class name of the texture useful for serialization or dynamic coding.
  108355. * @returns "EquiRectangularCubeTexture"
  108356. */
  108357. getClassName(): string;
  108358. /**
  108359. * Create a clone of the current EquiRectangularCubeTexture and return it.
  108360. * @returns A clone of the current EquiRectangularCubeTexture.
  108361. */
  108362. clone(): EquiRectangularCubeTexture;
  108363. }
  108364. }
  108365. declare module BABYLON {
  108366. /**
  108367. * Based on jsTGALoader - Javascript loader for TGA file
  108368. * By Vincent Thibault
  108369. * @see http://blog.robrowser.com/javascript-tga-loader.html
  108370. */
  108371. export class TGATools {
  108372. private static _TYPE_INDEXED;
  108373. private static _TYPE_RGB;
  108374. private static _TYPE_GREY;
  108375. private static _TYPE_RLE_INDEXED;
  108376. private static _TYPE_RLE_RGB;
  108377. private static _TYPE_RLE_GREY;
  108378. private static _ORIGIN_MASK;
  108379. private static _ORIGIN_SHIFT;
  108380. private static _ORIGIN_BL;
  108381. private static _ORIGIN_BR;
  108382. private static _ORIGIN_UL;
  108383. private static _ORIGIN_UR;
  108384. /**
  108385. * Gets the header of a TGA file
  108386. * @param data defines the TGA data
  108387. * @returns the header
  108388. */
  108389. static GetTGAHeader(data: Uint8Array): any;
  108390. /**
  108391. * Uploads TGA content to a Babylon Texture
  108392. * @hidden
  108393. */
  108394. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  108395. /** @hidden */
  108396. 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;
  108397. /** @hidden */
  108398. 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;
  108399. /** @hidden */
  108400. 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;
  108401. /** @hidden */
  108402. 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;
  108403. /** @hidden */
  108404. 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;
  108405. /** @hidden */
  108406. 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;
  108407. }
  108408. }
  108409. declare module BABYLON {
  108410. /**
  108411. * Implementation of the TGA Texture Loader.
  108412. * @hidden
  108413. */
  108414. export class _TGATextureLoader implements IInternalTextureLoader {
  108415. /**
  108416. * Defines wether the loader supports cascade loading the different faces.
  108417. */
  108418. readonly supportCascades: boolean;
  108419. /**
  108420. * This returns if the loader support the current file information.
  108421. * @param extension defines the file extension of the file being loaded
  108422. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108423. * @param fallback defines the fallback internal texture if any
  108424. * @param isBase64 defines whether the texture is encoded as a base64
  108425. * @param isBuffer defines whether the texture data are stored as a buffer
  108426. * @returns true if the loader can load the specified file
  108427. */
  108428. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108429. /**
  108430. * Transform the url before loading if required.
  108431. * @param rootUrl the url of the texture
  108432. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108433. * @returns the transformed texture
  108434. */
  108435. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108436. /**
  108437. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108438. * @param rootUrl the url of the texture
  108439. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108440. * @returns the fallback texture
  108441. */
  108442. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108443. /**
  108444. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108445. * @param data contains the texture data
  108446. * @param texture defines the BabylonJS internal texture
  108447. * @param createPolynomials will be true if polynomials have been requested
  108448. * @param onLoad defines the callback to trigger once the texture is ready
  108449. * @param onError defines the callback to trigger in case of error
  108450. */
  108451. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108452. /**
  108453. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108454. * @param data contains the texture data
  108455. * @param texture defines the BabylonJS internal texture
  108456. * @param callback defines the method to call once ready to upload
  108457. */
  108458. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108459. }
  108460. }
  108461. declare module BABYLON {
  108462. /**
  108463. * 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.
  108464. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108465. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108466. */
  108467. export class CustomProceduralTexture extends ProceduralTexture {
  108468. private _animate;
  108469. private _time;
  108470. private _config;
  108471. private _texturePath;
  108472. /**
  108473. * Instantiates a new Custom Procedural Texture.
  108474. * 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.
  108475. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108476. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108477. * @param name Define the name of the texture
  108478. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  108479. * @param size Define the size of the texture to create
  108480. * @param scene Define the scene the texture belongs to
  108481. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  108482. * @param generateMipMaps Define if the texture should creates mip maps or not
  108483. */
  108484. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108485. private _loadJson;
  108486. /**
  108487. * Is the texture ready to be used ? (rendered at least once)
  108488. * @returns true if ready, otherwise, false.
  108489. */
  108490. isReady(): boolean;
  108491. /**
  108492. * Render the texture to its associated render target.
  108493. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  108494. */
  108495. render(useCameraPostProcess?: boolean): void;
  108496. /**
  108497. * Update the list of dependant textures samplers in the shader.
  108498. */
  108499. updateTextures(): void;
  108500. /**
  108501. * Update the uniform values of the procedural texture in the shader.
  108502. */
  108503. updateShaderUniforms(): void;
  108504. /**
  108505. * Define if the texture animates or not.
  108506. */
  108507. animate: boolean;
  108508. }
  108509. }
  108510. declare module BABYLON {
  108511. /** @hidden */
  108512. export var noisePixelShader: {
  108513. name: string;
  108514. shader: string;
  108515. };
  108516. }
  108517. declare module BABYLON {
  108518. /**
  108519. * Class used to generate noise procedural textures
  108520. */
  108521. export class NoiseProceduralTexture extends ProceduralTexture {
  108522. private _time;
  108523. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  108524. brightness: number;
  108525. /** Defines the number of octaves to process */
  108526. octaves: number;
  108527. /** Defines the level of persistence (0.8 by default) */
  108528. persistence: number;
  108529. /** Gets or sets animation speed factor (default is 1) */
  108530. animationSpeedFactor: number;
  108531. /**
  108532. * Creates a new NoiseProceduralTexture
  108533. * @param name defines the name fo the texture
  108534. * @param size defines the size of the texture (default is 256)
  108535. * @param scene defines the hosting scene
  108536. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  108537. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  108538. */
  108539. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108540. private _updateShaderUniforms;
  108541. protected _getDefines(): string;
  108542. /** Generate the current state of the procedural texture */
  108543. render(useCameraPostProcess?: boolean): void;
  108544. /**
  108545. * Serializes this noise procedural texture
  108546. * @returns a serialized noise procedural texture object
  108547. */
  108548. serialize(): any;
  108549. /**
  108550. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  108551. * @param parsedTexture defines parsed texture data
  108552. * @param scene defines the current scene
  108553. * @param rootUrl defines the root URL containing noise procedural texture information
  108554. * @returns a parsed NoiseProceduralTexture
  108555. */
  108556. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  108557. }
  108558. }
  108559. declare module BABYLON {
  108560. /**
  108561. * Raw cube texture where the raw buffers are passed in
  108562. */
  108563. export class RawCubeTexture extends CubeTexture {
  108564. /**
  108565. * Creates a cube texture where the raw buffers are passed in.
  108566. * @param scene defines the scene the texture is attached to
  108567. * @param data defines the array of data to use to create each face
  108568. * @param size defines the size of the textures
  108569. * @param format defines the format of the data
  108570. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  108571. * @param generateMipMaps defines if the engine should generate the mip levels
  108572. * @param invertY defines if data must be stored with Y axis inverted
  108573. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  108574. * @param compression defines the compression used (null by default)
  108575. */
  108576. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  108577. /**
  108578. * Updates the raw cube texture.
  108579. * @param data defines the data to store
  108580. * @param format defines the data format
  108581. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  108582. * @param invertY defines if data must be stored with Y axis inverted
  108583. * @param compression defines the compression used (null by default)
  108584. * @param level defines which level of the texture to update
  108585. */
  108586. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  108587. /**
  108588. * Updates a raw cube texture with RGBD encoded data.
  108589. * @param data defines the array of data [mipmap][face] to use to create each face
  108590. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  108591. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  108592. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  108593. * @returns a promsie that resolves when the operation is complete
  108594. */
  108595. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  108596. /**
  108597. * Clones the raw cube texture.
  108598. * @return a new cube texture
  108599. */
  108600. clone(): CubeTexture;
  108601. /** @hidden */
  108602. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108603. }
  108604. }
  108605. declare module BABYLON {
  108606. /**
  108607. * Class used to store 3D textures containing user data
  108608. */
  108609. export class RawTexture3D extends Texture {
  108610. /** Gets or sets the texture format to use */
  108611. format: number;
  108612. private _engine;
  108613. /**
  108614. * Create a new RawTexture3D
  108615. * @param data defines the data of the texture
  108616. * @param width defines the width of the texture
  108617. * @param height defines the height of the texture
  108618. * @param depth defines the depth of the texture
  108619. * @param format defines the texture format to use
  108620. * @param scene defines the hosting scene
  108621. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  108622. * @param invertY defines if texture must be stored with Y axis inverted
  108623. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108624. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  108625. */
  108626. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  108627. /** Gets or sets the texture format to use */
  108628. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  108629. /**
  108630. * Update the texture with new data
  108631. * @param data defines the data to store in the texture
  108632. */
  108633. update(data: ArrayBufferView): void;
  108634. }
  108635. }
  108636. declare module BABYLON {
  108637. /**
  108638. * Creates a refraction texture used by refraction channel of the standard material.
  108639. * It is like a mirror but to see through a material.
  108640. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108641. */
  108642. export class RefractionTexture extends RenderTargetTexture {
  108643. /**
  108644. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  108645. * 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.
  108646. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108647. */
  108648. refractionPlane: Plane;
  108649. /**
  108650. * Define how deep under the surface we should see.
  108651. */
  108652. depth: number;
  108653. /**
  108654. * Creates a refraction texture used by refraction channel of the standard material.
  108655. * It is like a mirror but to see through a material.
  108656. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108657. * @param name Define the texture name
  108658. * @param size Define the size of the underlying texture
  108659. * @param scene Define the scene the refraction belongs to
  108660. * @param generateMipMaps Define if we need to generate mips level for the refraction
  108661. */
  108662. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  108663. /**
  108664. * Clone the refraction texture.
  108665. * @returns the cloned texture
  108666. */
  108667. clone(): RefractionTexture;
  108668. /**
  108669. * Serialize the texture to a JSON representation you could use in Parse later on
  108670. * @returns the serialized JSON representation
  108671. */
  108672. serialize(): any;
  108673. }
  108674. }
  108675. declare module BABYLON {
  108676. /**
  108677. * Helper class to push actions to a pool of workers.
  108678. */
  108679. export class WorkerPool implements IDisposable {
  108680. private _workerInfos;
  108681. private _pendingActions;
  108682. /**
  108683. * Constructor
  108684. * @param workers Array of workers to use for actions
  108685. */
  108686. constructor(workers: Array<Worker>);
  108687. /**
  108688. * Terminates all workers and clears any pending actions.
  108689. */
  108690. dispose(): void;
  108691. /**
  108692. * Pushes an action to the worker pool. If all the workers are active, the action will be
  108693. * pended until a worker has completed its action.
  108694. * @param action The action to perform. Call onComplete when the action is complete.
  108695. */
  108696. push(action: (worker: Worker, onComplete: () => void) => void): void;
  108697. private _execute;
  108698. }
  108699. }
  108700. declare module BABYLON {
  108701. /**
  108702. * Configuration for Draco compression
  108703. */
  108704. export interface IDracoCompressionConfiguration {
  108705. /**
  108706. * Configuration for the decoder.
  108707. */
  108708. decoder?: {
  108709. /**
  108710. * The url to the WebAssembly module.
  108711. */
  108712. wasmUrl?: string;
  108713. /**
  108714. * The url to the WebAssembly binary.
  108715. */
  108716. wasmBinaryUrl?: string;
  108717. /**
  108718. * The url to the fallback JavaScript module.
  108719. */
  108720. fallbackUrl?: string;
  108721. };
  108722. }
  108723. /**
  108724. * Draco compression (https://google.github.io/draco/)
  108725. *
  108726. * This class wraps the Draco module.
  108727. *
  108728. * **Encoder**
  108729. *
  108730. * The encoder is not currently implemented.
  108731. *
  108732. * **Decoder**
  108733. *
  108734. * 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.
  108735. *
  108736. * To update the configuration, use the following code:
  108737. * ```javascript
  108738. * DracoCompression.Configuration = {
  108739. * decoder: {
  108740. * wasmUrl: "<url to the WebAssembly library>",
  108741. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  108742. * fallbackUrl: "<url to the fallback JavaScript library>",
  108743. * }
  108744. * };
  108745. * ```
  108746. *
  108747. * 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.
  108748. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  108749. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  108750. *
  108751. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  108752. * ```javascript
  108753. * var dracoCompression = new DracoCompression();
  108754. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  108755. * [VertexBuffer.PositionKind]: 0
  108756. * });
  108757. * ```
  108758. *
  108759. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  108760. */
  108761. export class DracoCompression implements IDisposable {
  108762. private _workerPoolPromise;
  108763. /**
  108764. * The configuration. Defaults to the following urls:
  108765. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  108766. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  108767. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  108768. */
  108769. static Configuration: IDracoCompressionConfiguration;
  108770. /**
  108771. * Returns true if the decoder is available.
  108772. */
  108773. static readonly DecoderAvailable: boolean;
  108774. /**
  108775. * Default number of workers to create when creating the draco compression object.
  108776. */
  108777. static DefaultNumWorkers: number;
  108778. private static GetDefaultNumWorkers;
  108779. /**
  108780. * Constructor
  108781. * @param numWorkers The number of workers for async operations
  108782. */
  108783. constructor(numWorkers?: number);
  108784. /**
  108785. * Stop all async operations and release resources.
  108786. */
  108787. dispose(): void;
  108788. /**
  108789. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  108790. * @returns a promise that resolves when ready
  108791. */
  108792. whenReadyAsync(): Promise<void>;
  108793. /**
  108794. * Decode Draco compressed mesh data to vertex data.
  108795. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  108796. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  108797. * @returns A promise that resolves with the decoded vertex data
  108798. */
  108799. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  108800. [kind: string]: number;
  108801. }): Promise<VertexData>;
  108802. /**
  108803. * The worker function that gets converted to a blob url to pass into a worker.
  108804. */
  108805. private static _Worker;
  108806. private _loadDecoderWasmBinaryAsync;
  108807. }
  108808. }
  108809. declare module BABYLON {
  108810. /**
  108811. * Class for building Constructive Solid Geometry
  108812. */
  108813. export class CSG {
  108814. private polygons;
  108815. /**
  108816. * The world matrix
  108817. */
  108818. matrix: Matrix;
  108819. /**
  108820. * Stores the position
  108821. */
  108822. position: Vector3;
  108823. /**
  108824. * Stores the rotation
  108825. */
  108826. rotation: Vector3;
  108827. /**
  108828. * Stores the rotation quaternion
  108829. */
  108830. rotationQuaternion: Nullable<Quaternion>;
  108831. /**
  108832. * Stores the scaling vector
  108833. */
  108834. scaling: Vector3;
  108835. /**
  108836. * Convert the Mesh to CSG
  108837. * @param mesh The Mesh to convert to CSG
  108838. * @returns A new CSG from the Mesh
  108839. */
  108840. static FromMesh(mesh: Mesh): CSG;
  108841. /**
  108842. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  108843. * @param polygons Polygons used to construct a CSG solid
  108844. */
  108845. private static FromPolygons;
  108846. /**
  108847. * Clones, or makes a deep copy, of the CSG
  108848. * @returns A new CSG
  108849. */
  108850. clone(): CSG;
  108851. /**
  108852. * Unions this CSG with another CSG
  108853. * @param csg The CSG to union against this CSG
  108854. * @returns The unioned CSG
  108855. */
  108856. union(csg: CSG): CSG;
  108857. /**
  108858. * Unions this CSG with another CSG in place
  108859. * @param csg The CSG to union against this CSG
  108860. */
  108861. unionInPlace(csg: CSG): void;
  108862. /**
  108863. * Subtracts this CSG with another CSG
  108864. * @param csg The CSG to subtract against this CSG
  108865. * @returns A new CSG
  108866. */
  108867. subtract(csg: CSG): CSG;
  108868. /**
  108869. * Subtracts this CSG with another CSG in place
  108870. * @param csg The CSG to subtact against this CSG
  108871. */
  108872. subtractInPlace(csg: CSG): void;
  108873. /**
  108874. * Intersect this CSG with another CSG
  108875. * @param csg The CSG to intersect against this CSG
  108876. * @returns A new CSG
  108877. */
  108878. intersect(csg: CSG): CSG;
  108879. /**
  108880. * Intersects this CSG with another CSG in place
  108881. * @param csg The CSG to intersect against this CSG
  108882. */
  108883. intersectInPlace(csg: CSG): void;
  108884. /**
  108885. * Return a new CSG solid with solid and empty space switched. This solid is
  108886. * not modified.
  108887. * @returns A new CSG solid with solid and empty space switched
  108888. */
  108889. inverse(): CSG;
  108890. /**
  108891. * Inverses the CSG in place
  108892. */
  108893. inverseInPlace(): void;
  108894. /**
  108895. * This is used to keep meshes transformations so they can be restored
  108896. * when we build back a Babylon Mesh
  108897. * NB : All CSG operations are performed in world coordinates
  108898. * @param csg The CSG to copy the transform attributes from
  108899. * @returns This CSG
  108900. */
  108901. copyTransformAttributes(csg: CSG): CSG;
  108902. /**
  108903. * Build Raw mesh from CSG
  108904. * Coordinates here are in world space
  108905. * @param name The name of the mesh geometry
  108906. * @param scene The Scene
  108907. * @param keepSubMeshes Specifies if the submeshes should be kept
  108908. * @returns A new Mesh
  108909. */
  108910. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  108911. /**
  108912. * Build Mesh from CSG taking material and transforms into account
  108913. * @param name The name of the Mesh
  108914. * @param material The material of the Mesh
  108915. * @param scene The Scene
  108916. * @param keepSubMeshes Specifies if submeshes should be kept
  108917. * @returns The new Mesh
  108918. */
  108919. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  108920. }
  108921. }
  108922. declare module BABYLON {
  108923. /**
  108924. * Class used to create a trail following a mesh
  108925. */
  108926. export class TrailMesh extends Mesh {
  108927. private _generator;
  108928. private _autoStart;
  108929. private _running;
  108930. private _diameter;
  108931. private _length;
  108932. private _sectionPolygonPointsCount;
  108933. private _sectionVectors;
  108934. private _sectionNormalVectors;
  108935. private _beforeRenderObserver;
  108936. /**
  108937. * @constructor
  108938. * @param name The value used by scene.getMeshByName() to do a lookup.
  108939. * @param generator The mesh to generate a trail.
  108940. * @param scene The scene to add this mesh to.
  108941. * @param diameter Diameter of trailing mesh. Default is 1.
  108942. * @param length Length of trailing mesh. Default is 60.
  108943. * @param autoStart Automatically start trailing mesh. Default true.
  108944. */
  108945. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  108946. /**
  108947. * "TrailMesh"
  108948. * @returns "TrailMesh"
  108949. */
  108950. getClassName(): string;
  108951. private _createMesh;
  108952. /**
  108953. * Start trailing mesh.
  108954. */
  108955. start(): void;
  108956. /**
  108957. * Stop trailing mesh.
  108958. */
  108959. stop(): void;
  108960. /**
  108961. * Update trailing mesh geometry.
  108962. */
  108963. update(): void;
  108964. /**
  108965. * Returns a new TrailMesh object.
  108966. * @param name is a string, the name given to the new mesh
  108967. * @param newGenerator use new generator object for cloned trail mesh
  108968. * @returns a new mesh
  108969. */
  108970. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  108971. /**
  108972. * Serializes this trail mesh
  108973. * @param serializationObject object to write serialization to
  108974. */
  108975. serialize(serializationObject: any): void;
  108976. /**
  108977. * Parses a serialized trail mesh
  108978. * @param parsedMesh the serialized mesh
  108979. * @param scene the scene to create the trail mesh in
  108980. * @returns the created trail mesh
  108981. */
  108982. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  108983. }
  108984. }
  108985. declare module BABYLON {
  108986. /**
  108987. * Class containing static functions to help procedurally build meshes
  108988. */
  108989. export class TorusKnotBuilder {
  108990. /**
  108991. * Creates a torus knot mesh
  108992. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108993. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  108994. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  108995. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  108996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108999. * @param name defines the name of the mesh
  109000. * @param options defines the options used to create the mesh
  109001. * @param scene defines the hosting scene
  109002. * @returns the torus knot mesh
  109003. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109004. */
  109005. static CreateTorusKnot(name: string, options: {
  109006. radius?: number;
  109007. tube?: number;
  109008. radialSegments?: number;
  109009. tubularSegments?: number;
  109010. p?: number;
  109011. q?: number;
  109012. updatable?: boolean;
  109013. sideOrientation?: number;
  109014. frontUVs?: Vector4;
  109015. backUVs?: Vector4;
  109016. }, scene: any): Mesh;
  109017. }
  109018. }
  109019. declare module BABYLON {
  109020. /**
  109021. * Polygon
  109022. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109023. */
  109024. export class Polygon {
  109025. /**
  109026. * Creates a rectangle
  109027. * @param xmin bottom X coord
  109028. * @param ymin bottom Y coord
  109029. * @param xmax top X coord
  109030. * @param ymax top Y coord
  109031. * @returns points that make the resulting rectation
  109032. */
  109033. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109034. /**
  109035. * Creates a circle
  109036. * @param radius radius of circle
  109037. * @param cx scale in x
  109038. * @param cy scale in y
  109039. * @param numberOfSides number of sides that make up the circle
  109040. * @returns points that make the resulting circle
  109041. */
  109042. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109043. /**
  109044. * Creates a polygon from input string
  109045. * @param input Input polygon data
  109046. * @returns the parsed points
  109047. */
  109048. static Parse(input: string): Vector2[];
  109049. /**
  109050. * Starts building a polygon from x and y coordinates
  109051. * @param x x coordinate
  109052. * @param y y coordinate
  109053. * @returns the started path2
  109054. */
  109055. static StartingAt(x: number, y: number): Path2;
  109056. }
  109057. /**
  109058. * Builds a polygon
  109059. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  109060. */
  109061. export class PolygonMeshBuilder {
  109062. private _points;
  109063. private _outlinepoints;
  109064. private _holes;
  109065. private _name;
  109066. private _scene;
  109067. private _epoints;
  109068. private _eholes;
  109069. private _addToepoint;
  109070. /**
  109071. * Babylon reference to the earcut plugin.
  109072. */
  109073. bjsEarcut: any;
  109074. /**
  109075. * Creates a PolygonMeshBuilder
  109076. * @param name name of the builder
  109077. * @param contours Path of the polygon
  109078. * @param scene scene to add to when creating the mesh
  109079. * @param earcutInjection can be used to inject your own earcut reference
  109080. */
  109081. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  109082. /**
  109083. * Adds a whole within the polygon
  109084. * @param hole Array of points defining the hole
  109085. * @returns this
  109086. */
  109087. addHole(hole: Vector2[]): PolygonMeshBuilder;
  109088. /**
  109089. * Creates the polygon
  109090. * @param updatable If the mesh should be updatable
  109091. * @param depth The depth of the mesh created
  109092. * @returns the created mesh
  109093. */
  109094. build(updatable?: boolean, depth?: number): Mesh;
  109095. /**
  109096. * Creates the polygon
  109097. * @param depth The depth of the mesh created
  109098. * @returns the created VertexData
  109099. */
  109100. buildVertexData(depth?: number): VertexData;
  109101. /**
  109102. * Adds a side to the polygon
  109103. * @param positions points that make the polygon
  109104. * @param normals normals of the polygon
  109105. * @param uvs uvs of the polygon
  109106. * @param indices indices of the polygon
  109107. * @param bounds bounds of the polygon
  109108. * @param points points of the polygon
  109109. * @param depth depth of the polygon
  109110. * @param flip flip of the polygon
  109111. */
  109112. private addSide;
  109113. }
  109114. }
  109115. declare module BABYLON {
  109116. /**
  109117. * Class containing static functions to help procedurally build meshes
  109118. */
  109119. export class PolygonBuilder {
  109120. /**
  109121. * Creates a polygon mesh
  109122. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109123. * * 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
  109124. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109127. * * Remember you can only change the shape positions, not their number when updating a polygon
  109128. * @param name defines the name of the mesh
  109129. * @param options defines the options used to create the mesh
  109130. * @param scene defines the hosting scene
  109131. * @param earcutInjection can be used to inject your own earcut reference
  109132. * @returns the polygon mesh
  109133. */
  109134. static CreatePolygon(name: string, options: {
  109135. shape: Vector3[];
  109136. holes?: Vector3[][];
  109137. depth?: number;
  109138. faceUV?: Vector4[];
  109139. faceColors?: Color4[];
  109140. updatable?: boolean;
  109141. sideOrientation?: number;
  109142. frontUVs?: Vector4;
  109143. backUVs?: Vector4;
  109144. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109145. /**
  109146. * Creates an extruded polygon mesh, with depth in the Y direction.
  109147. * * 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)
  109148. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109149. * @param name defines the name of the mesh
  109150. * @param options defines the options used to create the mesh
  109151. * @param scene defines the hosting scene
  109152. * @param earcutInjection can be used to inject your own earcut reference
  109153. * @returns the polygon mesh
  109154. */
  109155. static ExtrudePolygon(name: string, options: {
  109156. shape: Vector3[];
  109157. holes?: Vector3[][];
  109158. depth?: number;
  109159. faceUV?: Vector4[];
  109160. faceColors?: Color4[];
  109161. updatable?: boolean;
  109162. sideOrientation?: number;
  109163. frontUVs?: Vector4;
  109164. backUVs?: Vector4;
  109165. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109166. }
  109167. }
  109168. declare module BABYLON {
  109169. /**
  109170. * Class containing static functions to help procedurally build meshes
  109171. */
  109172. export class LatheBuilder {
  109173. /**
  109174. * Creates lathe mesh.
  109175. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109176. * * 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
  109177. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109178. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109179. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109180. * * 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
  109181. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109182. * * 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
  109183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109185. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109187. * @param name defines the name of the mesh
  109188. * @param options defines the options used to create the mesh
  109189. * @param scene defines the hosting scene
  109190. * @returns the lathe mesh
  109191. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109192. */
  109193. static CreateLathe(name: string, options: {
  109194. shape: Vector3[];
  109195. radius?: number;
  109196. tessellation?: number;
  109197. clip?: number;
  109198. arc?: number;
  109199. closed?: boolean;
  109200. updatable?: boolean;
  109201. sideOrientation?: number;
  109202. frontUVs?: Vector4;
  109203. backUVs?: Vector4;
  109204. cap?: number;
  109205. invertUV?: boolean;
  109206. }, scene?: Nullable<Scene>): Mesh;
  109207. }
  109208. }
  109209. declare module BABYLON {
  109210. /**
  109211. * Class containing static functions to help procedurally build meshes
  109212. */
  109213. export class TubeBuilder {
  109214. /**
  109215. * Creates a tube mesh.
  109216. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109217. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109218. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109219. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109220. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109221. * * 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)
  109222. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109223. * * 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
  109224. * * 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
  109225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109227. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109229. * @param name defines the name of the mesh
  109230. * @param options defines the options used to create the mesh
  109231. * @param scene defines the hosting scene
  109232. * @returns the tube mesh
  109233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109234. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109235. */
  109236. static CreateTube(name: string, options: {
  109237. path: Vector3[];
  109238. radius?: number;
  109239. tessellation?: number;
  109240. radiusFunction?: {
  109241. (i: number, distance: number): number;
  109242. };
  109243. cap?: number;
  109244. arc?: number;
  109245. updatable?: boolean;
  109246. sideOrientation?: number;
  109247. frontUVs?: Vector4;
  109248. backUVs?: Vector4;
  109249. instance?: Mesh;
  109250. invertUV?: boolean;
  109251. }, scene?: Nullable<Scene>): Mesh;
  109252. }
  109253. }
  109254. declare module BABYLON {
  109255. /**
  109256. * Class containing static functions to help procedurally build meshes
  109257. */
  109258. export class IcoSphereBuilder {
  109259. /**
  109260. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109261. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109262. * * 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`)
  109263. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109264. * * 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
  109265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109268. * @param name defines the name of the mesh
  109269. * @param options defines the options used to create the mesh
  109270. * @param scene defines the hosting scene
  109271. * @returns the icosahedron mesh
  109272. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109273. */
  109274. static CreateIcoSphere(name: string, options: {
  109275. radius?: number;
  109276. radiusX?: number;
  109277. radiusY?: number;
  109278. radiusZ?: number;
  109279. flat?: boolean;
  109280. subdivisions?: number;
  109281. sideOrientation?: number;
  109282. frontUVs?: Vector4;
  109283. backUVs?: Vector4;
  109284. updatable?: boolean;
  109285. }, scene?: Nullable<Scene>): Mesh;
  109286. }
  109287. }
  109288. declare module BABYLON {
  109289. /**
  109290. * Class containing static functions to help procedurally build meshes
  109291. */
  109292. export class DecalBuilder {
  109293. /**
  109294. * Creates a decal mesh.
  109295. * 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
  109296. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109297. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109298. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109299. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109300. * @param name defines the name of the mesh
  109301. * @param sourceMesh defines the mesh where the decal must be applied
  109302. * @param options defines the options used to create the mesh
  109303. * @param scene defines the hosting scene
  109304. * @returns the decal mesh
  109305. * @see https://doc.babylonjs.com/how_to/decals
  109306. */
  109307. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109308. position?: Vector3;
  109309. normal?: Vector3;
  109310. size?: Vector3;
  109311. angle?: number;
  109312. }): Mesh;
  109313. }
  109314. }
  109315. declare module BABYLON {
  109316. /**
  109317. * Class containing static functions to help procedurally build meshes
  109318. */
  109319. export class MeshBuilder {
  109320. /**
  109321. * Creates a box mesh
  109322. * * The parameter `size` sets the size (float) of each box side (default 1)
  109323. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109324. * * 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)
  109325. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109329. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109330. * @param name defines the name of the mesh
  109331. * @param options defines the options used to create the mesh
  109332. * @param scene defines the hosting scene
  109333. * @returns the box mesh
  109334. */
  109335. static CreateBox(name: string, options: {
  109336. size?: number;
  109337. width?: number;
  109338. height?: number;
  109339. depth?: number;
  109340. faceUV?: Vector4[];
  109341. faceColors?: Color4[];
  109342. sideOrientation?: number;
  109343. frontUVs?: Vector4;
  109344. backUVs?: Vector4;
  109345. updatable?: boolean;
  109346. }, scene?: Nullable<Scene>): Mesh;
  109347. /**
  109348. * Creates a sphere mesh
  109349. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109350. * * 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`)
  109351. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109352. * * 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
  109353. * * 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)
  109354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109357. * @param name defines the name of the mesh
  109358. * @param options defines the options used to create the mesh
  109359. * @param scene defines the hosting scene
  109360. * @returns the sphere mesh
  109361. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109362. */
  109363. static CreateSphere(name: string, options: {
  109364. segments?: number;
  109365. diameter?: number;
  109366. diameterX?: number;
  109367. diameterY?: number;
  109368. diameterZ?: number;
  109369. arc?: number;
  109370. slice?: number;
  109371. sideOrientation?: number;
  109372. frontUVs?: Vector4;
  109373. backUVs?: Vector4;
  109374. updatable?: boolean;
  109375. }, scene?: Nullable<Scene>): Mesh;
  109376. /**
  109377. * Creates a plane polygonal mesh. By default, this is a disc
  109378. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109379. * * 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
  109380. * * 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
  109381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109384. * @param name defines the name of the mesh
  109385. * @param options defines the options used to create the mesh
  109386. * @param scene defines the hosting scene
  109387. * @returns the plane polygonal mesh
  109388. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109389. */
  109390. static CreateDisc(name: string, options: {
  109391. radius?: number;
  109392. tessellation?: number;
  109393. arc?: number;
  109394. updatable?: boolean;
  109395. sideOrientation?: number;
  109396. frontUVs?: Vector4;
  109397. backUVs?: Vector4;
  109398. }, scene?: Nullable<Scene>): Mesh;
  109399. /**
  109400. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109401. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109402. * * 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`)
  109403. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109404. * * 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
  109405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109408. * @param name defines the name of the mesh
  109409. * @param options defines the options used to create the mesh
  109410. * @param scene defines the hosting scene
  109411. * @returns the icosahedron mesh
  109412. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109413. */
  109414. static CreateIcoSphere(name: string, options: {
  109415. radius?: number;
  109416. radiusX?: number;
  109417. radiusY?: number;
  109418. radiusZ?: number;
  109419. flat?: boolean;
  109420. subdivisions?: number;
  109421. sideOrientation?: number;
  109422. frontUVs?: Vector4;
  109423. backUVs?: Vector4;
  109424. updatable?: boolean;
  109425. }, scene?: Nullable<Scene>): Mesh;
  109426. /**
  109427. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109428. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  109429. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  109430. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  109431. * * 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
  109432. * * 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
  109433. * * 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
  109434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109436. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109437. * * 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
  109438. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  109439. * * 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
  109440. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  109441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109442. * @param name defines the name of the mesh
  109443. * @param options defines the options used to create the mesh
  109444. * @param scene defines the hosting scene
  109445. * @returns the ribbon mesh
  109446. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  109447. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109448. */
  109449. static CreateRibbon(name: string, options: {
  109450. pathArray: Vector3[][];
  109451. closeArray?: boolean;
  109452. closePath?: boolean;
  109453. offset?: number;
  109454. updatable?: boolean;
  109455. sideOrientation?: number;
  109456. frontUVs?: Vector4;
  109457. backUVs?: Vector4;
  109458. instance?: Mesh;
  109459. invertUV?: boolean;
  109460. uvs?: Vector2[];
  109461. colors?: Color4[];
  109462. }, scene?: Nullable<Scene>): Mesh;
  109463. /**
  109464. * Creates a cylinder or a cone mesh
  109465. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109466. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109467. * * 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.
  109468. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109469. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109470. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109471. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109472. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109473. * * 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).
  109474. * * 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
  109475. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109476. * * 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
  109477. * * 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.
  109478. * * If `enclose` is false, a ring surface is one element.
  109479. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109480. * * 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
  109481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109482. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109484. * @param name defines the name of the mesh
  109485. * @param options defines the options used to create the mesh
  109486. * @param scene defines the hosting scene
  109487. * @returns the cylinder mesh
  109488. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109489. */
  109490. static CreateCylinder(name: string, options: {
  109491. height?: number;
  109492. diameterTop?: number;
  109493. diameterBottom?: number;
  109494. diameter?: number;
  109495. tessellation?: number;
  109496. subdivisions?: number;
  109497. arc?: number;
  109498. faceColors?: Color4[];
  109499. faceUV?: Vector4[];
  109500. updatable?: boolean;
  109501. hasRings?: boolean;
  109502. enclose?: boolean;
  109503. sideOrientation?: number;
  109504. frontUVs?: Vector4;
  109505. backUVs?: Vector4;
  109506. }, scene?: Nullable<Scene>): Mesh;
  109507. /**
  109508. * Creates a torus mesh
  109509. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109510. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109511. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109515. * @param name defines the name of the mesh
  109516. * @param options defines the options used to create the mesh
  109517. * @param scene defines the hosting scene
  109518. * @returns the torus mesh
  109519. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109520. */
  109521. static CreateTorus(name: string, options: {
  109522. diameter?: number;
  109523. thickness?: number;
  109524. tessellation?: number;
  109525. updatable?: boolean;
  109526. sideOrientation?: number;
  109527. frontUVs?: Vector4;
  109528. backUVs?: Vector4;
  109529. }, scene?: Nullable<Scene>): Mesh;
  109530. /**
  109531. * Creates a torus knot mesh
  109532. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109533. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109534. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109535. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109539. * @param name defines the name of the mesh
  109540. * @param options defines the options used to create the mesh
  109541. * @param scene defines the hosting scene
  109542. * @returns the torus knot mesh
  109543. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109544. */
  109545. static CreateTorusKnot(name: string, options: {
  109546. radius?: number;
  109547. tube?: number;
  109548. radialSegments?: number;
  109549. tubularSegments?: number;
  109550. p?: number;
  109551. q?: number;
  109552. updatable?: boolean;
  109553. sideOrientation?: number;
  109554. frontUVs?: Vector4;
  109555. backUVs?: Vector4;
  109556. }, scene?: Nullable<Scene>): Mesh;
  109557. /**
  109558. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109559. * * 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
  109560. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109561. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109562. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109563. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109564. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109565. * * 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
  109566. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109568. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109569. * @param name defines the name of the new line system
  109570. * @param options defines the options used to create the line system
  109571. * @param scene defines the hosting scene
  109572. * @returns a new line system mesh
  109573. */
  109574. static CreateLineSystem(name: string, options: {
  109575. lines: Vector3[][];
  109576. updatable?: boolean;
  109577. instance?: Nullable<LinesMesh>;
  109578. colors?: Nullable<Color4[][]>;
  109579. useVertexAlpha?: boolean;
  109580. }, scene: Nullable<Scene>): LinesMesh;
  109581. /**
  109582. * Creates a line mesh
  109583. * 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
  109584. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109585. * * The parameter `points` is an array successive Vector3
  109586. * * 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
  109587. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109588. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109589. * * When updating an instance, remember that only point positions can change, not the number of points
  109590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109592. * @param name defines the name of the new line system
  109593. * @param options defines the options used to create the line system
  109594. * @param scene defines the hosting scene
  109595. * @returns a new line mesh
  109596. */
  109597. static CreateLines(name: string, options: {
  109598. points: Vector3[];
  109599. updatable?: boolean;
  109600. instance?: Nullable<LinesMesh>;
  109601. colors?: Color4[];
  109602. useVertexAlpha?: boolean;
  109603. }, scene?: Nullable<Scene>): LinesMesh;
  109604. /**
  109605. * Creates a dashed line mesh
  109606. * * 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
  109607. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109608. * * The parameter `points` is an array successive Vector3
  109609. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109610. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109611. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109612. * * 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
  109613. * * When updating an instance, remember that only point positions can change, not the number of points
  109614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109615. * @param name defines the name of the mesh
  109616. * @param options defines the options used to create the mesh
  109617. * @param scene defines the hosting scene
  109618. * @returns the dashed line mesh
  109619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109620. */
  109621. static CreateDashedLines(name: string, options: {
  109622. points: Vector3[];
  109623. dashSize?: number;
  109624. gapSize?: number;
  109625. dashNb?: number;
  109626. updatable?: boolean;
  109627. instance?: LinesMesh;
  109628. }, scene?: Nullable<Scene>): LinesMesh;
  109629. /**
  109630. * 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.
  109631. * * 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.
  109632. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109633. * * 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.
  109634. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  109635. * * 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
  109636. * * 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
  109637. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  109638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109639. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109640. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  109641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109642. * @param name defines the name of the mesh
  109643. * @param options defines the options used to create the mesh
  109644. * @param scene defines the hosting scene
  109645. * @returns the extruded shape mesh
  109646. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109648. */
  109649. static ExtrudeShape(name: string, options: {
  109650. shape: Vector3[];
  109651. path: Vector3[];
  109652. scale?: number;
  109653. rotation?: number;
  109654. cap?: number;
  109655. updatable?: boolean;
  109656. sideOrientation?: number;
  109657. frontUVs?: Vector4;
  109658. backUVs?: Vector4;
  109659. instance?: Mesh;
  109660. invertUV?: boolean;
  109661. }, scene?: Nullable<Scene>): Mesh;
  109662. /**
  109663. * Creates an custom extruded shape mesh.
  109664. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  109665. * * 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.
  109666. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109667. * * 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
  109668. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  109669. * * 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
  109670. * * It must returns a float value that will be the scale value applied to the shape on each path point
  109671. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109672. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  109673. * * 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
  109674. * * 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
  109675. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  109676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109678. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109680. * @param name defines the name of the mesh
  109681. * @param options defines the options used to create the mesh
  109682. * @param scene defines the hosting scene
  109683. * @returns the custom extruded shape mesh
  109684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  109685. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109687. */
  109688. static ExtrudeShapeCustom(name: string, options: {
  109689. shape: Vector3[];
  109690. path: Vector3[];
  109691. scaleFunction?: any;
  109692. rotationFunction?: any;
  109693. ribbonCloseArray?: boolean;
  109694. ribbonClosePath?: boolean;
  109695. cap?: number;
  109696. updatable?: boolean;
  109697. sideOrientation?: number;
  109698. frontUVs?: Vector4;
  109699. backUVs?: Vector4;
  109700. instance?: Mesh;
  109701. invertUV?: boolean;
  109702. }, scene?: Nullable<Scene>): Mesh;
  109703. /**
  109704. * Creates lathe mesh.
  109705. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109706. * * 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
  109707. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109708. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109709. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109710. * * 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
  109711. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109712. * * 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
  109713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109715. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109717. * @param name defines the name of the mesh
  109718. * @param options defines the options used to create the mesh
  109719. * @param scene defines the hosting scene
  109720. * @returns the lathe mesh
  109721. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109722. */
  109723. static CreateLathe(name: string, options: {
  109724. shape: Vector3[];
  109725. radius?: number;
  109726. tessellation?: number;
  109727. clip?: number;
  109728. arc?: number;
  109729. closed?: boolean;
  109730. updatable?: boolean;
  109731. sideOrientation?: number;
  109732. frontUVs?: Vector4;
  109733. backUVs?: Vector4;
  109734. cap?: number;
  109735. invertUV?: boolean;
  109736. }, scene?: Nullable<Scene>): Mesh;
  109737. /**
  109738. * Creates a plane mesh
  109739. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109740. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109741. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109745. * @param name defines the name of the mesh
  109746. * @param options defines the options used to create the mesh
  109747. * @param scene defines the hosting scene
  109748. * @returns the plane mesh
  109749. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109750. */
  109751. static CreatePlane(name: string, options: {
  109752. size?: number;
  109753. width?: number;
  109754. height?: number;
  109755. sideOrientation?: number;
  109756. frontUVs?: Vector4;
  109757. backUVs?: Vector4;
  109758. updatable?: boolean;
  109759. sourcePlane?: Plane;
  109760. }, scene?: Nullable<Scene>): Mesh;
  109761. /**
  109762. * Creates a ground mesh
  109763. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109764. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109766. * @param name defines the name of the mesh
  109767. * @param options defines the options used to create the mesh
  109768. * @param scene defines the hosting scene
  109769. * @returns the ground mesh
  109770. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109771. */
  109772. static CreateGround(name: string, options: {
  109773. width?: number;
  109774. height?: number;
  109775. subdivisions?: number;
  109776. subdivisionsX?: number;
  109777. subdivisionsY?: number;
  109778. updatable?: boolean;
  109779. }, scene?: Nullable<Scene>): Mesh;
  109780. /**
  109781. * Creates a tiled ground mesh
  109782. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109783. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109784. * * 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
  109785. * * 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
  109786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109787. * @param name defines the name of the mesh
  109788. * @param options defines the options used to create the mesh
  109789. * @param scene defines the hosting scene
  109790. * @returns the tiled ground mesh
  109791. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109792. */
  109793. static CreateTiledGround(name: string, options: {
  109794. xmin: number;
  109795. zmin: number;
  109796. xmax: number;
  109797. zmax: number;
  109798. subdivisions?: {
  109799. w: number;
  109800. h: number;
  109801. };
  109802. precision?: {
  109803. w: number;
  109804. h: number;
  109805. };
  109806. updatable?: boolean;
  109807. }, scene?: Nullable<Scene>): Mesh;
  109808. /**
  109809. * Creates a ground mesh from a height map
  109810. * * The parameter `url` sets the URL of the height map image resource.
  109811. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109812. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109813. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109814. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109815. * * 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.
  109816. * * 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).
  109817. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109819. * @param name defines the name of the mesh
  109820. * @param url defines the url to the height map
  109821. * @param options defines the options used to create the mesh
  109822. * @param scene defines the hosting scene
  109823. * @returns the ground mesh
  109824. * @see https://doc.babylonjs.com/babylon101/height_map
  109825. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109826. */
  109827. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109828. width?: number;
  109829. height?: number;
  109830. subdivisions?: number;
  109831. minHeight?: number;
  109832. maxHeight?: number;
  109833. colorFilter?: Color3;
  109834. alphaFilter?: number;
  109835. updatable?: boolean;
  109836. onReady?: (mesh: GroundMesh) => void;
  109837. }, scene?: Nullable<Scene>): GroundMesh;
  109838. /**
  109839. * Creates a polygon mesh
  109840. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109841. * * 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
  109842. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109845. * * Remember you can only change the shape positions, not their number when updating a polygon
  109846. * @param name defines the name of the mesh
  109847. * @param options defines the options used to create the mesh
  109848. * @param scene defines the hosting scene
  109849. * @param earcutInjection can be used to inject your own earcut reference
  109850. * @returns the polygon mesh
  109851. */
  109852. static CreatePolygon(name: string, options: {
  109853. shape: Vector3[];
  109854. holes?: Vector3[][];
  109855. depth?: number;
  109856. faceUV?: Vector4[];
  109857. faceColors?: Color4[];
  109858. updatable?: boolean;
  109859. sideOrientation?: number;
  109860. frontUVs?: Vector4;
  109861. backUVs?: Vector4;
  109862. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109863. /**
  109864. * Creates an extruded polygon mesh, with depth in the Y direction.
  109865. * * 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)
  109866. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109867. * @param name defines the name of the mesh
  109868. * @param options defines the options used to create the mesh
  109869. * @param scene defines the hosting scene
  109870. * @param earcutInjection can be used to inject your own earcut reference
  109871. * @returns the polygon mesh
  109872. */
  109873. static ExtrudePolygon(name: string, options: {
  109874. shape: Vector3[];
  109875. holes?: Vector3[][];
  109876. depth?: number;
  109877. faceUV?: Vector4[];
  109878. faceColors?: Color4[];
  109879. updatable?: boolean;
  109880. sideOrientation?: number;
  109881. frontUVs?: Vector4;
  109882. backUVs?: Vector4;
  109883. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109884. /**
  109885. * Creates a tube mesh.
  109886. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109887. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109888. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109889. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109890. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109891. * * 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)
  109892. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109893. * * 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
  109894. * * 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
  109895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109897. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109899. * @param name defines the name of the mesh
  109900. * @param options defines the options used to create the mesh
  109901. * @param scene defines the hosting scene
  109902. * @returns the tube mesh
  109903. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109904. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109905. */
  109906. static CreateTube(name: string, options: {
  109907. path: Vector3[];
  109908. radius?: number;
  109909. tessellation?: number;
  109910. radiusFunction?: {
  109911. (i: number, distance: number): number;
  109912. };
  109913. cap?: number;
  109914. arc?: number;
  109915. updatable?: boolean;
  109916. sideOrientation?: number;
  109917. frontUVs?: Vector4;
  109918. backUVs?: Vector4;
  109919. instance?: Mesh;
  109920. invertUV?: boolean;
  109921. }, scene?: Nullable<Scene>): Mesh;
  109922. /**
  109923. * Creates a polyhedron mesh
  109924. * * 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
  109925. * * The parameter `size` (positive float, default 1) sets the polygon size
  109926. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109927. * * 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`
  109928. * * 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
  109929. * * 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)`)
  109930. * * 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
  109931. * * 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
  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 polyhedron mesh
  109939. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109940. */
  109941. static CreatePolyhedron(name: string, options: {
  109942. type?: number;
  109943. size?: number;
  109944. sizeX?: number;
  109945. sizeY?: number;
  109946. sizeZ?: number;
  109947. custom?: any;
  109948. faceUV?: Vector4[];
  109949. faceColors?: Color4[];
  109950. flat?: boolean;
  109951. updatable?: boolean;
  109952. sideOrientation?: number;
  109953. frontUVs?: Vector4;
  109954. backUVs?: Vector4;
  109955. }, scene?: Nullable<Scene>): Mesh;
  109956. /**
  109957. * Creates a decal mesh.
  109958. * 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
  109959. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109960. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109961. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109962. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109963. * @param name defines the name of the mesh
  109964. * @param sourceMesh defines the mesh where the decal must be applied
  109965. * @param options defines the options used to create the mesh
  109966. * @param scene defines the hosting scene
  109967. * @returns the decal mesh
  109968. * @see https://doc.babylonjs.com/how_to/decals
  109969. */
  109970. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109971. position?: Vector3;
  109972. normal?: Vector3;
  109973. size?: Vector3;
  109974. angle?: number;
  109975. }): Mesh;
  109976. }
  109977. }
  109978. declare module BABYLON {
  109979. /**
  109980. * A simplifier interface for future simplification implementations
  109981. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109982. */
  109983. export interface ISimplifier {
  109984. /**
  109985. * Simplification of a given mesh according to the given settings.
  109986. * Since this requires computation, it is assumed that the function runs async.
  109987. * @param settings The settings of the simplification, including quality and distance
  109988. * @param successCallback A callback that will be called after the mesh was simplified.
  109989. * @param errorCallback in case of an error, this callback will be called. optional.
  109990. */
  109991. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  109992. }
  109993. /**
  109994. * Expected simplification settings.
  109995. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  109996. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109997. */
  109998. export interface ISimplificationSettings {
  109999. /**
  110000. * Gets or sets the expected quality
  110001. */
  110002. quality: number;
  110003. /**
  110004. * Gets or sets the distance when this optimized version should be used
  110005. */
  110006. distance: number;
  110007. /**
  110008. * Gets an already optimized mesh
  110009. */
  110010. optimizeMesh?: boolean;
  110011. }
  110012. /**
  110013. * Class used to specify simplification options
  110014. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110015. */
  110016. export class SimplificationSettings implements ISimplificationSettings {
  110017. /** expected quality */
  110018. quality: number;
  110019. /** distance when this optimized version should be used */
  110020. distance: number;
  110021. /** already optimized mesh */
  110022. optimizeMesh?: boolean | undefined;
  110023. /**
  110024. * Creates a SimplificationSettings
  110025. * @param quality expected quality
  110026. * @param distance distance when this optimized version should be used
  110027. * @param optimizeMesh already optimized mesh
  110028. */
  110029. constructor(
  110030. /** expected quality */
  110031. quality: number,
  110032. /** distance when this optimized version should be used */
  110033. distance: number,
  110034. /** already optimized mesh */
  110035. optimizeMesh?: boolean | undefined);
  110036. }
  110037. /**
  110038. * Interface used to define a simplification task
  110039. */
  110040. export interface ISimplificationTask {
  110041. /**
  110042. * Array of settings
  110043. */
  110044. settings: Array<ISimplificationSettings>;
  110045. /**
  110046. * Simplification type
  110047. */
  110048. simplificationType: SimplificationType;
  110049. /**
  110050. * Mesh to simplify
  110051. */
  110052. mesh: Mesh;
  110053. /**
  110054. * Callback called on success
  110055. */
  110056. successCallback?: () => void;
  110057. /**
  110058. * Defines if parallel processing can be used
  110059. */
  110060. parallelProcessing: boolean;
  110061. }
  110062. /**
  110063. * Queue used to order the simplification tasks
  110064. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110065. */
  110066. export class SimplificationQueue {
  110067. private _simplificationArray;
  110068. /**
  110069. * Gets a boolean indicating that the process is still running
  110070. */
  110071. running: boolean;
  110072. /**
  110073. * Creates a new queue
  110074. */
  110075. constructor();
  110076. /**
  110077. * Adds a new simplification task
  110078. * @param task defines a task to add
  110079. */
  110080. addTask(task: ISimplificationTask): void;
  110081. /**
  110082. * Execute next task
  110083. */
  110084. executeNext(): void;
  110085. /**
  110086. * Execute a simplification task
  110087. * @param task defines the task to run
  110088. */
  110089. runSimplification(task: ISimplificationTask): void;
  110090. private getSimplifier;
  110091. }
  110092. /**
  110093. * The implemented types of simplification
  110094. * At the moment only Quadratic Error Decimation is implemented
  110095. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110096. */
  110097. export enum SimplificationType {
  110098. /** Quadratic error decimation */
  110099. QUADRATIC = 0
  110100. }
  110101. }
  110102. declare module BABYLON {
  110103. interface Scene {
  110104. /** @hidden (Backing field) */
  110105. _simplificationQueue: SimplificationQueue;
  110106. /**
  110107. * Gets or sets the simplification queue attached to the scene
  110108. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110109. */
  110110. simplificationQueue: SimplificationQueue;
  110111. }
  110112. interface Mesh {
  110113. /**
  110114. * Simplify the mesh according to the given array of settings.
  110115. * Function will return immediately and will simplify async
  110116. * @param settings a collection of simplification settings
  110117. * @param parallelProcessing should all levels calculate parallel or one after the other
  110118. * @param simplificationType the type of simplification to run
  110119. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  110120. * @returns the current mesh
  110121. */
  110122. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  110123. }
  110124. /**
  110125. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  110126. * created in a scene
  110127. */
  110128. export class SimplicationQueueSceneComponent implements ISceneComponent {
  110129. /**
  110130. * The component name helpfull to identify the component in the list of scene components.
  110131. */
  110132. readonly name: string;
  110133. /**
  110134. * The scene the component belongs to.
  110135. */
  110136. scene: Scene;
  110137. /**
  110138. * Creates a new instance of the component for the given scene
  110139. * @param scene Defines the scene to register the component in
  110140. */
  110141. constructor(scene: Scene);
  110142. /**
  110143. * Registers the component in a given scene
  110144. */
  110145. register(): void;
  110146. /**
  110147. * Rebuilds the elements related to this component in case of
  110148. * context lost for instance.
  110149. */
  110150. rebuild(): void;
  110151. /**
  110152. * Disposes the component and the associated ressources
  110153. */
  110154. dispose(): void;
  110155. private _beforeCameraUpdate;
  110156. }
  110157. }
  110158. declare module BABYLON {
  110159. /**
  110160. * Class used to enable access to IndexedDB
  110161. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110162. */
  110163. export class Database implements IOfflineProvider {
  110164. private _callbackManifestChecked;
  110165. private _currentSceneUrl;
  110166. private _db;
  110167. private _enableSceneOffline;
  110168. private _enableTexturesOffline;
  110169. private _manifestVersionFound;
  110170. private _mustUpdateRessources;
  110171. private _hasReachedQuota;
  110172. private _isSupported;
  110173. private _idbFactory;
  110174. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  110175. private static IsUASupportingBlobStorage;
  110176. /**
  110177. * Gets a boolean indicating if Database storate is enabled (off by default)
  110178. */
  110179. static IDBStorageEnabled: boolean;
  110180. /**
  110181. * Gets a boolean indicating if scene must be saved in the database
  110182. */
  110183. readonly enableSceneOffline: boolean;
  110184. /**
  110185. * Gets a boolean indicating if textures must be saved in the database
  110186. */
  110187. readonly enableTexturesOffline: boolean;
  110188. /**
  110189. * Creates a new Database
  110190. * @param urlToScene defines the url to load the scene
  110191. * @param callbackManifestChecked defines the callback to use when manifest is checked
  110192. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  110193. */
  110194. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  110195. private static _ParseURL;
  110196. private static _ReturnFullUrlLocation;
  110197. private _checkManifestFile;
  110198. /**
  110199. * Open the database and make it available
  110200. * @param successCallback defines the callback to call on success
  110201. * @param errorCallback defines the callback to call on error
  110202. */
  110203. open(successCallback: () => void, errorCallback: () => void): void;
  110204. /**
  110205. * Loads an image from the database
  110206. * @param url defines the url to load from
  110207. * @param image defines the target DOM image
  110208. */
  110209. loadImage(url: string, image: HTMLImageElement): void;
  110210. private _loadImageFromDBAsync;
  110211. private _saveImageIntoDBAsync;
  110212. private _checkVersionFromDB;
  110213. private _loadVersionFromDBAsync;
  110214. private _saveVersionIntoDBAsync;
  110215. /**
  110216. * Loads a file from database
  110217. * @param url defines the URL to load from
  110218. * @param sceneLoaded defines a callback to call on success
  110219. * @param progressCallBack defines a callback to call when progress changed
  110220. * @param errorCallback defines a callback to call on error
  110221. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  110222. */
  110223. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  110224. private _loadFileAsync;
  110225. private _saveFileAsync;
  110226. /**
  110227. * Validates if xhr data is correct
  110228. * @param xhr defines the request to validate
  110229. * @param dataType defines the expected data type
  110230. * @returns true if data is correct
  110231. */
  110232. private static _ValidateXHRData;
  110233. }
  110234. }
  110235. declare module BABYLON {
  110236. /** @hidden */
  110237. export var gpuUpdateParticlesPixelShader: {
  110238. name: string;
  110239. shader: string;
  110240. };
  110241. }
  110242. declare module BABYLON {
  110243. /** @hidden */
  110244. export var gpuUpdateParticlesVertexShader: {
  110245. name: string;
  110246. shader: string;
  110247. };
  110248. }
  110249. declare module BABYLON {
  110250. /** @hidden */
  110251. export var clipPlaneFragmentDeclaration2: {
  110252. name: string;
  110253. shader: string;
  110254. };
  110255. }
  110256. declare module BABYLON {
  110257. /** @hidden */
  110258. export var gpuRenderParticlesPixelShader: {
  110259. name: string;
  110260. shader: string;
  110261. };
  110262. }
  110263. declare module BABYLON {
  110264. /** @hidden */
  110265. export var clipPlaneVertexDeclaration2: {
  110266. name: string;
  110267. shader: string;
  110268. };
  110269. }
  110270. declare module BABYLON {
  110271. /** @hidden */
  110272. export var gpuRenderParticlesVertexShader: {
  110273. name: string;
  110274. shader: string;
  110275. };
  110276. }
  110277. declare module BABYLON {
  110278. /**
  110279. * This represents a GPU particle system in Babylon
  110280. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  110281. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  110282. */
  110283. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  110284. /**
  110285. * The layer mask we are rendering the particles through.
  110286. */
  110287. layerMask: number;
  110288. private _capacity;
  110289. private _activeCount;
  110290. private _currentActiveCount;
  110291. private _accumulatedCount;
  110292. private _renderEffect;
  110293. private _updateEffect;
  110294. private _buffer0;
  110295. private _buffer1;
  110296. private _spriteBuffer;
  110297. private _updateVAO;
  110298. private _renderVAO;
  110299. private _targetIndex;
  110300. private _sourceBuffer;
  110301. private _targetBuffer;
  110302. private _engine;
  110303. private _currentRenderId;
  110304. private _started;
  110305. private _stopped;
  110306. private _timeDelta;
  110307. private _randomTexture;
  110308. private _randomTexture2;
  110309. private _attributesStrideSize;
  110310. private _updateEffectOptions;
  110311. private _randomTextureSize;
  110312. private _actualFrame;
  110313. private readonly _rawTextureWidth;
  110314. /**
  110315. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  110316. */
  110317. static readonly IsSupported: boolean;
  110318. /**
  110319. * An event triggered when the system is disposed.
  110320. */
  110321. onDisposeObservable: Observable<GPUParticleSystem>;
  110322. /**
  110323. * Gets the maximum number of particles active at the same time.
  110324. * @returns The max number of active particles.
  110325. */
  110326. getCapacity(): number;
  110327. /**
  110328. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  110329. * to override the particles.
  110330. */
  110331. forceDepthWrite: boolean;
  110332. /**
  110333. * Gets or set the number of active particles
  110334. */
  110335. activeParticleCount: number;
  110336. private _preWarmDone;
  110337. /**
  110338. * Is this system ready to be used/rendered
  110339. * @return true if the system is ready
  110340. */
  110341. isReady(): boolean;
  110342. /**
  110343. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110344. * @returns True if it has been started, otherwise false.
  110345. */
  110346. isStarted(): boolean;
  110347. /**
  110348. * Starts the particle system and begins to emit
  110349. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110350. */
  110351. start(delay?: number): void;
  110352. /**
  110353. * Stops the particle system.
  110354. */
  110355. stop(): void;
  110356. /**
  110357. * Remove all active particles
  110358. */
  110359. reset(): void;
  110360. /**
  110361. * Returns the string "GPUParticleSystem"
  110362. * @returns a string containing the class name
  110363. */
  110364. getClassName(): string;
  110365. private _colorGradientsTexture;
  110366. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  110367. /**
  110368. * Adds a new color gradient
  110369. * @param gradient defines the gradient to use (between 0 and 1)
  110370. * @param color1 defines the color to affect to the specified gradient
  110371. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110372. * @returns the current particle system
  110373. */
  110374. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  110375. /**
  110376. * Remove a specific color gradient
  110377. * @param gradient defines the gradient to remove
  110378. * @returns the current particle system
  110379. */
  110380. removeColorGradient(gradient: number): GPUParticleSystem;
  110381. private _angularSpeedGradientsTexture;
  110382. private _sizeGradientsTexture;
  110383. private _velocityGradientsTexture;
  110384. private _limitVelocityGradientsTexture;
  110385. private _dragGradientsTexture;
  110386. private _addFactorGradient;
  110387. /**
  110388. * Adds a new size gradient
  110389. * @param gradient defines the gradient to use (between 0 and 1)
  110390. * @param factor defines the size factor to affect to the specified gradient
  110391. * @returns the current particle system
  110392. */
  110393. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  110394. /**
  110395. * Remove a specific size gradient
  110396. * @param gradient defines the gradient to remove
  110397. * @returns the current particle system
  110398. */
  110399. removeSizeGradient(gradient: number): GPUParticleSystem;
  110400. /**
  110401. * Adds a new angular speed gradient
  110402. * @param gradient defines the gradient to use (between 0 and 1)
  110403. * @param factor defines the angular speed to affect to the specified gradient
  110404. * @returns the current particle system
  110405. */
  110406. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  110407. /**
  110408. * Remove a specific angular speed gradient
  110409. * @param gradient defines the gradient to remove
  110410. * @returns the current particle system
  110411. */
  110412. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  110413. /**
  110414. * Adds a new velocity gradient
  110415. * @param gradient defines the gradient to use (between 0 and 1)
  110416. * @param factor defines the velocity to affect to the specified gradient
  110417. * @returns the current particle system
  110418. */
  110419. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110420. /**
  110421. * Remove a specific velocity gradient
  110422. * @param gradient defines the gradient to remove
  110423. * @returns the current particle system
  110424. */
  110425. removeVelocityGradient(gradient: number): GPUParticleSystem;
  110426. /**
  110427. * Adds a new limit velocity gradient
  110428. * @param gradient defines the gradient to use (between 0 and 1)
  110429. * @param factor defines the limit velocity value to affect to the specified gradient
  110430. * @returns the current particle system
  110431. */
  110432. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110433. /**
  110434. * Remove a specific limit velocity gradient
  110435. * @param gradient defines the gradient to remove
  110436. * @returns the current particle system
  110437. */
  110438. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  110439. /**
  110440. * Adds a new drag gradient
  110441. * @param gradient defines the gradient to use (between 0 and 1)
  110442. * @param factor defines the drag value to affect to the specified gradient
  110443. * @returns the current particle system
  110444. */
  110445. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  110446. /**
  110447. * Remove a specific drag gradient
  110448. * @param gradient defines the gradient to remove
  110449. * @returns the current particle system
  110450. */
  110451. removeDragGradient(gradient: number): GPUParticleSystem;
  110452. /**
  110453. * Not supported by GPUParticleSystem
  110454. * @param gradient defines the gradient to use (between 0 and 1)
  110455. * @param factor defines the emit rate value to affect to the specified gradient
  110456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110457. * @returns the current particle system
  110458. */
  110459. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110460. /**
  110461. * Not supported by GPUParticleSystem
  110462. * @param gradient defines the gradient to remove
  110463. * @returns the current particle system
  110464. */
  110465. removeEmitRateGradient(gradient: number): IParticleSystem;
  110466. /**
  110467. * Not supported by GPUParticleSystem
  110468. * @param gradient defines the gradient to use (between 0 and 1)
  110469. * @param factor defines the start size value to affect to the specified gradient
  110470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110471. * @returns the current particle system
  110472. */
  110473. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110474. /**
  110475. * Not supported by GPUParticleSystem
  110476. * @param gradient defines the gradient to remove
  110477. * @returns the current particle system
  110478. */
  110479. removeStartSizeGradient(gradient: number): IParticleSystem;
  110480. /**
  110481. * Not supported by GPUParticleSystem
  110482. * @param gradient defines the gradient to use (between 0 and 1)
  110483. * @param min defines the color remap minimal range
  110484. * @param max defines the color remap maximal range
  110485. * @returns the current particle system
  110486. */
  110487. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110488. /**
  110489. * Not supported by GPUParticleSystem
  110490. * @param gradient defines the gradient to remove
  110491. * @returns the current particle system
  110492. */
  110493. removeColorRemapGradient(): IParticleSystem;
  110494. /**
  110495. * Not supported by GPUParticleSystem
  110496. * @param gradient defines the gradient to use (between 0 and 1)
  110497. * @param min defines the alpha remap minimal range
  110498. * @param max defines the alpha remap maximal range
  110499. * @returns the current particle system
  110500. */
  110501. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110502. /**
  110503. * Not supported by GPUParticleSystem
  110504. * @param gradient defines the gradient to remove
  110505. * @returns the current particle system
  110506. */
  110507. removeAlphaRemapGradient(): IParticleSystem;
  110508. /**
  110509. * Not supported by GPUParticleSystem
  110510. * @param gradient defines the gradient to use (between 0 and 1)
  110511. * @param color defines the color to affect to the specified gradient
  110512. * @returns the current particle system
  110513. */
  110514. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  110515. /**
  110516. * Not supported by GPUParticleSystem
  110517. * @param gradient defines the gradient to remove
  110518. * @returns the current particle system
  110519. */
  110520. removeRampGradient(): IParticleSystem;
  110521. /**
  110522. * Not supported by GPUParticleSystem
  110523. * @returns the list of ramp gradients
  110524. */
  110525. getRampGradients(): Nullable<Array<Color3Gradient>>;
  110526. /**
  110527. * Not supported by GPUParticleSystem
  110528. * Gets or sets a boolean indicating that ramp gradients must be used
  110529. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110530. */
  110531. useRampGradients: boolean;
  110532. /**
  110533. * Not supported by GPUParticleSystem
  110534. * @param gradient defines the gradient to use (between 0 and 1)
  110535. * @param factor defines the life time factor to affect to the specified gradient
  110536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110537. * @returns the current particle system
  110538. */
  110539. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110540. /**
  110541. * Not supported by GPUParticleSystem
  110542. * @param gradient defines the gradient to remove
  110543. * @returns the current particle system
  110544. */
  110545. removeLifeTimeGradient(gradient: number): IParticleSystem;
  110546. /**
  110547. * Instantiates a GPU particle system.
  110548. * 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.
  110549. * @param name The name of the particle system
  110550. * @param options The options used to create the system
  110551. * @param scene The scene the particle system belongs to
  110552. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  110553. */
  110554. constructor(name: string, options: Partial<{
  110555. capacity: number;
  110556. randomTextureSize: number;
  110557. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  110558. protected _reset(): void;
  110559. private _createUpdateVAO;
  110560. private _createRenderVAO;
  110561. private _initialize;
  110562. /** @hidden */
  110563. _recreateUpdateEffect(): void;
  110564. /** @hidden */
  110565. _recreateRenderEffect(): void;
  110566. /**
  110567. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  110568. * @param preWarm defines if we are in the pre-warmimg phase
  110569. */
  110570. animate(preWarm?: boolean): void;
  110571. private _createFactorGradientTexture;
  110572. private _createSizeGradientTexture;
  110573. private _createAngularSpeedGradientTexture;
  110574. private _createVelocityGradientTexture;
  110575. private _createLimitVelocityGradientTexture;
  110576. private _createDragGradientTexture;
  110577. private _createColorGradientTexture;
  110578. /**
  110579. * Renders the particle system in its current state
  110580. * @param preWarm defines if the system should only update the particles but not render them
  110581. * @returns the current number of particles
  110582. */
  110583. render(preWarm?: boolean): number;
  110584. /**
  110585. * Rebuilds the particle system
  110586. */
  110587. rebuild(): void;
  110588. private _releaseBuffers;
  110589. private _releaseVAOs;
  110590. /**
  110591. * Disposes the particle system and free the associated resources
  110592. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  110593. */
  110594. dispose(disposeTexture?: boolean): void;
  110595. /**
  110596. * Clones the particle system.
  110597. * @param name The name of the cloned object
  110598. * @param newEmitter The new emitter to use
  110599. * @returns the cloned particle system
  110600. */
  110601. clone(name: string, newEmitter: any): GPUParticleSystem;
  110602. /**
  110603. * Serializes the particle system to a JSON object.
  110604. * @returns the JSON object
  110605. */
  110606. serialize(): any;
  110607. /**
  110608. * Parses a JSON object to create a GPU particle system.
  110609. * @param parsedParticleSystem The JSON object to parse
  110610. * @param scene The scene to create the particle system in
  110611. * @param rootUrl The root url to use to load external dependencies like texture
  110612. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  110613. * @returns the parsed GPU particle system
  110614. */
  110615. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  110616. }
  110617. }
  110618. declare module BABYLON {
  110619. /**
  110620. * Represents a set of particle systems working together to create a specific effect
  110621. */
  110622. export class ParticleSystemSet implements IDisposable {
  110623. private _emitterCreationOptions;
  110624. private _emitterNode;
  110625. /**
  110626. * Gets the particle system list
  110627. */
  110628. systems: IParticleSystem[];
  110629. /**
  110630. * Gets the emitter node used with this set
  110631. */
  110632. readonly emitterNode: Nullable<TransformNode>;
  110633. /**
  110634. * Creates a new emitter mesh as a sphere
  110635. * @param options defines the options used to create the sphere
  110636. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  110637. * @param scene defines the hosting scene
  110638. */
  110639. setEmitterAsSphere(options: {
  110640. diameter: number;
  110641. segments: number;
  110642. color: Color3;
  110643. }, renderingGroupId: number, scene: Scene): void;
  110644. /**
  110645. * Starts all particle systems of the set
  110646. * @param emitter defines an optional mesh to use as emitter for the particle systems
  110647. */
  110648. start(emitter?: AbstractMesh): void;
  110649. /**
  110650. * Release all associated resources
  110651. */
  110652. dispose(): void;
  110653. /**
  110654. * Serialize the set into a JSON compatible object
  110655. * @returns a JSON compatible representation of the set
  110656. */
  110657. serialize(): any;
  110658. /**
  110659. * Parse a new ParticleSystemSet from a serialized source
  110660. * @param data defines a JSON compatible representation of the set
  110661. * @param scene defines the hosting scene
  110662. * @param gpu defines if we want GPU particles or CPU particles
  110663. * @returns a new ParticleSystemSet
  110664. */
  110665. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  110666. }
  110667. }
  110668. declare module BABYLON {
  110669. /**
  110670. * This class is made for on one-liner static method to help creating particle system set.
  110671. */
  110672. export class ParticleHelper {
  110673. /**
  110674. * Gets or sets base Assets URL
  110675. */
  110676. static BaseAssetsUrl: string;
  110677. /**
  110678. * Create a default particle system that you can tweak
  110679. * @param emitter defines the emitter to use
  110680. * @param capacity defines the system capacity (default is 500 particles)
  110681. * @param scene defines the hosting scene
  110682. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  110683. * @returns the new Particle system
  110684. */
  110685. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  110686. /**
  110687. * This is the main static method (one-liner) of this helper to create different particle systems
  110688. * @param type This string represents the type to the particle system to create
  110689. * @param scene The scene where the particle system should live
  110690. * @param gpu If the system will use gpu
  110691. * @returns the ParticleSystemSet created
  110692. */
  110693. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  110694. /**
  110695. * Static function used to export a particle system to a ParticleSystemSet variable.
  110696. * Please note that the emitter shape is not exported
  110697. * @param systems defines the particle systems to export
  110698. * @returns the created particle system set
  110699. */
  110700. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  110701. }
  110702. }
  110703. declare module BABYLON {
  110704. interface Engine {
  110705. /**
  110706. * Create an effect to use with particle systems.
  110707. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  110708. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  110709. * @param uniformsNames defines a list of attribute names
  110710. * @param samplers defines an array of string used to represent textures
  110711. * @param defines defines the string containing the defines to use to compile the shaders
  110712. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  110713. * @param onCompiled defines a function to call when the effect creation is successful
  110714. * @param onError defines a function to call when the effect creation has failed
  110715. * @returns the new Effect
  110716. */
  110717. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  110718. }
  110719. interface Mesh {
  110720. /**
  110721. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  110722. * @returns an array of IParticleSystem
  110723. */
  110724. getEmittedParticleSystems(): IParticleSystem[];
  110725. /**
  110726. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  110727. * @returns an array of IParticleSystem
  110728. */
  110729. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  110730. }
  110731. /**
  110732. * @hidden
  110733. */
  110734. export var _IDoNeedToBeInTheBuild: number;
  110735. }
  110736. declare module BABYLON {
  110737. interface Scene {
  110738. /** @hidden (Backing field) */
  110739. _physicsEngine: Nullable<IPhysicsEngine>;
  110740. /**
  110741. * Gets the current physics engine
  110742. * @returns a IPhysicsEngine or null if none attached
  110743. */
  110744. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  110745. /**
  110746. * Enables physics to the current scene
  110747. * @param gravity defines the scene's gravity for the physics engine
  110748. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110749. * @return a boolean indicating if the physics engine was initialized
  110750. */
  110751. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  110752. /**
  110753. * Disables and disposes the physics engine associated with the scene
  110754. */
  110755. disablePhysicsEngine(): void;
  110756. /**
  110757. * Gets a boolean indicating if there is an active physics engine
  110758. * @returns a boolean indicating if there is an active physics engine
  110759. */
  110760. isPhysicsEnabled(): boolean;
  110761. /**
  110762. * Deletes a physics compound impostor
  110763. * @param compound defines the compound to delete
  110764. */
  110765. deleteCompoundImpostor(compound: any): void;
  110766. /**
  110767. * An event triggered when physic simulation is about to be run
  110768. */
  110769. onBeforePhysicsObservable: Observable<Scene>;
  110770. /**
  110771. * An event triggered when physic simulation has been done
  110772. */
  110773. onAfterPhysicsObservable: Observable<Scene>;
  110774. }
  110775. interface AbstractMesh {
  110776. /** @hidden */
  110777. _physicsImpostor: Nullable<PhysicsImpostor>;
  110778. /**
  110779. * Gets or sets impostor used for physic simulation
  110780. * @see http://doc.babylonjs.com/features/physics_engine
  110781. */
  110782. physicsImpostor: Nullable<PhysicsImpostor>;
  110783. /**
  110784. * Gets the current physics impostor
  110785. * @see http://doc.babylonjs.com/features/physics_engine
  110786. * @returns a physics impostor or null
  110787. */
  110788. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  110789. /** Apply a physic impulse to the mesh
  110790. * @param force defines the force to apply
  110791. * @param contactPoint defines where to apply the force
  110792. * @returns the current mesh
  110793. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110794. */
  110795. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  110796. /**
  110797. * Creates a physic joint between two meshes
  110798. * @param otherMesh defines the other mesh to use
  110799. * @param pivot1 defines the pivot to use on this mesh
  110800. * @param pivot2 defines the pivot to use on the other mesh
  110801. * @param options defines additional options (can be plugin dependent)
  110802. * @returns the current mesh
  110803. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110804. */
  110805. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  110806. /** @hidden */
  110807. _disposePhysicsObserver: Nullable<Observer<Node>>;
  110808. }
  110809. /**
  110810. * Defines the physics engine scene component responsible to manage a physics engine
  110811. */
  110812. export class PhysicsEngineSceneComponent implements ISceneComponent {
  110813. /**
  110814. * The component name helpful to identify the component in the list of scene components.
  110815. */
  110816. readonly name: string;
  110817. /**
  110818. * The scene the component belongs to.
  110819. */
  110820. scene: Scene;
  110821. /**
  110822. * Creates a new instance of the component for the given scene
  110823. * @param scene Defines the scene to register the component in
  110824. */
  110825. constructor(scene: Scene);
  110826. /**
  110827. * Registers the component in a given scene
  110828. */
  110829. register(): void;
  110830. /**
  110831. * Rebuilds the elements related to this component in case of
  110832. * context lost for instance.
  110833. */
  110834. rebuild(): void;
  110835. /**
  110836. * Disposes the component and the associated ressources
  110837. */
  110838. dispose(): void;
  110839. }
  110840. }
  110841. declare module BABYLON {
  110842. /**
  110843. * A helper for physics simulations
  110844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110845. */
  110846. export class PhysicsHelper {
  110847. private _scene;
  110848. private _physicsEngine;
  110849. /**
  110850. * Initializes the Physics helper
  110851. * @param scene Babylon.js scene
  110852. */
  110853. constructor(scene: Scene);
  110854. /**
  110855. * Applies a radial explosion impulse
  110856. * @param origin the origin of the explosion
  110857. * @param radiusOrEventOptions the radius or the options of radial explosion
  110858. * @param strength the explosion strength
  110859. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110860. * @returns A physics radial explosion event, or null
  110861. */
  110862. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110863. /**
  110864. * Applies a radial explosion force
  110865. * @param origin the origin of the explosion
  110866. * @param radiusOrEventOptions the radius or the options of radial explosion
  110867. * @param strength the explosion strength
  110868. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110869. * @returns A physics radial explosion event, or null
  110870. */
  110871. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110872. /**
  110873. * Creates a gravitational field
  110874. * @param origin the origin of the explosion
  110875. * @param radiusOrEventOptions the radius or the options of radial explosion
  110876. * @param strength the explosion strength
  110877. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110878. * @returns A physics gravitational field event, or null
  110879. */
  110880. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  110881. /**
  110882. * Creates a physics updraft event
  110883. * @param origin the origin of the updraft
  110884. * @param radiusOrEventOptions the radius or the options of the updraft
  110885. * @param strength the strength of the updraft
  110886. * @param height the height of the updraft
  110887. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110888. * @returns A physics updraft event, or null
  110889. */
  110890. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  110891. /**
  110892. * Creates a physics vortex event
  110893. * @param origin the of the vortex
  110894. * @param radiusOrEventOptions the radius or the options of the vortex
  110895. * @param strength the strength of the vortex
  110896. * @param height the height of the vortex
  110897. * @returns a Physics vortex event, or null
  110898. * A physics vortex event or null
  110899. */
  110900. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  110901. }
  110902. /**
  110903. * Represents a physics radial explosion event
  110904. */
  110905. class PhysicsRadialExplosionEvent {
  110906. private _scene;
  110907. private _options;
  110908. private _sphere;
  110909. private _dataFetched;
  110910. /**
  110911. * Initializes a radial explosioin event
  110912. * @param _scene BabylonJS scene
  110913. * @param _options The options for the vortex event
  110914. */
  110915. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  110916. /**
  110917. * Returns the data related to the radial explosion event (sphere).
  110918. * @returns The radial explosion event data
  110919. */
  110920. getData(): PhysicsRadialExplosionEventData;
  110921. /**
  110922. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110923. * @param impostor A physics imposter
  110924. * @param origin the origin of the explosion
  110925. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  110926. */
  110927. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  110928. /**
  110929. * Triggers affecterd impostors callbacks
  110930. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  110931. */
  110932. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  110933. /**
  110934. * Disposes the sphere.
  110935. * @param force Specifies if the sphere should be disposed by force
  110936. */
  110937. dispose(force?: boolean): void;
  110938. /*** Helpers ***/
  110939. private _prepareSphere;
  110940. private _intersectsWithSphere;
  110941. }
  110942. /**
  110943. * Represents a gravitational field event
  110944. */
  110945. class PhysicsGravitationalFieldEvent {
  110946. private _physicsHelper;
  110947. private _scene;
  110948. private _origin;
  110949. private _options;
  110950. private _tickCallback;
  110951. private _sphere;
  110952. private _dataFetched;
  110953. /**
  110954. * Initializes the physics gravitational field event
  110955. * @param _physicsHelper A physics helper
  110956. * @param _scene BabylonJS scene
  110957. * @param _origin The origin position of the gravitational field event
  110958. * @param _options The options for the vortex event
  110959. */
  110960. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  110961. /**
  110962. * Returns the data related to the gravitational field event (sphere).
  110963. * @returns A gravitational field event
  110964. */
  110965. getData(): PhysicsGravitationalFieldEventData;
  110966. /**
  110967. * Enables the gravitational field.
  110968. */
  110969. enable(): void;
  110970. /**
  110971. * Disables the gravitational field.
  110972. */
  110973. disable(): void;
  110974. /**
  110975. * Disposes the sphere.
  110976. * @param force The force to dispose from the gravitational field event
  110977. */
  110978. dispose(force?: boolean): void;
  110979. private _tick;
  110980. }
  110981. /**
  110982. * Represents a physics updraft event
  110983. */
  110984. class PhysicsUpdraftEvent {
  110985. private _scene;
  110986. private _origin;
  110987. private _options;
  110988. private _physicsEngine;
  110989. private _originTop;
  110990. private _originDirection;
  110991. private _tickCallback;
  110992. private _cylinder;
  110993. private _cylinderPosition;
  110994. private _dataFetched;
  110995. /**
  110996. * Initializes the physics updraft event
  110997. * @param _scene BabylonJS scene
  110998. * @param _origin The origin position of the updraft
  110999. * @param _options The options for the updraft event
  111000. */
  111001. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111002. /**
  111003. * Returns the data related to the updraft event (cylinder).
  111004. * @returns A physics updraft event
  111005. */
  111006. getData(): PhysicsUpdraftEventData;
  111007. /**
  111008. * Enables the updraft.
  111009. */
  111010. enable(): void;
  111011. /**
  111012. * Disables the updraft.
  111013. */
  111014. disable(): void;
  111015. /**
  111016. * Disposes the cylinder.
  111017. * @param force Specifies if the updraft should be disposed by force
  111018. */
  111019. dispose(force?: boolean): void;
  111020. private getImpostorHitData;
  111021. private _tick;
  111022. /*** Helpers ***/
  111023. private _prepareCylinder;
  111024. private _intersectsWithCylinder;
  111025. }
  111026. /**
  111027. * Represents a physics vortex event
  111028. */
  111029. class PhysicsVortexEvent {
  111030. private _scene;
  111031. private _origin;
  111032. private _options;
  111033. private _physicsEngine;
  111034. private _originTop;
  111035. private _tickCallback;
  111036. private _cylinder;
  111037. private _cylinderPosition;
  111038. private _dataFetched;
  111039. /**
  111040. * Initializes the physics vortex event
  111041. * @param _scene The BabylonJS scene
  111042. * @param _origin The origin position of the vortex
  111043. * @param _options The options for the vortex event
  111044. */
  111045. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111046. /**
  111047. * Returns the data related to the vortex event (cylinder).
  111048. * @returns The physics vortex event data
  111049. */
  111050. getData(): PhysicsVortexEventData;
  111051. /**
  111052. * Enables the vortex.
  111053. */
  111054. enable(): void;
  111055. /**
  111056. * Disables the cortex.
  111057. */
  111058. disable(): void;
  111059. /**
  111060. * Disposes the sphere.
  111061. * @param force
  111062. */
  111063. dispose(force?: boolean): void;
  111064. private getImpostorHitData;
  111065. private _tick;
  111066. /*** Helpers ***/
  111067. private _prepareCylinder;
  111068. private _intersectsWithCylinder;
  111069. }
  111070. /**
  111071. * Options fot the radial explosion event
  111072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111073. */
  111074. export class PhysicsRadialExplosionEventOptions {
  111075. /**
  111076. * The radius of the sphere for the radial explosion.
  111077. */
  111078. radius: number;
  111079. /**
  111080. * The strenth of the explosion.
  111081. */
  111082. strength: number;
  111083. /**
  111084. * The strenght of the force in correspondence to the distance of the affected object
  111085. */
  111086. falloff: PhysicsRadialImpulseFalloff;
  111087. /**
  111088. * Sphere options for the radial explosion.
  111089. */
  111090. sphere: {
  111091. segments: number;
  111092. diameter: number;
  111093. };
  111094. /**
  111095. * Sphere options for the radial explosion.
  111096. */
  111097. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  111098. }
  111099. /**
  111100. * Options fot the updraft event
  111101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111102. */
  111103. export class PhysicsUpdraftEventOptions {
  111104. /**
  111105. * The radius of the cylinder for the vortex
  111106. */
  111107. radius: number;
  111108. /**
  111109. * The strenth of the updraft.
  111110. */
  111111. strength: number;
  111112. /**
  111113. * The height of the cylinder for the updraft.
  111114. */
  111115. height: number;
  111116. /**
  111117. * The mode for the the updraft.
  111118. */
  111119. updraftMode: PhysicsUpdraftMode;
  111120. }
  111121. /**
  111122. * Options fot the vortex event
  111123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111124. */
  111125. export class PhysicsVortexEventOptions {
  111126. /**
  111127. * The radius of the cylinder for the vortex
  111128. */
  111129. radius: number;
  111130. /**
  111131. * The strenth of the vortex.
  111132. */
  111133. strength: number;
  111134. /**
  111135. * The height of the cylinder for the vortex.
  111136. */
  111137. height: number;
  111138. /**
  111139. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  111140. */
  111141. centripetalForceThreshold: number;
  111142. /**
  111143. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  111144. */
  111145. centripetalForceMultiplier: number;
  111146. /**
  111147. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  111148. */
  111149. centrifugalForceMultiplier: number;
  111150. /**
  111151. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  111152. */
  111153. updraftForceMultiplier: number;
  111154. }
  111155. /**
  111156. * The strenght of the force in correspondence to the distance of the affected object
  111157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111158. */
  111159. export enum PhysicsRadialImpulseFalloff {
  111160. /** Defines that impulse is constant in strength across it's whole radius */
  111161. Constant = 0,
  111162. /** Defines that impulse gets weaker if it's further from the origin */
  111163. Linear = 1
  111164. }
  111165. /**
  111166. * The strength of the force in correspondence to the distance of the affected object
  111167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111168. */
  111169. export enum PhysicsUpdraftMode {
  111170. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111171. Center = 0,
  111172. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111173. Perpendicular = 1
  111174. }
  111175. /**
  111176. * Interface for a physics hit data
  111177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111178. */
  111179. export interface PhysicsHitData {
  111180. /**
  111181. * The force applied at the contact point
  111182. */
  111183. force: Vector3;
  111184. /**
  111185. * The contact point
  111186. */
  111187. contactPoint: Vector3;
  111188. /**
  111189. * The distance from the origin to the contact point
  111190. */
  111191. distanceFromOrigin: number;
  111192. }
  111193. /**
  111194. * Interface for radial explosion event data
  111195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111196. */
  111197. export interface PhysicsRadialExplosionEventData {
  111198. /**
  111199. * A sphere used for the radial explosion event
  111200. */
  111201. sphere: Mesh;
  111202. }
  111203. /**
  111204. * Interface for gravitational field event data
  111205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111206. */
  111207. export interface PhysicsGravitationalFieldEventData {
  111208. /**
  111209. * A sphere mesh used for the gravitational field event
  111210. */
  111211. sphere: Mesh;
  111212. }
  111213. /**
  111214. * Interface for updraft event data
  111215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111216. */
  111217. export interface PhysicsUpdraftEventData {
  111218. /**
  111219. * A cylinder used for the updraft event
  111220. */
  111221. cylinder: Mesh;
  111222. }
  111223. /**
  111224. * Interface for vortex event data
  111225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111226. */
  111227. export interface PhysicsVortexEventData {
  111228. /**
  111229. * A cylinder used for the vortex event
  111230. */
  111231. cylinder: Mesh;
  111232. }
  111233. /**
  111234. * Interface for an affected physics impostor
  111235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111236. */
  111237. export interface PhysicsAffectedImpostorWithData {
  111238. /**
  111239. * The impostor affected by the effect
  111240. */
  111241. impostor: PhysicsImpostor;
  111242. /**
  111243. * The data about the hit/horce from the explosion
  111244. */
  111245. hitData: PhysicsHitData;
  111246. }
  111247. }
  111248. declare module BABYLON {
  111249. /** @hidden */
  111250. export var blackAndWhitePixelShader: {
  111251. name: string;
  111252. shader: string;
  111253. };
  111254. }
  111255. declare module BABYLON {
  111256. /**
  111257. * Post process used to render in black and white
  111258. */
  111259. export class BlackAndWhitePostProcess extends PostProcess {
  111260. /**
  111261. * Linear about to convert he result to black and white (default: 1)
  111262. */
  111263. degree: number;
  111264. /**
  111265. * Creates a black and white post process
  111266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  111267. * @param name The name of the effect.
  111268. * @param options The required width/height ratio to downsize to before computing the render pass.
  111269. * @param camera The camera to apply the render pass to.
  111270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111271. * @param engine The engine which the post process will be applied. (default: current engine)
  111272. * @param reusable If the post process can be reused on the same frame. (default: false)
  111273. */
  111274. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111275. }
  111276. }
  111277. declare module BABYLON {
  111278. /**
  111279. * This represents a set of one or more post processes in Babylon.
  111280. * A post process can be used to apply a shader to a texture after it is rendered.
  111281. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111282. */
  111283. export class PostProcessRenderEffect {
  111284. private _postProcesses;
  111285. private _getPostProcesses;
  111286. private _singleInstance;
  111287. private _cameras;
  111288. private _indicesForCamera;
  111289. /**
  111290. * Name of the effect
  111291. * @hidden
  111292. */
  111293. _name: string;
  111294. /**
  111295. * Instantiates a post process render effect.
  111296. * A post process can be used to apply a shader to a texture after it is rendered.
  111297. * @param engine The engine the effect is tied to
  111298. * @param name The name of the effect
  111299. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  111300. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  111301. */
  111302. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  111303. /**
  111304. * Checks if all the post processes in the effect are supported.
  111305. */
  111306. readonly isSupported: boolean;
  111307. /**
  111308. * Updates the current state of the effect
  111309. * @hidden
  111310. */
  111311. _update(): void;
  111312. /**
  111313. * Attaches the effect on cameras
  111314. * @param cameras The camera to attach to.
  111315. * @hidden
  111316. */
  111317. _attachCameras(cameras: Camera): void;
  111318. /**
  111319. * Attaches the effect on cameras
  111320. * @param cameras The camera to attach to.
  111321. * @hidden
  111322. */
  111323. _attachCameras(cameras: Camera[]): void;
  111324. /**
  111325. * Detatches the effect on cameras
  111326. * @param cameras The camera to detatch from.
  111327. * @hidden
  111328. */
  111329. _detachCameras(cameras: Camera): void;
  111330. /**
  111331. * Detatches the effect on cameras
  111332. * @param cameras The camera to detatch from.
  111333. * @hidden
  111334. */
  111335. _detachCameras(cameras: Camera[]): void;
  111336. /**
  111337. * Enables the effect on given cameras
  111338. * @param cameras The camera to enable.
  111339. * @hidden
  111340. */
  111341. _enable(cameras: Camera): void;
  111342. /**
  111343. * Enables the effect on given cameras
  111344. * @param cameras The camera to enable.
  111345. * @hidden
  111346. */
  111347. _enable(cameras: Nullable<Camera[]>): void;
  111348. /**
  111349. * Disables the effect on the given cameras
  111350. * @param cameras The camera to disable.
  111351. * @hidden
  111352. */
  111353. _disable(cameras: Camera): void;
  111354. /**
  111355. * Disables the effect on the given cameras
  111356. * @param cameras The camera to disable.
  111357. * @hidden
  111358. */
  111359. _disable(cameras: Nullable<Camera[]>): void;
  111360. /**
  111361. * Gets a list of the post processes contained in the effect.
  111362. * @param camera The camera to get the post processes on.
  111363. * @returns The list of the post processes in the effect.
  111364. */
  111365. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  111366. }
  111367. }
  111368. declare module BABYLON {
  111369. /** @hidden */
  111370. export var extractHighlightsPixelShader: {
  111371. name: string;
  111372. shader: string;
  111373. };
  111374. }
  111375. declare module BABYLON {
  111376. /**
  111377. * 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.
  111378. */
  111379. export class ExtractHighlightsPostProcess extends PostProcess {
  111380. /**
  111381. * The luminance threshold, pixels below this value will be set to black.
  111382. */
  111383. threshold: number;
  111384. /** @hidden */
  111385. _exposure: number;
  111386. /**
  111387. * Post process which has the input texture to be used when performing highlight extraction
  111388. * @hidden
  111389. */
  111390. _inputPostProcess: Nullable<PostProcess>;
  111391. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111392. }
  111393. }
  111394. declare module BABYLON {
  111395. /** @hidden */
  111396. export var bloomMergePixelShader: {
  111397. name: string;
  111398. shader: string;
  111399. };
  111400. }
  111401. declare module BABYLON {
  111402. /**
  111403. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111404. */
  111405. export class BloomMergePostProcess extends PostProcess {
  111406. /** Weight of the bloom to be added to the original input. */
  111407. weight: number;
  111408. /**
  111409. * Creates a new instance of @see BloomMergePostProcess
  111410. * @param name The name of the effect.
  111411. * @param originalFromInput Post process which's input will be used for the merge.
  111412. * @param blurred Blurred highlights post process which's output will be used.
  111413. * @param weight Weight of the bloom to be added to the original input.
  111414. * @param options The required width/height ratio to downsize to before computing the render pass.
  111415. * @param camera The camera to apply the render pass to.
  111416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111417. * @param engine The engine which the post process will be applied. (default: current engine)
  111418. * @param reusable If the post process can be reused on the same frame. (default: false)
  111419. * @param textureType Type of textures used when performing the post process. (default: 0)
  111420. * @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)
  111421. */
  111422. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  111423. /** Weight of the bloom to be added to the original input. */
  111424. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111425. }
  111426. }
  111427. declare module BABYLON {
  111428. /**
  111429. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  111430. */
  111431. export class BloomEffect extends PostProcessRenderEffect {
  111432. private bloomScale;
  111433. /**
  111434. * @hidden Internal
  111435. */
  111436. _effects: Array<PostProcess>;
  111437. /**
  111438. * @hidden Internal
  111439. */
  111440. _downscale: ExtractHighlightsPostProcess;
  111441. private _blurX;
  111442. private _blurY;
  111443. private _merge;
  111444. /**
  111445. * The luminance threshold to find bright areas of the image to bloom.
  111446. */
  111447. threshold: number;
  111448. /**
  111449. * The strength of the bloom.
  111450. */
  111451. weight: number;
  111452. /**
  111453. * Specifies the size of the bloom blur kernel, relative to the final output size
  111454. */
  111455. kernel: number;
  111456. /**
  111457. * Creates a new instance of @see BloomEffect
  111458. * @param scene The scene the effect belongs to.
  111459. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  111460. * @param bloomKernel The size of the kernel to be used when applying the blur.
  111461. * @param bloomWeight The the strength of bloom.
  111462. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111463. * @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)
  111464. */
  111465. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  111466. /**
  111467. * Disposes each of the internal effects for a given camera.
  111468. * @param camera The camera to dispose the effect on.
  111469. */
  111470. disposeEffects(camera: Camera): void;
  111471. /**
  111472. * @hidden Internal
  111473. */
  111474. _updateEffects(): void;
  111475. /**
  111476. * Internal
  111477. * @returns if all the contained post processes are ready.
  111478. * @hidden
  111479. */
  111480. _isReady(): boolean;
  111481. }
  111482. }
  111483. declare module BABYLON {
  111484. /** @hidden */
  111485. export var chromaticAberrationPixelShader: {
  111486. name: string;
  111487. shader: string;
  111488. };
  111489. }
  111490. declare module BABYLON {
  111491. /**
  111492. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  111493. */
  111494. export class ChromaticAberrationPostProcess extends PostProcess {
  111495. /**
  111496. * The amount of seperation of rgb channels (default: 30)
  111497. */
  111498. aberrationAmount: number;
  111499. /**
  111500. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  111501. */
  111502. radialIntensity: number;
  111503. /**
  111504. * 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))
  111505. */
  111506. direction: Vector2;
  111507. /**
  111508. * 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))
  111509. */
  111510. centerPosition: Vector2;
  111511. /**
  111512. * Creates a new instance ChromaticAberrationPostProcess
  111513. * @param name The name of the effect.
  111514. * @param screenWidth The width of the screen to apply the effect on.
  111515. * @param screenHeight The height of the screen to apply the effect on.
  111516. * @param options The required width/height ratio to downsize to before computing the render pass.
  111517. * @param camera The camera to apply the render pass to.
  111518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111519. * @param engine The engine which the post process will be applied. (default: current engine)
  111520. * @param reusable If the post process can be reused on the same frame. (default: false)
  111521. * @param textureType Type of textures used when performing the post process. (default: 0)
  111522. * @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)
  111523. */
  111524. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111525. }
  111526. }
  111527. declare module BABYLON {
  111528. /** @hidden */
  111529. export var circleOfConfusionPixelShader: {
  111530. name: string;
  111531. shader: string;
  111532. };
  111533. }
  111534. declare module BABYLON {
  111535. /**
  111536. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  111537. */
  111538. export class CircleOfConfusionPostProcess extends PostProcess {
  111539. /**
  111540. * 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.
  111541. */
  111542. lensSize: number;
  111543. /**
  111544. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111545. */
  111546. fStop: number;
  111547. /**
  111548. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111549. */
  111550. focusDistance: number;
  111551. /**
  111552. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  111553. */
  111554. focalLength: number;
  111555. private _depthTexture;
  111556. /**
  111557. * Creates a new instance CircleOfConfusionPostProcess
  111558. * @param name The name of the effect.
  111559. * @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.
  111560. * @param options The required width/height ratio to downsize to before computing the render pass.
  111561. * @param camera The camera to apply the render pass to.
  111562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111563. * @param engine The engine which the post process will be applied. (default: current engine)
  111564. * @param reusable If the post process can be reused on the same frame. (default: false)
  111565. * @param textureType Type of textures used when performing the post process. (default: 0)
  111566. * @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)
  111567. */
  111568. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111569. /**
  111570. * 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.
  111571. */
  111572. depthTexture: RenderTargetTexture;
  111573. }
  111574. }
  111575. declare module BABYLON {
  111576. /** @hidden */
  111577. export var colorCorrectionPixelShader: {
  111578. name: string;
  111579. shader: string;
  111580. };
  111581. }
  111582. declare module BABYLON {
  111583. /**
  111584. *
  111585. * This post-process allows the modification of rendered colors by using
  111586. * a 'look-up table' (LUT). This effect is also called Color Grading.
  111587. *
  111588. * The object needs to be provided an url to a texture containing the color
  111589. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  111590. * Use an image editing software to tweak the LUT to match your needs.
  111591. *
  111592. * For an example of a color LUT, see here:
  111593. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  111594. * For explanations on color grading, see here:
  111595. * @see http://udn.epicgames.com/Three/ColorGrading.html
  111596. *
  111597. */
  111598. export class ColorCorrectionPostProcess extends PostProcess {
  111599. private _colorTableTexture;
  111600. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111601. }
  111602. }
  111603. declare module BABYLON {
  111604. /** @hidden */
  111605. export var convolutionPixelShader: {
  111606. name: string;
  111607. shader: string;
  111608. };
  111609. }
  111610. declare module BABYLON {
  111611. /**
  111612. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  111613. * input texture to perform effects such as edge detection or sharpening
  111614. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  111615. */
  111616. export class ConvolutionPostProcess extends PostProcess {
  111617. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111618. kernel: number[];
  111619. /**
  111620. * Creates a new instance ConvolutionPostProcess
  111621. * @param name The name of the effect.
  111622. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  111623. * @param options The required width/height ratio to downsize to before computing the render pass.
  111624. * @param camera The camera to apply the render pass to.
  111625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111626. * @param engine The engine which the post process will be applied. (default: current engine)
  111627. * @param reusable If the post process can be reused on the same frame. (default: false)
  111628. * @param textureType Type of textures used when performing the post process. (default: 0)
  111629. */
  111630. constructor(name: string,
  111631. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111632. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111633. /**
  111634. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111635. */
  111636. static EdgeDetect0Kernel: number[];
  111637. /**
  111638. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111639. */
  111640. static EdgeDetect1Kernel: number[];
  111641. /**
  111642. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111643. */
  111644. static EdgeDetect2Kernel: number[];
  111645. /**
  111646. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111647. */
  111648. static SharpenKernel: number[];
  111649. /**
  111650. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111651. */
  111652. static EmbossKernel: number[];
  111653. /**
  111654. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111655. */
  111656. static GaussianKernel: number[];
  111657. }
  111658. }
  111659. declare module BABYLON {
  111660. /**
  111661. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  111662. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  111663. * based on samples that have a large difference in distance than the center pixel.
  111664. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  111665. */
  111666. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  111667. direction: Vector2;
  111668. /**
  111669. * Creates a new instance CircleOfConfusionPostProcess
  111670. * @param name The name of the effect.
  111671. * @param scene The scene the effect belongs to.
  111672. * @param direction The direction the blur should be applied.
  111673. * @param kernel The size of the kernel used to blur.
  111674. * @param options The required width/height ratio to downsize to before computing the render pass.
  111675. * @param camera The camera to apply the render pass to.
  111676. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  111677. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  111678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111679. * @param engine The engine which the post process will be applied. (default: current engine)
  111680. * @param reusable If the post process can be reused on the same frame. (default: false)
  111681. * @param textureType Type of textures used when performing the post process. (default: 0)
  111682. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  111683. */
  111684. constructor(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);
  111685. }
  111686. }
  111687. declare module BABYLON {
  111688. /** @hidden */
  111689. export var depthOfFieldMergePixelShader: {
  111690. name: string;
  111691. shader: string;
  111692. };
  111693. }
  111694. declare module BABYLON {
  111695. /**
  111696. * Options to be set when merging outputs from the default pipeline.
  111697. */
  111698. export class DepthOfFieldMergePostProcessOptions {
  111699. /**
  111700. * The original image to merge on top of
  111701. */
  111702. originalFromInput: PostProcess;
  111703. /**
  111704. * Parameters to perform the merge of the depth of field effect
  111705. */
  111706. depthOfField?: {
  111707. circleOfConfusion: PostProcess;
  111708. blurSteps: Array<PostProcess>;
  111709. };
  111710. /**
  111711. * Parameters to perform the merge of bloom effect
  111712. */
  111713. bloom?: {
  111714. blurred: PostProcess;
  111715. weight: number;
  111716. };
  111717. }
  111718. /**
  111719. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111720. */
  111721. export class DepthOfFieldMergePostProcess extends PostProcess {
  111722. private blurSteps;
  111723. /**
  111724. * Creates a new instance of DepthOfFieldMergePostProcess
  111725. * @param name The name of the effect.
  111726. * @param originalFromInput Post process which's input will be used for the merge.
  111727. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  111728. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  111729. * @param options The required width/height ratio to downsize to before computing the render pass.
  111730. * @param camera The camera to apply the render pass to.
  111731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111732. * @param engine The engine which the post process will be applied. (default: current engine)
  111733. * @param reusable If the post process can be reused on the same frame. (default: false)
  111734. * @param textureType Type of textures used when performing the post process. (default: 0)
  111735. * @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)
  111736. */
  111737. 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);
  111738. /**
  111739. * Updates the effect with the current post process compile time values and recompiles the shader.
  111740. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  111741. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  111742. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  111743. * @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
  111744. * @param onCompiled Called when the shader has been compiled.
  111745. * @param onError Called if there is an error when compiling a shader.
  111746. */
  111747. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  111748. }
  111749. }
  111750. declare module BABYLON {
  111751. /**
  111752. * Specifies the level of max blur that should be applied when using the depth of field effect
  111753. */
  111754. export enum DepthOfFieldEffectBlurLevel {
  111755. /**
  111756. * Subtle blur
  111757. */
  111758. Low = 0,
  111759. /**
  111760. * Medium blur
  111761. */
  111762. Medium = 1,
  111763. /**
  111764. * Large blur
  111765. */
  111766. High = 2
  111767. }
  111768. /**
  111769. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  111770. */
  111771. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  111772. private _circleOfConfusion;
  111773. /**
  111774. * @hidden Internal, blurs from high to low
  111775. */
  111776. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  111777. private _depthOfFieldBlurY;
  111778. private _dofMerge;
  111779. /**
  111780. * @hidden Internal post processes in depth of field effect
  111781. */
  111782. _effects: Array<PostProcess>;
  111783. /**
  111784. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  111785. */
  111786. focalLength: number;
  111787. /**
  111788. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111789. */
  111790. fStop: number;
  111791. /**
  111792. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111793. */
  111794. focusDistance: number;
  111795. /**
  111796. * 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.
  111797. */
  111798. lensSize: number;
  111799. /**
  111800. * Creates a new instance DepthOfFieldEffect
  111801. * @param scene The scene the effect belongs to.
  111802. * @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.
  111803. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111804. * @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)
  111805. */
  111806. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  111807. /**
  111808. * 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.
  111809. */
  111810. depthTexture: RenderTargetTexture;
  111811. /**
  111812. * Disposes each of the internal effects for a given camera.
  111813. * @param camera The camera to dispose the effect on.
  111814. */
  111815. disposeEffects(camera: Camera): void;
  111816. /**
  111817. * @hidden Internal
  111818. */
  111819. _updateEffects(): void;
  111820. /**
  111821. * Internal
  111822. * @returns if all the contained post processes are ready.
  111823. * @hidden
  111824. */
  111825. _isReady(): boolean;
  111826. }
  111827. }
  111828. declare module BABYLON {
  111829. /** @hidden */
  111830. export var displayPassPixelShader: {
  111831. name: string;
  111832. shader: string;
  111833. };
  111834. }
  111835. declare module BABYLON {
  111836. /**
  111837. * DisplayPassPostProcess which produces an output the same as it's input
  111838. */
  111839. export class DisplayPassPostProcess extends PostProcess {
  111840. /**
  111841. * Creates the DisplayPassPostProcess
  111842. * @param name The name of the effect.
  111843. * @param options The required width/height ratio to downsize to before computing the render pass.
  111844. * @param camera The camera to apply the render pass to.
  111845. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111846. * @param engine The engine which the post process will be applied. (default: current engine)
  111847. * @param reusable If the post process can be reused on the same frame. (default: false)
  111848. */
  111849. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111850. }
  111851. }
  111852. declare module BABYLON {
  111853. /** @hidden */
  111854. export var filterPixelShader: {
  111855. name: string;
  111856. shader: string;
  111857. };
  111858. }
  111859. declare module BABYLON {
  111860. /**
  111861. * Applies a kernel filter to the image
  111862. */
  111863. export class FilterPostProcess extends PostProcess {
  111864. /** The matrix to be applied to the image */
  111865. kernelMatrix: Matrix;
  111866. /**
  111867. *
  111868. * @param name The name of the effect.
  111869. * @param kernelMatrix The matrix to be applied to the image
  111870. * @param options The required width/height ratio to downsize to before computing the render pass.
  111871. * @param camera The camera to apply the render pass to.
  111872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111873. * @param engine The engine which the post process will be applied. (default: current engine)
  111874. * @param reusable If the post process can be reused on the same frame. (default: false)
  111875. */
  111876. constructor(name: string,
  111877. /** The matrix to be applied to the image */
  111878. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111879. }
  111880. }
  111881. declare module BABYLON {
  111882. /** @hidden */
  111883. export var fxaaPixelShader: {
  111884. name: string;
  111885. shader: string;
  111886. };
  111887. }
  111888. declare module BABYLON {
  111889. /** @hidden */
  111890. export var fxaaVertexShader: {
  111891. name: string;
  111892. shader: string;
  111893. };
  111894. }
  111895. declare module BABYLON {
  111896. /**
  111897. * Fxaa post process
  111898. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  111899. */
  111900. export class FxaaPostProcess extends PostProcess {
  111901. /** @hidden */
  111902. texelWidth: number;
  111903. /** @hidden */
  111904. texelHeight: number;
  111905. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111906. private _getDefines;
  111907. }
  111908. }
  111909. declare module BABYLON {
  111910. /** @hidden */
  111911. export var grainPixelShader: {
  111912. name: string;
  111913. shader: string;
  111914. };
  111915. }
  111916. declare module BABYLON {
  111917. /**
  111918. * The GrainPostProcess adds noise to the image at mid luminance levels
  111919. */
  111920. export class GrainPostProcess extends PostProcess {
  111921. /**
  111922. * The intensity of the grain added (default: 30)
  111923. */
  111924. intensity: number;
  111925. /**
  111926. * If the grain should be randomized on every frame
  111927. */
  111928. animated: boolean;
  111929. /**
  111930. * Creates a new instance of @see GrainPostProcess
  111931. * @param name The name of the effect.
  111932. * @param options The required width/height ratio to downsize to before computing the render pass.
  111933. * @param camera The camera to apply the render pass to.
  111934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111935. * @param engine The engine which the post process will be applied. (default: current engine)
  111936. * @param reusable If the post process can be reused on the same frame. (default: false)
  111937. * @param textureType Type of textures used when performing the post process. (default: 0)
  111938. * @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)
  111939. */
  111940. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111941. }
  111942. }
  111943. declare module BABYLON {
  111944. /** @hidden */
  111945. export var highlightsPixelShader: {
  111946. name: string;
  111947. shader: string;
  111948. };
  111949. }
  111950. declare module BABYLON {
  111951. /**
  111952. * Extracts highlights from the image
  111953. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111954. */
  111955. export class HighlightsPostProcess extends PostProcess {
  111956. /**
  111957. * Extracts highlights from the image
  111958. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111959. * @param name The name of the effect.
  111960. * @param options The required width/height ratio to downsize to before computing the render pass.
  111961. * @param camera The camera to apply the render pass to.
  111962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111963. * @param engine The engine which the post process will be applied. (default: current engine)
  111964. * @param reusable If the post process can be reused on the same frame. (default: false)
  111965. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  111966. */
  111967. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111968. }
  111969. }
  111970. declare module BABYLON {
  111971. /** @hidden */
  111972. export var mrtFragmentDeclaration: {
  111973. name: string;
  111974. shader: string;
  111975. };
  111976. }
  111977. declare module BABYLON {
  111978. /** @hidden */
  111979. export var geometryPixelShader: {
  111980. name: string;
  111981. shader: string;
  111982. };
  111983. }
  111984. declare module BABYLON {
  111985. /** @hidden */
  111986. export var geometryVertexShader: {
  111987. name: string;
  111988. shader: string;
  111989. };
  111990. }
  111991. declare module BABYLON {
  111992. /**
  111993. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  111994. */
  111995. export class GeometryBufferRenderer {
  111996. /**
  111997. * Constant used to retrieve the position texture index in the G-Buffer textures array
  111998. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  111999. */
  112000. static readonly POSITION_TEXTURE_TYPE: number;
  112001. /**
  112002. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112003. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112004. */
  112005. static readonly VELOCITY_TEXTURE_TYPE: number;
  112006. /**
  112007. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112008. * in order to compute objects velocities when enableVelocity is set to "true"
  112009. * @hidden
  112010. */
  112011. _previousTransformationMatrices: {
  112012. [index: number]: Matrix;
  112013. };
  112014. private _scene;
  112015. private _multiRenderTarget;
  112016. private _ratio;
  112017. private _enablePosition;
  112018. private _enableVelocity;
  112019. private _positionIndex;
  112020. private _velocityIndex;
  112021. protected _effect: Effect;
  112022. protected _cachedDefines: string;
  112023. /**
  112024. * Set the render list (meshes to be rendered) used in the G buffer.
  112025. */
  112026. renderList: Mesh[];
  112027. /**
  112028. * Gets wether or not G buffer are supported by the running hardware.
  112029. * This requires draw buffer supports
  112030. */
  112031. readonly isSupported: boolean;
  112032. /**
  112033. * Returns the index of the given texture type in the G-Buffer textures array
  112034. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112035. * @returns the index of the given texture type in the G-Buffer textures array
  112036. */
  112037. getTextureIndex(textureType: number): number;
  112038. /**
  112039. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112040. */
  112041. /**
  112042. * Sets whether or not objects positions are enabled for the G buffer.
  112043. */
  112044. enablePosition: boolean;
  112045. /**
  112046. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112047. */
  112048. /**
  112049. * Sets wether or not objects velocities are enabled for the G buffer.
  112050. */
  112051. enableVelocity: boolean;
  112052. /**
  112053. * Gets the scene associated with the buffer.
  112054. */
  112055. readonly scene: Scene;
  112056. /**
  112057. * Gets the ratio used by the buffer during its creation.
  112058. * How big is the buffer related to the main canvas.
  112059. */
  112060. readonly ratio: number;
  112061. /** @hidden */
  112062. static _SceneComponentInitialization: (scene: Scene) => void;
  112063. /**
  112064. * Creates a new G Buffer for the scene
  112065. * @param scene The scene the buffer belongs to
  112066. * @param ratio How big is the buffer related to the main canvas.
  112067. */
  112068. constructor(scene: Scene, ratio?: number);
  112069. /**
  112070. * Checks wether everything is ready to render a submesh to the G buffer.
  112071. * @param subMesh the submesh to check readiness for
  112072. * @param useInstances is the mesh drawn using instance or not
  112073. * @returns true if ready otherwise false
  112074. */
  112075. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112076. /**
  112077. * Gets the current underlying G Buffer.
  112078. * @returns the buffer
  112079. */
  112080. getGBuffer(): MultiRenderTarget;
  112081. /**
  112082. * Gets the number of samples used to render the buffer (anti aliasing).
  112083. */
  112084. /**
  112085. * Sets the number of samples used to render the buffer (anti aliasing).
  112086. */
  112087. samples: number;
  112088. /**
  112089. * Disposes the renderer and frees up associated resources.
  112090. */
  112091. dispose(): void;
  112092. protected _createRenderTargets(): void;
  112093. }
  112094. }
  112095. declare module BABYLON {
  112096. interface Scene {
  112097. /** @hidden (Backing field) */
  112098. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112099. /**
  112100. * Gets or Sets the current geometry buffer associated to the scene.
  112101. */
  112102. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112103. /**
  112104. * Enables a GeometryBufferRender and associates it with the scene
  112105. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  112106. * @returns the GeometryBufferRenderer
  112107. */
  112108. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  112109. /**
  112110. * Disables the GeometryBufferRender associated with the scene
  112111. */
  112112. disableGeometryBufferRenderer(): void;
  112113. }
  112114. /**
  112115. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  112116. * in several rendering techniques.
  112117. */
  112118. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  112119. /**
  112120. * The component name helpful to identify the component in the list of scene components.
  112121. */
  112122. readonly name: string;
  112123. /**
  112124. * The scene the component belongs to.
  112125. */
  112126. scene: Scene;
  112127. /**
  112128. * Creates a new instance of the component for the given scene
  112129. * @param scene Defines the scene to register the component in
  112130. */
  112131. constructor(scene: Scene);
  112132. /**
  112133. * Registers the component in a given scene
  112134. */
  112135. register(): void;
  112136. /**
  112137. * Rebuilds the elements related to this component in case of
  112138. * context lost for instance.
  112139. */
  112140. rebuild(): void;
  112141. /**
  112142. * Disposes the component and the associated ressources
  112143. */
  112144. dispose(): void;
  112145. private _gatherRenderTargets;
  112146. }
  112147. }
  112148. declare module BABYLON {
  112149. /** @hidden */
  112150. export var motionBlurPixelShader: {
  112151. name: string;
  112152. shader: string;
  112153. };
  112154. }
  112155. declare module BABYLON {
  112156. /**
  112157. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  112158. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  112159. * As an example, all you have to do is to create the post-process:
  112160. * var mb = new BABYLON.MotionBlurPostProcess(
  112161. * 'mb', // The name of the effect.
  112162. * scene, // The scene containing the objects to blur according to their velocity.
  112163. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  112164. * camera // The camera to apply the render pass to.
  112165. * );
  112166. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  112167. */
  112168. export class MotionBlurPostProcess extends PostProcess {
  112169. /**
  112170. * Defines how much the image is blurred by the movement. Default value is equal to 1
  112171. */
  112172. motionStrength: number;
  112173. /**
  112174. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  112175. */
  112176. /**
  112177. * Sets the number of iterations to be used for motion blur quality
  112178. */
  112179. motionBlurSamples: number;
  112180. private _motionBlurSamples;
  112181. private _geometryBufferRenderer;
  112182. /**
  112183. * Creates a new instance MotionBlurPostProcess
  112184. * @param name The name of the effect.
  112185. * @param scene The scene containing the objects to blur according to their velocity.
  112186. * @param options The required width/height ratio to downsize to before computing the render pass.
  112187. * @param camera The camera to apply the render pass to.
  112188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112189. * @param engine The engine which the post process will be applied. (default: current engine)
  112190. * @param reusable If the post process can be reused on the same frame. (default: false)
  112191. * @param textureType Type of textures used when performing the post process. (default: 0)
  112192. * @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)
  112193. */
  112194. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112195. /**
  112196. * Disposes the post process.
  112197. * @param camera The camera to dispose the post process on.
  112198. */
  112199. dispose(camera?: Camera): void;
  112200. }
  112201. }
  112202. declare module BABYLON {
  112203. /** @hidden */
  112204. export var refractionPixelShader: {
  112205. name: string;
  112206. shader: string;
  112207. };
  112208. }
  112209. declare module BABYLON {
  112210. /**
  112211. * Post process which applies a refractin texture
  112212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112213. */
  112214. export class RefractionPostProcess extends PostProcess {
  112215. /** the base color of the refraction (used to taint the rendering) */
  112216. color: Color3;
  112217. /** simulated refraction depth */
  112218. depth: number;
  112219. /** the coefficient of the base color (0 to remove base color tainting) */
  112220. colorLevel: number;
  112221. private _refTexture;
  112222. private _ownRefractionTexture;
  112223. /**
  112224. * Gets or sets the refraction texture
  112225. * Please note that you are responsible for disposing the texture if you set it manually
  112226. */
  112227. refractionTexture: Texture;
  112228. /**
  112229. * Initializes the RefractionPostProcess
  112230. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112231. * @param name The name of the effect.
  112232. * @param refractionTextureUrl Url of the refraction texture to use
  112233. * @param color the base color of the refraction (used to taint the rendering)
  112234. * @param depth simulated refraction depth
  112235. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  112236. * @param camera The camera to apply the render pass to.
  112237. * @param options The required width/height ratio to downsize to before computing the render pass.
  112238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112239. * @param engine The engine which the post process will be applied. (default: current engine)
  112240. * @param reusable If the post process can be reused on the same frame. (default: false)
  112241. */
  112242. constructor(name: string, refractionTextureUrl: string,
  112243. /** the base color of the refraction (used to taint the rendering) */
  112244. color: Color3,
  112245. /** simulated refraction depth */
  112246. depth: number,
  112247. /** the coefficient of the base color (0 to remove base color tainting) */
  112248. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112249. /**
  112250. * Disposes of the post process
  112251. * @param camera Camera to dispose post process on
  112252. */
  112253. dispose(camera: Camera): void;
  112254. }
  112255. }
  112256. declare module BABYLON {
  112257. /** @hidden */
  112258. export var sharpenPixelShader: {
  112259. name: string;
  112260. shader: string;
  112261. };
  112262. }
  112263. declare module BABYLON {
  112264. /**
  112265. * The SharpenPostProcess applies a sharpen kernel to every pixel
  112266. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112267. */
  112268. export class SharpenPostProcess extends PostProcess {
  112269. /**
  112270. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  112271. */
  112272. colorAmount: number;
  112273. /**
  112274. * How much sharpness should be applied (default: 0.3)
  112275. */
  112276. edgeAmount: number;
  112277. /**
  112278. * Creates a new instance ConvolutionPostProcess
  112279. * @param name The name of the effect.
  112280. * @param options The required width/height ratio to downsize to before computing the render pass.
  112281. * @param camera The camera to apply the render pass to.
  112282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112283. * @param engine The engine which the post process will be applied. (default: current engine)
  112284. * @param reusable If the post process can be reused on the same frame. (default: false)
  112285. * @param textureType Type of textures used when performing the post process. (default: 0)
  112286. * @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)
  112287. */
  112288. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112289. }
  112290. }
  112291. declare module BABYLON {
  112292. /**
  112293. * PostProcessRenderPipeline
  112294. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112295. */
  112296. export class PostProcessRenderPipeline {
  112297. private engine;
  112298. private _renderEffects;
  112299. private _renderEffectsForIsolatedPass;
  112300. /**
  112301. * List of inspectable custom properties (used by the Inspector)
  112302. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112303. */
  112304. inspectableCustomProperties: IInspectable[];
  112305. /**
  112306. * @hidden
  112307. */
  112308. protected _cameras: Camera[];
  112309. /** @hidden */
  112310. _name: string;
  112311. /**
  112312. * Gets pipeline name
  112313. */
  112314. readonly name: string;
  112315. /**
  112316. * Initializes a PostProcessRenderPipeline
  112317. * @param engine engine to add the pipeline to
  112318. * @param name name of the pipeline
  112319. */
  112320. constructor(engine: Engine, name: string);
  112321. /**
  112322. * Gets the class name
  112323. * @returns "PostProcessRenderPipeline"
  112324. */
  112325. getClassName(): string;
  112326. /**
  112327. * If all the render effects in the pipeline are supported
  112328. */
  112329. readonly isSupported: boolean;
  112330. /**
  112331. * Adds an effect to the pipeline
  112332. * @param renderEffect the effect to add
  112333. */
  112334. addEffect(renderEffect: PostProcessRenderEffect): void;
  112335. /** @hidden */
  112336. _rebuild(): void;
  112337. /** @hidden */
  112338. _enableEffect(renderEffectName: string, cameras: Camera): void;
  112339. /** @hidden */
  112340. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  112341. /** @hidden */
  112342. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112343. /** @hidden */
  112344. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112345. /** @hidden */
  112346. _attachCameras(cameras: Camera, unique: boolean): void;
  112347. /** @hidden */
  112348. _attachCameras(cameras: Camera[], unique: boolean): void;
  112349. /** @hidden */
  112350. _detachCameras(cameras: Camera): void;
  112351. /** @hidden */
  112352. _detachCameras(cameras: Nullable<Camera[]>): void;
  112353. /** @hidden */
  112354. _update(): void;
  112355. /** @hidden */
  112356. _reset(): void;
  112357. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  112358. /**
  112359. * Disposes of the pipeline
  112360. */
  112361. dispose(): void;
  112362. }
  112363. }
  112364. declare module BABYLON {
  112365. /**
  112366. * PostProcessRenderPipelineManager class
  112367. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112368. */
  112369. export class PostProcessRenderPipelineManager {
  112370. private _renderPipelines;
  112371. /**
  112372. * Initializes a PostProcessRenderPipelineManager
  112373. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112374. */
  112375. constructor();
  112376. /**
  112377. * Gets the list of supported render pipelines
  112378. */
  112379. readonly supportedPipelines: PostProcessRenderPipeline[];
  112380. /**
  112381. * Adds a pipeline to the manager
  112382. * @param renderPipeline The pipeline to add
  112383. */
  112384. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  112385. /**
  112386. * Attaches a camera to the pipeline
  112387. * @param renderPipelineName The name of the pipeline to attach to
  112388. * @param cameras the camera to attach
  112389. * @param unique if the camera can be attached multiple times to the pipeline
  112390. */
  112391. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  112392. /**
  112393. * Detaches a camera from the pipeline
  112394. * @param renderPipelineName The name of the pipeline to detach from
  112395. * @param cameras the camera to detach
  112396. */
  112397. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  112398. /**
  112399. * Enables an effect by name on a pipeline
  112400. * @param renderPipelineName the name of the pipeline to enable the effect in
  112401. * @param renderEffectName the name of the effect to enable
  112402. * @param cameras the cameras that the effect should be enabled on
  112403. */
  112404. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112405. /**
  112406. * Disables an effect by name on a pipeline
  112407. * @param renderPipelineName the name of the pipeline to disable the effect in
  112408. * @param renderEffectName the name of the effect to disable
  112409. * @param cameras the cameras that the effect should be disabled on
  112410. */
  112411. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112412. /**
  112413. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  112414. */
  112415. update(): void;
  112416. /** @hidden */
  112417. _rebuild(): void;
  112418. /**
  112419. * Disposes of the manager and pipelines
  112420. */
  112421. dispose(): void;
  112422. }
  112423. }
  112424. declare module BABYLON {
  112425. interface Scene {
  112426. /** @hidden (Backing field) */
  112427. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112428. /**
  112429. * Gets the postprocess render pipeline manager
  112430. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112431. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112432. */
  112433. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112434. }
  112435. /**
  112436. * Defines the Render Pipeline scene component responsible to rendering pipelines
  112437. */
  112438. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  112439. /**
  112440. * The component name helpfull to identify the component in the list of scene components.
  112441. */
  112442. readonly name: string;
  112443. /**
  112444. * The scene the component belongs to.
  112445. */
  112446. scene: Scene;
  112447. /**
  112448. * Creates a new instance of the component for the given scene
  112449. * @param scene Defines the scene to register the component in
  112450. */
  112451. constructor(scene: Scene);
  112452. /**
  112453. * Registers the component in a given scene
  112454. */
  112455. register(): void;
  112456. /**
  112457. * Rebuilds the elements related to this component in case of
  112458. * context lost for instance.
  112459. */
  112460. rebuild(): void;
  112461. /**
  112462. * Disposes the component and the associated ressources
  112463. */
  112464. dispose(): void;
  112465. private _gatherRenderTargets;
  112466. }
  112467. }
  112468. declare module BABYLON {
  112469. /**
  112470. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  112471. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112472. */
  112473. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  112474. private _scene;
  112475. private _camerasToBeAttached;
  112476. /**
  112477. * ID of the sharpen post process,
  112478. */
  112479. private readonly SharpenPostProcessId;
  112480. /**
  112481. * @ignore
  112482. * ID of the image processing post process;
  112483. */
  112484. readonly ImageProcessingPostProcessId: string;
  112485. /**
  112486. * @ignore
  112487. * ID of the Fast Approximate Anti-Aliasing post process;
  112488. */
  112489. readonly FxaaPostProcessId: string;
  112490. /**
  112491. * ID of the chromatic aberration post process,
  112492. */
  112493. private readonly ChromaticAberrationPostProcessId;
  112494. /**
  112495. * ID of the grain post process
  112496. */
  112497. private readonly GrainPostProcessId;
  112498. /**
  112499. * Sharpen post process which will apply a sharpen convolution to enhance edges
  112500. */
  112501. sharpen: SharpenPostProcess;
  112502. private _sharpenEffect;
  112503. private bloom;
  112504. /**
  112505. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  112506. */
  112507. depthOfField: DepthOfFieldEffect;
  112508. /**
  112509. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  112510. */
  112511. fxaa: FxaaPostProcess;
  112512. /**
  112513. * Image post processing pass used to perform operations such as tone mapping or color grading.
  112514. */
  112515. imageProcessing: ImageProcessingPostProcess;
  112516. /**
  112517. * Chromatic aberration post process which will shift rgb colors in the image
  112518. */
  112519. chromaticAberration: ChromaticAberrationPostProcess;
  112520. private _chromaticAberrationEffect;
  112521. /**
  112522. * Grain post process which add noise to the image
  112523. */
  112524. grain: GrainPostProcess;
  112525. private _grainEffect;
  112526. /**
  112527. * Glow post process which adds a glow to emissive areas of the image
  112528. */
  112529. private _glowLayer;
  112530. /**
  112531. * Animations which can be used to tweak settings over a period of time
  112532. */
  112533. animations: Animation[];
  112534. private _imageProcessingConfigurationObserver;
  112535. private _sharpenEnabled;
  112536. private _bloomEnabled;
  112537. private _depthOfFieldEnabled;
  112538. private _depthOfFieldBlurLevel;
  112539. private _fxaaEnabled;
  112540. private _imageProcessingEnabled;
  112541. private _defaultPipelineTextureType;
  112542. private _bloomScale;
  112543. private _chromaticAberrationEnabled;
  112544. private _grainEnabled;
  112545. private _buildAllowed;
  112546. /**
  112547. * Gets active scene
  112548. */
  112549. readonly scene: Scene;
  112550. /**
  112551. * Enable or disable the sharpen process from the pipeline
  112552. */
  112553. sharpenEnabled: boolean;
  112554. private _resizeObserver;
  112555. private _hardwareScaleLevel;
  112556. private _bloomKernel;
  112557. /**
  112558. * Specifies the size of the bloom blur kernel, relative to the final output size
  112559. */
  112560. bloomKernel: number;
  112561. /**
  112562. * Specifies the weight of the bloom in the final rendering
  112563. */
  112564. private _bloomWeight;
  112565. /**
  112566. * Specifies the luma threshold for the area that will be blurred by the bloom
  112567. */
  112568. private _bloomThreshold;
  112569. private _hdr;
  112570. /**
  112571. * The strength of the bloom.
  112572. */
  112573. bloomWeight: number;
  112574. /**
  112575. * The strength of the bloom.
  112576. */
  112577. bloomThreshold: number;
  112578. /**
  112579. * The scale of the bloom, lower value will provide better performance.
  112580. */
  112581. bloomScale: number;
  112582. /**
  112583. * Enable or disable the bloom from the pipeline
  112584. */
  112585. bloomEnabled: boolean;
  112586. private _rebuildBloom;
  112587. /**
  112588. * If the depth of field is enabled.
  112589. */
  112590. depthOfFieldEnabled: boolean;
  112591. /**
  112592. * Blur level of the depth of field effect. (Higher blur will effect performance)
  112593. */
  112594. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  112595. /**
  112596. * If the anti aliasing is enabled.
  112597. */
  112598. fxaaEnabled: boolean;
  112599. private _samples;
  112600. /**
  112601. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112602. */
  112603. samples: number;
  112604. /**
  112605. * If image processing is enabled.
  112606. */
  112607. imageProcessingEnabled: boolean;
  112608. /**
  112609. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  112610. */
  112611. glowLayerEnabled: boolean;
  112612. /**
  112613. * Enable or disable the chromaticAberration process from the pipeline
  112614. */
  112615. chromaticAberrationEnabled: boolean;
  112616. /**
  112617. * Enable or disable the grain process from the pipeline
  112618. */
  112619. grainEnabled: boolean;
  112620. /**
  112621. * @constructor
  112622. * @param name - The rendering pipeline name (default: "")
  112623. * @param hdr - If high dynamic range textures should be used (default: true)
  112624. * @param scene - The scene linked to this pipeline (default: the last created scene)
  112625. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  112626. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  112627. */
  112628. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  112629. /**
  112630. * Get the class name
  112631. * @returns "DefaultRenderingPipeline"
  112632. */
  112633. getClassName(): string;
  112634. /**
  112635. * Force the compilation of the entire pipeline.
  112636. */
  112637. prepare(): void;
  112638. private _hasCleared;
  112639. private _prevPostProcess;
  112640. private _prevPrevPostProcess;
  112641. private _setAutoClearAndTextureSharing;
  112642. private _depthOfFieldSceneObserver;
  112643. private _buildPipeline;
  112644. private _disposePostProcesses;
  112645. /**
  112646. * Adds a camera to the pipeline
  112647. * @param camera the camera to be added
  112648. */
  112649. addCamera(camera: Camera): void;
  112650. /**
  112651. * Removes a camera from the pipeline
  112652. * @param camera the camera to remove
  112653. */
  112654. removeCamera(camera: Camera): void;
  112655. /**
  112656. * Dispose of the pipeline and stop all post processes
  112657. */
  112658. dispose(): void;
  112659. /**
  112660. * Serialize the rendering pipeline (Used when exporting)
  112661. * @returns the serialized object
  112662. */
  112663. serialize(): any;
  112664. /**
  112665. * Parse the serialized pipeline
  112666. * @param source Source pipeline.
  112667. * @param scene The scene to load the pipeline to.
  112668. * @param rootUrl The URL of the serialized pipeline.
  112669. * @returns An instantiated pipeline from the serialized object.
  112670. */
  112671. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  112672. }
  112673. }
  112674. declare module BABYLON {
  112675. /** @hidden */
  112676. export var lensHighlightsPixelShader: {
  112677. name: string;
  112678. shader: string;
  112679. };
  112680. }
  112681. declare module BABYLON {
  112682. /** @hidden */
  112683. export var depthOfFieldPixelShader: {
  112684. name: string;
  112685. shader: string;
  112686. };
  112687. }
  112688. declare module BABYLON {
  112689. /**
  112690. * BABYLON.JS Chromatic Aberration GLSL Shader
  112691. * Author: Olivier Guyot
  112692. * Separates very slightly R, G and B colors on the edges of the screen
  112693. * Inspired by Francois Tarlier & Martins Upitis
  112694. */
  112695. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  112696. /**
  112697. * @ignore
  112698. * The chromatic aberration PostProcess id in the pipeline
  112699. */
  112700. LensChromaticAberrationEffect: string;
  112701. /**
  112702. * @ignore
  112703. * The highlights enhancing PostProcess id in the pipeline
  112704. */
  112705. HighlightsEnhancingEffect: string;
  112706. /**
  112707. * @ignore
  112708. * The depth-of-field PostProcess id in the pipeline
  112709. */
  112710. LensDepthOfFieldEffect: string;
  112711. private _scene;
  112712. private _depthTexture;
  112713. private _grainTexture;
  112714. private _chromaticAberrationPostProcess;
  112715. private _highlightsPostProcess;
  112716. private _depthOfFieldPostProcess;
  112717. private _edgeBlur;
  112718. private _grainAmount;
  112719. private _chromaticAberration;
  112720. private _distortion;
  112721. private _highlightsGain;
  112722. private _highlightsThreshold;
  112723. private _dofDistance;
  112724. private _dofAperture;
  112725. private _dofDarken;
  112726. private _dofPentagon;
  112727. private _blurNoise;
  112728. /**
  112729. * @constructor
  112730. *
  112731. * Effect parameters are as follow:
  112732. * {
  112733. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112734. * edge_blur: number; // from 0 to x (1 for realism)
  112735. * distortion: number; // from 0 to x (1 for realism)
  112736. * grain_amount: number; // from 0 to 1
  112737. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112738. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112739. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112740. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112741. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112742. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112743. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112744. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112745. * }
  112746. * Note: if an effect parameter is unset, effect is disabled
  112747. *
  112748. * @param name The rendering pipeline name
  112749. * @param parameters - An object containing all parameters (see above)
  112750. * @param scene The scene linked to this pipeline
  112751. * @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)
  112752. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112753. */
  112754. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  112755. /**
  112756. * Get the class name
  112757. * @returns "LensRenderingPipeline"
  112758. */
  112759. getClassName(): string;
  112760. /**
  112761. * Gets associated scene
  112762. */
  112763. readonly scene: Scene;
  112764. /**
  112765. * Gets or sets the edge blur
  112766. */
  112767. edgeBlur: number;
  112768. /**
  112769. * Gets or sets the grain amount
  112770. */
  112771. grainAmount: number;
  112772. /**
  112773. * Gets or sets the chromatic aberration amount
  112774. */
  112775. chromaticAberration: number;
  112776. /**
  112777. * Gets or sets the depth of field aperture
  112778. */
  112779. dofAperture: number;
  112780. /**
  112781. * Gets or sets the edge distortion
  112782. */
  112783. edgeDistortion: number;
  112784. /**
  112785. * Gets or sets the depth of field distortion
  112786. */
  112787. dofDistortion: number;
  112788. /**
  112789. * Gets or sets the darken out of focus amount
  112790. */
  112791. darkenOutOfFocus: number;
  112792. /**
  112793. * Gets or sets a boolean indicating if blur noise is enabled
  112794. */
  112795. blurNoise: boolean;
  112796. /**
  112797. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  112798. */
  112799. pentagonBokeh: boolean;
  112800. /**
  112801. * Gets or sets the highlight grain amount
  112802. */
  112803. highlightsGain: number;
  112804. /**
  112805. * Gets or sets the highlight threshold
  112806. */
  112807. highlightsThreshold: number;
  112808. /**
  112809. * Sets the amount of blur at the edges
  112810. * @param amount blur amount
  112811. */
  112812. setEdgeBlur(amount: number): void;
  112813. /**
  112814. * Sets edge blur to 0
  112815. */
  112816. disableEdgeBlur(): void;
  112817. /**
  112818. * Sets the amout of grain
  112819. * @param amount Amount of grain
  112820. */
  112821. setGrainAmount(amount: number): void;
  112822. /**
  112823. * Set grain amount to 0
  112824. */
  112825. disableGrain(): void;
  112826. /**
  112827. * Sets the chromatic aberration amount
  112828. * @param amount amount of chromatic aberration
  112829. */
  112830. setChromaticAberration(amount: number): void;
  112831. /**
  112832. * Sets chromatic aberration amount to 0
  112833. */
  112834. disableChromaticAberration(): void;
  112835. /**
  112836. * Sets the EdgeDistortion amount
  112837. * @param amount amount of EdgeDistortion
  112838. */
  112839. setEdgeDistortion(amount: number): void;
  112840. /**
  112841. * Sets edge distortion to 0
  112842. */
  112843. disableEdgeDistortion(): void;
  112844. /**
  112845. * Sets the FocusDistance amount
  112846. * @param amount amount of FocusDistance
  112847. */
  112848. setFocusDistance(amount: number): void;
  112849. /**
  112850. * Disables depth of field
  112851. */
  112852. disableDepthOfField(): void;
  112853. /**
  112854. * Sets the Aperture amount
  112855. * @param amount amount of Aperture
  112856. */
  112857. setAperture(amount: number): void;
  112858. /**
  112859. * Sets the DarkenOutOfFocus amount
  112860. * @param amount amount of DarkenOutOfFocus
  112861. */
  112862. setDarkenOutOfFocus(amount: number): void;
  112863. private _pentagonBokehIsEnabled;
  112864. /**
  112865. * Creates a pentagon bokeh effect
  112866. */
  112867. enablePentagonBokeh(): void;
  112868. /**
  112869. * Disables the pentagon bokeh effect
  112870. */
  112871. disablePentagonBokeh(): void;
  112872. /**
  112873. * Enables noise blur
  112874. */
  112875. enableNoiseBlur(): void;
  112876. /**
  112877. * Disables noise blur
  112878. */
  112879. disableNoiseBlur(): void;
  112880. /**
  112881. * Sets the HighlightsGain amount
  112882. * @param amount amount of HighlightsGain
  112883. */
  112884. setHighlightsGain(amount: number): void;
  112885. /**
  112886. * Sets the HighlightsThreshold amount
  112887. * @param amount amount of HighlightsThreshold
  112888. */
  112889. setHighlightsThreshold(amount: number): void;
  112890. /**
  112891. * Disables highlights
  112892. */
  112893. disableHighlights(): void;
  112894. /**
  112895. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112896. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112897. */
  112898. dispose(disableDepthRender?: boolean): void;
  112899. private _createChromaticAberrationPostProcess;
  112900. private _createHighlightsPostProcess;
  112901. private _createDepthOfFieldPostProcess;
  112902. private _createGrainTexture;
  112903. }
  112904. }
  112905. declare module BABYLON {
  112906. /** @hidden */
  112907. export var ssao2PixelShader: {
  112908. name: string;
  112909. shader: string;
  112910. };
  112911. }
  112912. declare module BABYLON {
  112913. /** @hidden */
  112914. export var ssaoCombinePixelShader: {
  112915. name: string;
  112916. shader: string;
  112917. };
  112918. }
  112919. declare module BABYLON {
  112920. /**
  112921. * Render pipeline to produce ssao effect
  112922. */
  112923. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  112924. /**
  112925. * @ignore
  112926. * The PassPostProcess id in the pipeline that contains the original scene color
  112927. */
  112928. SSAOOriginalSceneColorEffect: string;
  112929. /**
  112930. * @ignore
  112931. * The SSAO PostProcess id in the pipeline
  112932. */
  112933. SSAORenderEffect: string;
  112934. /**
  112935. * @ignore
  112936. * The horizontal blur PostProcess id in the pipeline
  112937. */
  112938. SSAOBlurHRenderEffect: string;
  112939. /**
  112940. * @ignore
  112941. * The vertical blur PostProcess id in the pipeline
  112942. */
  112943. SSAOBlurVRenderEffect: string;
  112944. /**
  112945. * @ignore
  112946. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112947. */
  112948. SSAOCombineRenderEffect: string;
  112949. /**
  112950. * The output strength of the SSAO post-process. Default value is 1.0.
  112951. */
  112952. totalStrength: number;
  112953. /**
  112954. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  112955. */
  112956. maxZ: number;
  112957. /**
  112958. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  112959. */
  112960. minZAspect: number;
  112961. private _samples;
  112962. /**
  112963. * Number of samples used for the SSAO calculations. Default value is 8
  112964. */
  112965. samples: number;
  112966. private _textureSamples;
  112967. /**
  112968. * Number of samples to use for antialiasing
  112969. */
  112970. textureSamples: number;
  112971. /**
  112972. * Ratio object used for SSAO ratio and blur ratio
  112973. */
  112974. private _ratio;
  112975. /**
  112976. * Dynamically generated sphere sampler.
  112977. */
  112978. private _sampleSphere;
  112979. /**
  112980. * Blur filter offsets
  112981. */
  112982. private _samplerOffsets;
  112983. private _expensiveBlur;
  112984. /**
  112985. * If bilateral blur should be used
  112986. */
  112987. expensiveBlur: boolean;
  112988. /**
  112989. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  112990. */
  112991. radius: number;
  112992. /**
  112993. * The base color of the SSAO post-process
  112994. * The final result is "base + ssao" between [0, 1]
  112995. */
  112996. base: number;
  112997. /**
  112998. * Support test.
  112999. */
  113000. static readonly IsSupported: boolean;
  113001. private _scene;
  113002. private _depthTexture;
  113003. private _normalTexture;
  113004. private _randomTexture;
  113005. private _originalColorPostProcess;
  113006. private _ssaoPostProcess;
  113007. private _blurHPostProcess;
  113008. private _blurVPostProcess;
  113009. private _ssaoCombinePostProcess;
  113010. private _firstUpdate;
  113011. /**
  113012. * Gets active scene
  113013. */
  113014. readonly scene: Scene;
  113015. /**
  113016. * @constructor
  113017. * @param name The rendering pipeline name
  113018. * @param scene The scene linked to this pipeline
  113019. * @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 }
  113020. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113021. */
  113022. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113023. /**
  113024. * Get the class name
  113025. * @returns "SSAO2RenderingPipeline"
  113026. */
  113027. getClassName(): string;
  113028. /**
  113029. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113030. */
  113031. dispose(disableGeometryBufferRenderer?: boolean): void;
  113032. private _createBlurPostProcess;
  113033. /** @hidden */
  113034. _rebuild(): void;
  113035. private _bits;
  113036. private _radicalInverse_VdC;
  113037. private _hammersley;
  113038. private _hemisphereSample_uniform;
  113039. private _generateHemisphere;
  113040. private _createSSAOPostProcess;
  113041. private _createSSAOCombinePostProcess;
  113042. private _createRandomTexture;
  113043. /**
  113044. * Serialize the rendering pipeline (Used when exporting)
  113045. * @returns the serialized object
  113046. */
  113047. serialize(): any;
  113048. /**
  113049. * Parse the serialized pipeline
  113050. * @param source Source pipeline.
  113051. * @param scene The scene to load the pipeline to.
  113052. * @param rootUrl The URL of the serialized pipeline.
  113053. * @returns An instantiated pipeline from the serialized object.
  113054. */
  113055. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  113056. }
  113057. }
  113058. declare module BABYLON {
  113059. /** @hidden */
  113060. export var ssaoPixelShader: {
  113061. name: string;
  113062. shader: string;
  113063. };
  113064. }
  113065. declare module BABYLON {
  113066. /**
  113067. * Render pipeline to produce ssao effect
  113068. */
  113069. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  113070. /**
  113071. * @ignore
  113072. * The PassPostProcess id in the pipeline that contains the original scene color
  113073. */
  113074. SSAOOriginalSceneColorEffect: string;
  113075. /**
  113076. * @ignore
  113077. * The SSAO PostProcess id in the pipeline
  113078. */
  113079. SSAORenderEffect: string;
  113080. /**
  113081. * @ignore
  113082. * The horizontal blur PostProcess id in the pipeline
  113083. */
  113084. SSAOBlurHRenderEffect: string;
  113085. /**
  113086. * @ignore
  113087. * The vertical blur PostProcess id in the pipeline
  113088. */
  113089. SSAOBlurVRenderEffect: string;
  113090. /**
  113091. * @ignore
  113092. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113093. */
  113094. SSAOCombineRenderEffect: string;
  113095. /**
  113096. * The output strength of the SSAO post-process. Default value is 1.0.
  113097. */
  113098. totalStrength: number;
  113099. /**
  113100. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  113101. */
  113102. radius: number;
  113103. /**
  113104. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  113105. * Must not be equal to fallOff and superior to fallOff.
  113106. * Default value is 0.0075
  113107. */
  113108. area: number;
  113109. /**
  113110. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  113111. * Must not be equal to area and inferior to area.
  113112. * Default value is 0.000001
  113113. */
  113114. fallOff: number;
  113115. /**
  113116. * The base color of the SSAO post-process
  113117. * The final result is "base + ssao" between [0, 1]
  113118. */
  113119. base: number;
  113120. private _scene;
  113121. private _depthTexture;
  113122. private _randomTexture;
  113123. private _originalColorPostProcess;
  113124. private _ssaoPostProcess;
  113125. private _blurHPostProcess;
  113126. private _blurVPostProcess;
  113127. private _ssaoCombinePostProcess;
  113128. private _firstUpdate;
  113129. /**
  113130. * Gets active scene
  113131. */
  113132. readonly scene: Scene;
  113133. /**
  113134. * @constructor
  113135. * @param name - The rendering pipeline name
  113136. * @param scene - The scene linked to this pipeline
  113137. * @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 }
  113138. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113139. */
  113140. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113141. /**
  113142. * Get the class name
  113143. * @returns "SSAORenderingPipeline"
  113144. */
  113145. getClassName(): string;
  113146. /**
  113147. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113148. */
  113149. dispose(disableDepthRender?: boolean): void;
  113150. private _createBlurPostProcess;
  113151. /** @hidden */
  113152. _rebuild(): void;
  113153. private _createSSAOPostProcess;
  113154. private _createSSAOCombinePostProcess;
  113155. private _createRandomTexture;
  113156. }
  113157. }
  113158. declare module BABYLON {
  113159. /** @hidden */
  113160. export var standardPixelShader: {
  113161. name: string;
  113162. shader: string;
  113163. };
  113164. }
  113165. declare module BABYLON {
  113166. /**
  113167. * Standard rendering pipeline
  113168. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113169. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113170. */
  113171. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113172. /**
  113173. * Public members
  113174. */
  113175. /**
  113176. * Post-process which contains the original scene color before the pipeline applies all the effects
  113177. */
  113178. originalPostProcess: Nullable<PostProcess>;
  113179. /**
  113180. * Post-process used to down scale an image x4
  113181. */
  113182. downSampleX4PostProcess: Nullable<PostProcess>;
  113183. /**
  113184. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113185. */
  113186. brightPassPostProcess: Nullable<PostProcess>;
  113187. /**
  113188. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113189. */
  113190. blurHPostProcesses: PostProcess[];
  113191. /**
  113192. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113193. */
  113194. blurVPostProcesses: PostProcess[];
  113195. /**
  113196. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113197. */
  113198. textureAdderPostProcess: Nullable<PostProcess>;
  113199. /**
  113200. * Post-process used to create volumetric lighting effect
  113201. */
  113202. volumetricLightPostProcess: Nullable<PostProcess>;
  113203. /**
  113204. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113205. */
  113206. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  113207. /**
  113208. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113209. */
  113210. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  113211. /**
  113212. * Post-process used to merge the volumetric light effect and the real scene color
  113213. */
  113214. volumetricLightMergePostProces: Nullable<PostProcess>;
  113215. /**
  113216. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113217. */
  113218. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  113219. /**
  113220. * Base post-process used to calculate the average luminance of the final image for HDR
  113221. */
  113222. luminancePostProcess: Nullable<PostProcess>;
  113223. /**
  113224. * Post-processes used to create down sample post-processes in order to get
  113225. * the average luminance of the final image for HDR
  113226. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113227. */
  113228. luminanceDownSamplePostProcesses: PostProcess[];
  113229. /**
  113230. * Post-process used to create a HDR effect (light adaptation)
  113231. */
  113232. hdrPostProcess: Nullable<PostProcess>;
  113233. /**
  113234. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113235. */
  113236. textureAdderFinalPostProcess: Nullable<PostProcess>;
  113237. /**
  113238. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113239. */
  113240. lensFlareFinalPostProcess: Nullable<PostProcess>;
  113241. /**
  113242. * Post-process used to merge the final HDR post-process and the real scene color
  113243. */
  113244. hdrFinalPostProcess: Nullable<PostProcess>;
  113245. /**
  113246. * Post-process used to create a lens flare effect
  113247. */
  113248. lensFlarePostProcess: Nullable<PostProcess>;
  113249. /**
  113250. * Post-process that merges the result of the lens flare post-process and the real scene color
  113251. */
  113252. lensFlareComposePostProcess: Nullable<PostProcess>;
  113253. /**
  113254. * Post-process used to create a motion blur effect
  113255. */
  113256. motionBlurPostProcess: Nullable<PostProcess>;
  113257. /**
  113258. * Post-process used to create a depth of field effect
  113259. */
  113260. depthOfFieldPostProcess: Nullable<PostProcess>;
  113261. /**
  113262. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113263. */
  113264. fxaaPostProcess: Nullable<FxaaPostProcess>;
  113265. /**
  113266. * Represents the brightness threshold in order to configure the illuminated surfaces
  113267. */
  113268. brightThreshold: number;
  113269. /**
  113270. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113271. */
  113272. blurWidth: number;
  113273. /**
  113274. * Sets if the blur for highlighted surfaces must be only horizontal
  113275. */
  113276. horizontalBlur: boolean;
  113277. /**
  113278. * Gets the overall exposure used by the pipeline
  113279. */
  113280. /**
  113281. * Sets the overall exposure used by the pipeline
  113282. */
  113283. exposure: number;
  113284. /**
  113285. * Texture used typically to simulate "dirty" on camera lens
  113286. */
  113287. lensTexture: Nullable<Texture>;
  113288. /**
  113289. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113290. */
  113291. volumetricLightCoefficient: number;
  113292. /**
  113293. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113294. */
  113295. volumetricLightPower: number;
  113296. /**
  113297. * Used the set the blur intensity to smooth the volumetric lights
  113298. */
  113299. volumetricLightBlurScale: number;
  113300. /**
  113301. * Light (spot or directional) used to generate the volumetric lights rays
  113302. * The source light must have a shadow generate so the pipeline can get its
  113303. * depth map
  113304. */
  113305. sourceLight: Nullable<SpotLight | DirectionalLight>;
  113306. /**
  113307. * For eye adaptation, represents the minimum luminance the eye can see
  113308. */
  113309. hdrMinimumLuminance: number;
  113310. /**
  113311. * For eye adaptation, represents the decrease luminance speed
  113312. */
  113313. hdrDecreaseRate: number;
  113314. /**
  113315. * For eye adaptation, represents the increase luminance speed
  113316. */
  113317. hdrIncreaseRate: number;
  113318. /**
  113319. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113320. */
  113321. /**
  113322. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113323. */
  113324. hdrAutoExposure: boolean;
  113325. /**
  113326. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113327. */
  113328. lensColorTexture: Nullable<Texture>;
  113329. /**
  113330. * The overall strengh for the lens flare effect
  113331. */
  113332. lensFlareStrength: number;
  113333. /**
  113334. * Dispersion coefficient for lens flare ghosts
  113335. */
  113336. lensFlareGhostDispersal: number;
  113337. /**
  113338. * Main lens flare halo width
  113339. */
  113340. lensFlareHaloWidth: number;
  113341. /**
  113342. * Based on the lens distortion effect, defines how much the lens flare result
  113343. * is distorted
  113344. */
  113345. lensFlareDistortionStrength: number;
  113346. /**
  113347. * Lens star texture must be used to simulate rays on the flares and is available
  113348. * in the documentation
  113349. */
  113350. lensStarTexture: Nullable<Texture>;
  113351. /**
  113352. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113353. * flare effect by taking account of the dirt texture
  113354. */
  113355. lensFlareDirtTexture: Nullable<Texture>;
  113356. /**
  113357. * Represents the focal length for the depth of field effect
  113358. */
  113359. depthOfFieldDistance: number;
  113360. /**
  113361. * Represents the blur intensity for the blurred part of the depth of field effect
  113362. */
  113363. depthOfFieldBlurWidth: number;
  113364. /**
  113365. * For motion blur, defines how much the image is blurred by the movement
  113366. */
  113367. motionStrength: number;
  113368. /**
  113369. * List of animations for the pipeline (IAnimatable implementation)
  113370. */
  113371. animations: Animation[];
  113372. /**
  113373. * Private members
  113374. */
  113375. private _scene;
  113376. private _currentDepthOfFieldSource;
  113377. private _basePostProcess;
  113378. private _fixedExposure;
  113379. private _currentExposure;
  113380. private _hdrAutoExposure;
  113381. private _hdrCurrentLuminance;
  113382. private _floatTextureType;
  113383. private _ratio;
  113384. private _bloomEnabled;
  113385. private _depthOfFieldEnabled;
  113386. private _vlsEnabled;
  113387. private _lensFlareEnabled;
  113388. private _hdrEnabled;
  113389. private _motionBlurEnabled;
  113390. private _fxaaEnabled;
  113391. private _motionBlurSamples;
  113392. private _volumetricLightStepsCount;
  113393. private _samples;
  113394. /**
  113395. * @ignore
  113396. * Specifies if the bloom pipeline is enabled
  113397. */
  113398. BloomEnabled: boolean;
  113399. /**
  113400. * @ignore
  113401. * Specifies if the depth of field pipeline is enabed
  113402. */
  113403. DepthOfFieldEnabled: boolean;
  113404. /**
  113405. * @ignore
  113406. * Specifies if the lens flare pipeline is enabed
  113407. */
  113408. LensFlareEnabled: boolean;
  113409. /**
  113410. * @ignore
  113411. * Specifies if the HDR pipeline is enabled
  113412. */
  113413. HDREnabled: boolean;
  113414. /**
  113415. * @ignore
  113416. * Specifies if the volumetric lights scattering effect is enabled
  113417. */
  113418. VLSEnabled: boolean;
  113419. /**
  113420. * @ignore
  113421. * Specifies if the motion blur effect is enabled
  113422. */
  113423. MotionBlurEnabled: boolean;
  113424. /**
  113425. * Specifies if anti-aliasing is enabled
  113426. */
  113427. fxaaEnabled: boolean;
  113428. /**
  113429. * Specifies the number of steps used to calculate the volumetric lights
  113430. * Typically in interval [50, 200]
  113431. */
  113432. volumetricLightStepsCount: number;
  113433. /**
  113434. * Specifies the number of samples used for the motion blur effect
  113435. * Typically in interval [16, 64]
  113436. */
  113437. motionBlurSamples: number;
  113438. /**
  113439. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113440. */
  113441. samples: number;
  113442. /**
  113443. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113444. * @constructor
  113445. * @param name The rendering pipeline name
  113446. * @param scene The scene linked to this pipeline
  113447. * @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)
  113448. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  113449. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113450. */
  113451. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  113452. private _buildPipeline;
  113453. private _createDownSampleX4PostProcess;
  113454. private _createBrightPassPostProcess;
  113455. private _createBlurPostProcesses;
  113456. private _createTextureAdderPostProcess;
  113457. private _createVolumetricLightPostProcess;
  113458. private _createLuminancePostProcesses;
  113459. private _createHdrPostProcess;
  113460. private _createLensFlarePostProcess;
  113461. private _createDepthOfFieldPostProcess;
  113462. private _createMotionBlurPostProcess;
  113463. private _getDepthTexture;
  113464. private _disposePostProcesses;
  113465. /**
  113466. * Dispose of the pipeline and stop all post processes
  113467. */
  113468. dispose(): void;
  113469. /**
  113470. * Serialize the rendering pipeline (Used when exporting)
  113471. * @returns the serialized object
  113472. */
  113473. serialize(): any;
  113474. /**
  113475. * Parse the serialized pipeline
  113476. * @param source Source pipeline.
  113477. * @param scene The scene to load the pipeline to.
  113478. * @param rootUrl The URL of the serialized pipeline.
  113479. * @returns An instantiated pipeline from the serialized object.
  113480. */
  113481. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  113482. /**
  113483. * Luminance steps
  113484. */
  113485. static LuminanceSteps: number;
  113486. }
  113487. }
  113488. declare module BABYLON {
  113489. /** @hidden */
  113490. export var tonemapPixelShader: {
  113491. name: string;
  113492. shader: string;
  113493. };
  113494. }
  113495. declare module BABYLON {
  113496. /** Defines operator used for tonemapping */
  113497. export enum TonemappingOperator {
  113498. /** Hable */
  113499. Hable = 0,
  113500. /** Reinhard */
  113501. Reinhard = 1,
  113502. /** HejiDawson */
  113503. HejiDawson = 2,
  113504. /** Photographic */
  113505. Photographic = 3
  113506. }
  113507. /**
  113508. * Defines a post process to apply tone mapping
  113509. */
  113510. export class TonemapPostProcess extends PostProcess {
  113511. private _operator;
  113512. /** Defines the required exposure adjustement */
  113513. exposureAdjustment: number;
  113514. /**
  113515. * Creates a new TonemapPostProcess
  113516. * @param name defines the name of the postprocess
  113517. * @param _operator defines the operator to use
  113518. * @param exposureAdjustment defines the required exposure adjustement
  113519. * @param camera defines the camera to use (can be null)
  113520. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  113521. * @param engine defines the hosting engine (can be ignore if camera is set)
  113522. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113523. */
  113524. constructor(name: string, _operator: TonemappingOperator,
  113525. /** Defines the required exposure adjustement */
  113526. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  113527. }
  113528. }
  113529. declare module BABYLON {
  113530. /** @hidden */
  113531. export var depthVertexShader: {
  113532. name: string;
  113533. shader: string;
  113534. };
  113535. }
  113536. declare module BABYLON {
  113537. /** @hidden */
  113538. export var volumetricLightScatteringPixelShader: {
  113539. name: string;
  113540. shader: string;
  113541. };
  113542. }
  113543. declare module BABYLON {
  113544. /** @hidden */
  113545. export var volumetricLightScatteringPassPixelShader: {
  113546. name: string;
  113547. shader: string;
  113548. };
  113549. }
  113550. declare module BABYLON {
  113551. /**
  113552. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  113553. */
  113554. export class VolumetricLightScatteringPostProcess extends PostProcess {
  113555. private _volumetricLightScatteringPass;
  113556. private _volumetricLightScatteringRTT;
  113557. private _viewPort;
  113558. private _screenCoordinates;
  113559. private _cachedDefines;
  113560. /**
  113561. * If not undefined, the mesh position is computed from the attached node position
  113562. */
  113563. attachedNode: {
  113564. position: Vector3;
  113565. };
  113566. /**
  113567. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  113568. */
  113569. customMeshPosition: Vector3;
  113570. /**
  113571. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  113572. */
  113573. useCustomMeshPosition: boolean;
  113574. /**
  113575. * If the post-process should inverse the light scattering direction
  113576. */
  113577. invert: boolean;
  113578. /**
  113579. * The internal mesh used by the post-process
  113580. */
  113581. mesh: Mesh;
  113582. /**
  113583. * @hidden
  113584. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  113585. */
  113586. useDiffuseColor: boolean;
  113587. /**
  113588. * Array containing the excluded meshes not rendered in the internal pass
  113589. */
  113590. excludedMeshes: AbstractMesh[];
  113591. /**
  113592. * Controls the overall intensity of the post-process
  113593. */
  113594. exposure: number;
  113595. /**
  113596. * Dissipates each sample's contribution in range [0, 1]
  113597. */
  113598. decay: number;
  113599. /**
  113600. * Controls the overall intensity of each sample
  113601. */
  113602. weight: number;
  113603. /**
  113604. * Controls the density of each sample
  113605. */
  113606. density: number;
  113607. /**
  113608. * @constructor
  113609. * @param name The post-process name
  113610. * @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)
  113611. * @param camera The camera that the post-process will be attached to
  113612. * @param mesh The mesh used to create the light scattering
  113613. * @param samples The post-process quality, default 100
  113614. * @param samplingModeThe post-process filtering mode
  113615. * @param engine The babylon engine
  113616. * @param reusable If the post-process is reusable
  113617. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  113618. */
  113619. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  113620. /**
  113621. * Returns the string "VolumetricLightScatteringPostProcess"
  113622. * @returns "VolumetricLightScatteringPostProcess"
  113623. */
  113624. getClassName(): string;
  113625. private _isReady;
  113626. /**
  113627. * Sets the new light position for light scattering effect
  113628. * @param position The new custom light position
  113629. */
  113630. setCustomMeshPosition(position: Vector3): void;
  113631. /**
  113632. * Returns the light position for light scattering effect
  113633. * @return Vector3 The custom light position
  113634. */
  113635. getCustomMeshPosition(): Vector3;
  113636. /**
  113637. * Disposes the internal assets and detaches the post-process from the camera
  113638. */
  113639. dispose(camera: Camera): void;
  113640. /**
  113641. * Returns the render target texture used by the post-process
  113642. * @return the render target texture used by the post-process
  113643. */
  113644. getPass(): RenderTargetTexture;
  113645. private _meshExcluded;
  113646. private _createPass;
  113647. private _updateMeshScreenCoordinates;
  113648. /**
  113649. * Creates a default mesh for the Volumeric Light Scattering post-process
  113650. * @param name The mesh name
  113651. * @param scene The scene where to create the mesh
  113652. * @return the default mesh
  113653. */
  113654. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  113655. }
  113656. }
  113657. declare module BABYLON {
  113658. interface Scene {
  113659. /** @hidden (Backing field) */
  113660. _boundingBoxRenderer: BoundingBoxRenderer;
  113661. /** @hidden (Backing field) */
  113662. _forceShowBoundingBoxes: boolean;
  113663. /**
  113664. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  113665. */
  113666. forceShowBoundingBoxes: boolean;
  113667. /**
  113668. * Gets the bounding box renderer associated with the scene
  113669. * @returns a BoundingBoxRenderer
  113670. */
  113671. getBoundingBoxRenderer(): BoundingBoxRenderer;
  113672. }
  113673. interface AbstractMesh {
  113674. /** @hidden (Backing field) */
  113675. _showBoundingBox: boolean;
  113676. /**
  113677. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  113678. */
  113679. showBoundingBox: boolean;
  113680. }
  113681. /**
  113682. * Component responsible of rendering the bounding box of the meshes in a scene.
  113683. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  113684. */
  113685. export class BoundingBoxRenderer implements ISceneComponent {
  113686. /**
  113687. * The component name helpfull to identify the component in the list of scene components.
  113688. */
  113689. readonly name: string;
  113690. /**
  113691. * The scene the component belongs to.
  113692. */
  113693. scene: Scene;
  113694. /**
  113695. * Color of the bounding box lines placed in front of an object
  113696. */
  113697. frontColor: Color3;
  113698. /**
  113699. * Color of the bounding box lines placed behind an object
  113700. */
  113701. backColor: Color3;
  113702. /**
  113703. * Defines if the renderer should show the back lines or not
  113704. */
  113705. showBackLines: boolean;
  113706. /**
  113707. * @hidden
  113708. */
  113709. renderList: SmartArray<BoundingBox>;
  113710. private _colorShader;
  113711. private _vertexBuffers;
  113712. private _indexBuffer;
  113713. /**
  113714. * Instantiates a new bounding box renderer in a scene.
  113715. * @param scene the scene the renderer renders in
  113716. */
  113717. constructor(scene: Scene);
  113718. /**
  113719. * Registers the component in a given scene
  113720. */
  113721. register(): void;
  113722. private _evaluateSubMesh;
  113723. private _activeMesh;
  113724. private _prepareRessources;
  113725. private _createIndexBuffer;
  113726. /**
  113727. * Rebuilds the elements related to this component in case of
  113728. * context lost for instance.
  113729. */
  113730. rebuild(): void;
  113731. /**
  113732. * @hidden
  113733. */
  113734. reset(): void;
  113735. /**
  113736. * Render the bounding boxes of a specific rendering group
  113737. * @param renderingGroupId defines the rendering group to render
  113738. */
  113739. render(renderingGroupId: number): void;
  113740. /**
  113741. * In case of occlusion queries, we can render the occlusion bounding box through this method
  113742. * @param mesh Define the mesh to render the occlusion bounding box for
  113743. */
  113744. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  113745. /**
  113746. * Dispose and release the resources attached to this renderer.
  113747. */
  113748. dispose(): void;
  113749. }
  113750. }
  113751. declare module BABYLON {
  113752. /** @hidden */
  113753. export var depthPixelShader: {
  113754. name: string;
  113755. shader: string;
  113756. };
  113757. }
  113758. declare module BABYLON {
  113759. /**
  113760. * This represents a depth renderer in Babylon.
  113761. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  113762. */
  113763. export class DepthRenderer {
  113764. private _scene;
  113765. private _depthMap;
  113766. private _effect;
  113767. private _cachedDefines;
  113768. private _camera;
  113769. /**
  113770. * Specifiess that the depth renderer will only be used within
  113771. * the camera it is created for.
  113772. * This can help forcing its rendering during the camera processing.
  113773. */
  113774. useOnlyInActiveCamera: boolean;
  113775. /** @hidden */
  113776. static _SceneComponentInitialization: (scene: Scene) => void;
  113777. /**
  113778. * Instantiates a depth renderer
  113779. * @param scene The scene the renderer belongs to
  113780. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  113781. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  113782. */
  113783. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  113784. /**
  113785. * Creates the depth rendering effect and checks if the effect is ready.
  113786. * @param subMesh The submesh to be used to render the depth map of
  113787. * @param useInstances If multiple world instances should be used
  113788. * @returns if the depth renderer is ready to render the depth map
  113789. */
  113790. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113791. /**
  113792. * Gets the texture which the depth map will be written to.
  113793. * @returns The depth map texture
  113794. */
  113795. getDepthMap(): RenderTargetTexture;
  113796. /**
  113797. * Disposes of the depth renderer.
  113798. */
  113799. dispose(): void;
  113800. }
  113801. }
  113802. declare module BABYLON {
  113803. interface Scene {
  113804. /** @hidden (Backing field) */
  113805. _depthRenderer: {
  113806. [id: string]: DepthRenderer;
  113807. };
  113808. /**
  113809. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  113810. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  113811. * @returns the created depth renderer
  113812. */
  113813. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  113814. /**
  113815. * Disables a depth renderer for a given camera
  113816. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  113817. */
  113818. disableDepthRenderer(camera?: Nullable<Camera>): void;
  113819. }
  113820. /**
  113821. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  113822. * in several rendering techniques.
  113823. */
  113824. export class DepthRendererSceneComponent implements ISceneComponent {
  113825. /**
  113826. * The component name helpfull to identify the component in the list of scene components.
  113827. */
  113828. readonly name: string;
  113829. /**
  113830. * The scene the component belongs to.
  113831. */
  113832. scene: Scene;
  113833. /**
  113834. * Creates a new instance of the component for the given scene
  113835. * @param scene Defines the scene to register the component in
  113836. */
  113837. constructor(scene: Scene);
  113838. /**
  113839. * Registers the component in a given scene
  113840. */
  113841. register(): void;
  113842. /**
  113843. * Rebuilds the elements related to this component in case of
  113844. * context lost for instance.
  113845. */
  113846. rebuild(): void;
  113847. /**
  113848. * Disposes the component and the associated ressources
  113849. */
  113850. dispose(): void;
  113851. private _gatherRenderTargets;
  113852. private _gatherActiveCameraRenderTargets;
  113853. }
  113854. }
  113855. declare module BABYLON {
  113856. /** @hidden */
  113857. export var outlinePixelShader: {
  113858. name: string;
  113859. shader: string;
  113860. };
  113861. }
  113862. declare module BABYLON {
  113863. /** @hidden */
  113864. export var outlineVertexShader: {
  113865. name: string;
  113866. shader: string;
  113867. };
  113868. }
  113869. declare module BABYLON {
  113870. interface Scene {
  113871. /** @hidden */
  113872. _outlineRenderer: OutlineRenderer;
  113873. /**
  113874. * Gets the outline renderer associated with the scene
  113875. * @returns a OutlineRenderer
  113876. */
  113877. getOutlineRenderer(): OutlineRenderer;
  113878. }
  113879. interface AbstractMesh {
  113880. /** @hidden (Backing field) */
  113881. _renderOutline: boolean;
  113882. /**
  113883. * Gets or sets a boolean indicating if the outline must be rendered as well
  113884. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  113885. */
  113886. renderOutline: boolean;
  113887. /** @hidden (Backing field) */
  113888. _renderOverlay: boolean;
  113889. /**
  113890. * Gets or sets a boolean indicating if the overlay must be rendered as well
  113891. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  113892. */
  113893. renderOverlay: boolean;
  113894. }
  113895. /**
  113896. * This class is responsible to draw bothe outline/overlay of meshes.
  113897. * It should not be used directly but through the available method on mesh.
  113898. */
  113899. export class OutlineRenderer implements ISceneComponent {
  113900. /**
  113901. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  113902. */
  113903. private static _StencilReference;
  113904. /**
  113905. * The name of the component. Each component must have a unique name.
  113906. */
  113907. name: string;
  113908. /**
  113909. * The scene the component belongs to.
  113910. */
  113911. scene: Scene;
  113912. /**
  113913. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  113914. */
  113915. zOffset: number;
  113916. private _engine;
  113917. private _effect;
  113918. private _cachedDefines;
  113919. private _savedDepthWrite;
  113920. /**
  113921. * Instantiates a new outline renderer. (There could be only one per scene).
  113922. * @param scene Defines the scene it belongs to
  113923. */
  113924. constructor(scene: Scene);
  113925. /**
  113926. * Register the component to one instance of a scene.
  113927. */
  113928. register(): void;
  113929. /**
  113930. * Rebuilds the elements related to this component in case of
  113931. * context lost for instance.
  113932. */
  113933. rebuild(): void;
  113934. /**
  113935. * Disposes the component and the associated ressources.
  113936. */
  113937. dispose(): void;
  113938. /**
  113939. * Renders the outline in the canvas.
  113940. * @param subMesh Defines the sumesh to render
  113941. * @param batch Defines the batch of meshes in case of instances
  113942. * @param useOverlay Defines if the rendering is for the overlay or the outline
  113943. */
  113944. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  113945. /**
  113946. * Returns whether or not the outline renderer is ready for a given submesh.
  113947. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  113948. * @param subMesh Defines the submesh to check readyness for
  113949. * @param useInstances Defines wheter wee are trying to render instances or not
  113950. * @returns true if ready otherwise false
  113951. */
  113952. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113953. private _beforeRenderingMesh;
  113954. private _afterRenderingMesh;
  113955. }
  113956. }
  113957. declare module BABYLON {
  113958. /**
  113959. * Defines the list of states available for a task inside a AssetsManager
  113960. */
  113961. export enum AssetTaskState {
  113962. /**
  113963. * Initialization
  113964. */
  113965. INIT = 0,
  113966. /**
  113967. * Running
  113968. */
  113969. RUNNING = 1,
  113970. /**
  113971. * Done
  113972. */
  113973. DONE = 2,
  113974. /**
  113975. * Error
  113976. */
  113977. ERROR = 3
  113978. }
  113979. /**
  113980. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  113981. */
  113982. export abstract class AbstractAssetTask {
  113983. /**
  113984. * Task name
  113985. */ name: string;
  113986. /**
  113987. * Callback called when the task is successful
  113988. */
  113989. onSuccess: (task: any) => void;
  113990. /**
  113991. * Callback called when the task is not successful
  113992. */
  113993. onError: (task: any, message?: string, exception?: any) => void;
  113994. /**
  113995. * Creates a new AssetsManager
  113996. * @param name defines the name of the task
  113997. */
  113998. constructor(
  113999. /**
  114000. * Task name
  114001. */ name: string);
  114002. private _isCompleted;
  114003. private _taskState;
  114004. private _errorObject;
  114005. /**
  114006. * Get if the task is completed
  114007. */
  114008. readonly isCompleted: boolean;
  114009. /**
  114010. * Gets the current state of the task
  114011. */
  114012. readonly taskState: AssetTaskState;
  114013. /**
  114014. * Gets the current error object (if task is in error)
  114015. */
  114016. readonly errorObject: {
  114017. message?: string;
  114018. exception?: any;
  114019. };
  114020. /**
  114021. * Internal only
  114022. * @hidden
  114023. */
  114024. _setErrorObject(message?: string, exception?: any): void;
  114025. /**
  114026. * Execute the current task
  114027. * @param scene defines the scene where you want your assets to be loaded
  114028. * @param onSuccess is a callback called when the task is successfully executed
  114029. * @param onError is a callback called if an error occurs
  114030. */
  114031. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114032. /**
  114033. * Execute the current task
  114034. * @param scene defines the scene where you want your assets to be loaded
  114035. * @param onSuccess is a callback called when the task is successfully executed
  114036. * @param onError is a callback called if an error occurs
  114037. */
  114038. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114039. /**
  114040. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114041. * This can be used with failed tasks that have the reason for failure fixed.
  114042. */
  114043. reset(): void;
  114044. private onErrorCallback;
  114045. private onDoneCallback;
  114046. }
  114047. /**
  114048. * Define the interface used by progress events raised during assets loading
  114049. */
  114050. export interface IAssetsProgressEvent {
  114051. /**
  114052. * Defines the number of remaining tasks to process
  114053. */
  114054. remainingCount: number;
  114055. /**
  114056. * Defines the total number of tasks
  114057. */
  114058. totalCount: number;
  114059. /**
  114060. * Defines the task that was just processed
  114061. */
  114062. task: AbstractAssetTask;
  114063. }
  114064. /**
  114065. * Class used to share progress information about assets loading
  114066. */
  114067. export class AssetsProgressEvent implements IAssetsProgressEvent {
  114068. /**
  114069. * Defines the number of remaining tasks to process
  114070. */
  114071. remainingCount: number;
  114072. /**
  114073. * Defines the total number of tasks
  114074. */
  114075. totalCount: number;
  114076. /**
  114077. * Defines the task that was just processed
  114078. */
  114079. task: AbstractAssetTask;
  114080. /**
  114081. * Creates a AssetsProgressEvent
  114082. * @param remainingCount defines the number of remaining tasks to process
  114083. * @param totalCount defines the total number of tasks
  114084. * @param task defines the task that was just processed
  114085. */
  114086. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  114087. }
  114088. /**
  114089. * Define a task used by AssetsManager to load meshes
  114090. */
  114091. export class MeshAssetTask extends AbstractAssetTask {
  114092. /**
  114093. * Defines the name of the task
  114094. */
  114095. name: string;
  114096. /**
  114097. * Defines the list of mesh's names you want to load
  114098. */
  114099. meshesNames: any;
  114100. /**
  114101. * Defines the root url to use as a base to load your meshes and associated resources
  114102. */
  114103. rootUrl: string;
  114104. /**
  114105. * Defines the filename of the scene to load from
  114106. */
  114107. sceneFilename: string;
  114108. /**
  114109. * Gets the list of loaded meshes
  114110. */
  114111. loadedMeshes: Array<AbstractMesh>;
  114112. /**
  114113. * Gets the list of loaded particle systems
  114114. */
  114115. loadedParticleSystems: Array<IParticleSystem>;
  114116. /**
  114117. * Gets the list of loaded skeletons
  114118. */
  114119. loadedSkeletons: Array<Skeleton>;
  114120. /**
  114121. * Gets the list of loaded animation groups
  114122. */
  114123. loadedAnimationGroups: Array<AnimationGroup>;
  114124. /**
  114125. * Callback called when the task is successful
  114126. */
  114127. onSuccess: (task: MeshAssetTask) => void;
  114128. /**
  114129. * Callback called when the task is successful
  114130. */
  114131. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  114132. /**
  114133. * Creates a new MeshAssetTask
  114134. * @param name defines the name of the task
  114135. * @param meshesNames defines the list of mesh's names you want to load
  114136. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  114137. * @param sceneFilename defines the filename of the scene to load from
  114138. */
  114139. constructor(
  114140. /**
  114141. * Defines the name of the task
  114142. */
  114143. name: string,
  114144. /**
  114145. * Defines the list of mesh's names you want to load
  114146. */
  114147. meshesNames: any,
  114148. /**
  114149. * Defines the root url to use as a base to load your meshes and associated resources
  114150. */
  114151. rootUrl: string,
  114152. /**
  114153. * Defines the filename of the scene to load from
  114154. */
  114155. sceneFilename: string);
  114156. /**
  114157. * Execute the current task
  114158. * @param scene defines the scene where you want your assets to be loaded
  114159. * @param onSuccess is a callback called when the task is successfully executed
  114160. * @param onError is a callback called if an error occurs
  114161. */
  114162. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114163. }
  114164. /**
  114165. * Define a task used by AssetsManager to load text content
  114166. */
  114167. export class TextFileAssetTask extends AbstractAssetTask {
  114168. /**
  114169. * Defines the name of the task
  114170. */
  114171. name: string;
  114172. /**
  114173. * Defines the location of the file to load
  114174. */
  114175. url: string;
  114176. /**
  114177. * Gets the loaded text string
  114178. */
  114179. text: string;
  114180. /**
  114181. * Callback called when the task is successful
  114182. */
  114183. onSuccess: (task: TextFileAssetTask) => void;
  114184. /**
  114185. * Callback called when the task is successful
  114186. */
  114187. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  114188. /**
  114189. * Creates a new TextFileAssetTask object
  114190. * @param name defines the name of the task
  114191. * @param url defines the location of the file to load
  114192. */
  114193. constructor(
  114194. /**
  114195. * Defines the name of the task
  114196. */
  114197. name: string,
  114198. /**
  114199. * Defines the location of the file to load
  114200. */
  114201. url: string);
  114202. /**
  114203. * Execute the current task
  114204. * @param scene defines the scene where you want your assets to be loaded
  114205. * @param onSuccess is a callback called when the task is successfully executed
  114206. * @param onError is a callback called if an error occurs
  114207. */
  114208. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114209. }
  114210. /**
  114211. * Define a task used by AssetsManager to load binary data
  114212. */
  114213. export class BinaryFileAssetTask extends AbstractAssetTask {
  114214. /**
  114215. * Defines the name of the task
  114216. */
  114217. name: string;
  114218. /**
  114219. * Defines the location of the file to load
  114220. */
  114221. url: string;
  114222. /**
  114223. * Gets the lodaded data (as an array buffer)
  114224. */
  114225. data: ArrayBuffer;
  114226. /**
  114227. * Callback called when the task is successful
  114228. */
  114229. onSuccess: (task: BinaryFileAssetTask) => void;
  114230. /**
  114231. * Callback called when the task is successful
  114232. */
  114233. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  114234. /**
  114235. * Creates a new BinaryFileAssetTask object
  114236. * @param name defines the name of the new task
  114237. * @param url defines the location of the file to load
  114238. */
  114239. constructor(
  114240. /**
  114241. * Defines the name of the task
  114242. */
  114243. name: string,
  114244. /**
  114245. * Defines the location of the file to load
  114246. */
  114247. url: string);
  114248. /**
  114249. * Execute the current task
  114250. * @param scene defines the scene where you want your assets to be loaded
  114251. * @param onSuccess is a callback called when the task is successfully executed
  114252. * @param onError is a callback called if an error occurs
  114253. */
  114254. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114255. }
  114256. /**
  114257. * Define a task used by AssetsManager to load images
  114258. */
  114259. export class ImageAssetTask extends AbstractAssetTask {
  114260. /**
  114261. * Defines the name of the task
  114262. */
  114263. name: string;
  114264. /**
  114265. * Defines the location of the image to load
  114266. */
  114267. url: string;
  114268. /**
  114269. * Gets the loaded images
  114270. */
  114271. image: HTMLImageElement;
  114272. /**
  114273. * Callback called when the task is successful
  114274. */
  114275. onSuccess: (task: ImageAssetTask) => void;
  114276. /**
  114277. * Callback called when the task is successful
  114278. */
  114279. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  114280. /**
  114281. * Creates a new ImageAssetTask
  114282. * @param name defines the name of the task
  114283. * @param url defines the location of the image to load
  114284. */
  114285. constructor(
  114286. /**
  114287. * Defines the name of the task
  114288. */
  114289. name: string,
  114290. /**
  114291. * Defines the location of the image to load
  114292. */
  114293. url: string);
  114294. /**
  114295. * Execute the current task
  114296. * @param scene defines the scene where you want your assets to be loaded
  114297. * @param onSuccess is a callback called when the task is successfully executed
  114298. * @param onError is a callback called if an error occurs
  114299. */
  114300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114301. }
  114302. /**
  114303. * Defines the interface used by texture loading tasks
  114304. */
  114305. export interface ITextureAssetTask<TEX extends BaseTexture> {
  114306. /**
  114307. * Gets the loaded texture
  114308. */
  114309. texture: TEX;
  114310. }
  114311. /**
  114312. * Define a task used by AssetsManager to load 2D textures
  114313. */
  114314. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  114315. /**
  114316. * Defines the name of the task
  114317. */
  114318. name: string;
  114319. /**
  114320. * Defines the location of the file to load
  114321. */
  114322. url: string;
  114323. /**
  114324. * Defines if mipmap should not be generated (default is false)
  114325. */
  114326. noMipmap?: boolean | undefined;
  114327. /**
  114328. * Defines if texture must be inverted on Y axis (default is false)
  114329. */
  114330. invertY?: boolean | undefined;
  114331. /**
  114332. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114333. */
  114334. samplingMode: number;
  114335. /**
  114336. * Gets the loaded texture
  114337. */
  114338. texture: Texture;
  114339. /**
  114340. * Callback called when the task is successful
  114341. */
  114342. onSuccess: (task: TextureAssetTask) => void;
  114343. /**
  114344. * Callback called when the task is successful
  114345. */
  114346. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  114347. /**
  114348. * Creates a new TextureAssetTask object
  114349. * @param name defines the name of the task
  114350. * @param url defines the location of the file to load
  114351. * @param noMipmap defines if mipmap should not be generated (default is false)
  114352. * @param invertY defines if texture must be inverted on Y axis (default is false)
  114353. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114354. */
  114355. constructor(
  114356. /**
  114357. * Defines the name of the task
  114358. */
  114359. name: string,
  114360. /**
  114361. * Defines the location of the file to load
  114362. */
  114363. url: string,
  114364. /**
  114365. * Defines if mipmap should not be generated (default is false)
  114366. */
  114367. noMipmap?: boolean | undefined,
  114368. /**
  114369. * Defines if texture must be inverted on Y axis (default is false)
  114370. */
  114371. invertY?: boolean | undefined,
  114372. /**
  114373. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114374. */
  114375. samplingMode?: number);
  114376. /**
  114377. * Execute the current task
  114378. * @param scene defines the scene where you want your assets to be loaded
  114379. * @param onSuccess is a callback called when the task is successfully executed
  114380. * @param onError is a callback called if an error occurs
  114381. */
  114382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114383. }
  114384. /**
  114385. * Define a task used by AssetsManager to load cube textures
  114386. */
  114387. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  114388. /**
  114389. * Defines the name of the task
  114390. */
  114391. name: string;
  114392. /**
  114393. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114394. */
  114395. url: string;
  114396. /**
  114397. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114398. */
  114399. extensions?: string[] | undefined;
  114400. /**
  114401. * Defines if mipmaps should not be generated (default is false)
  114402. */
  114403. noMipmap?: boolean | undefined;
  114404. /**
  114405. * Defines the explicit list of files (undefined by default)
  114406. */
  114407. files?: string[] | undefined;
  114408. /**
  114409. * Gets the loaded texture
  114410. */
  114411. texture: CubeTexture;
  114412. /**
  114413. * Callback called when the task is successful
  114414. */
  114415. onSuccess: (task: CubeTextureAssetTask) => void;
  114416. /**
  114417. * Callback called when the task is successful
  114418. */
  114419. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  114420. /**
  114421. * Creates a new CubeTextureAssetTask
  114422. * @param name defines the name of the task
  114423. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114424. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114425. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114426. * @param files defines the explicit list of files (undefined by default)
  114427. */
  114428. constructor(
  114429. /**
  114430. * Defines the name of the task
  114431. */
  114432. name: string,
  114433. /**
  114434. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114435. */
  114436. url: string,
  114437. /**
  114438. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114439. */
  114440. extensions?: string[] | undefined,
  114441. /**
  114442. * Defines if mipmaps should not be generated (default is false)
  114443. */
  114444. noMipmap?: boolean | undefined,
  114445. /**
  114446. * Defines the explicit list of files (undefined by default)
  114447. */
  114448. files?: string[] | undefined);
  114449. /**
  114450. * Execute the current task
  114451. * @param scene defines the scene where you want your assets to be loaded
  114452. * @param onSuccess is a callback called when the task is successfully executed
  114453. * @param onError is a callback called if an error occurs
  114454. */
  114455. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114456. }
  114457. /**
  114458. * Define a task used by AssetsManager to load HDR cube textures
  114459. */
  114460. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  114461. /**
  114462. * Defines the name of the task
  114463. */
  114464. name: string;
  114465. /**
  114466. * Defines the location of the file to load
  114467. */
  114468. url: string;
  114469. /**
  114470. * Defines the desired size (the more it increases the longer the generation will be)
  114471. */
  114472. size: number;
  114473. /**
  114474. * Defines if mipmaps should not be generated (default is false)
  114475. */
  114476. noMipmap: boolean;
  114477. /**
  114478. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114479. */
  114480. generateHarmonics: boolean;
  114481. /**
  114482. * 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)
  114483. */
  114484. gammaSpace: boolean;
  114485. /**
  114486. * Internal Use Only
  114487. */
  114488. reserved: boolean;
  114489. /**
  114490. * Gets the loaded texture
  114491. */
  114492. texture: HDRCubeTexture;
  114493. /**
  114494. * Callback called when the task is successful
  114495. */
  114496. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  114497. /**
  114498. * Callback called when the task is successful
  114499. */
  114500. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  114501. /**
  114502. * Creates a new HDRCubeTextureAssetTask object
  114503. * @param name defines the name of the task
  114504. * @param url defines the location of the file to load
  114505. * @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.
  114506. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114507. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114508. * @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)
  114509. * @param reserved Internal use only
  114510. */
  114511. constructor(
  114512. /**
  114513. * Defines the name of the task
  114514. */
  114515. name: string,
  114516. /**
  114517. * Defines the location of the file to load
  114518. */
  114519. url: string,
  114520. /**
  114521. * Defines the desired size (the more it increases the longer the generation will be)
  114522. */
  114523. size: number,
  114524. /**
  114525. * Defines if mipmaps should not be generated (default is false)
  114526. */
  114527. noMipmap?: boolean,
  114528. /**
  114529. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114530. */
  114531. generateHarmonics?: boolean,
  114532. /**
  114533. * 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)
  114534. */
  114535. gammaSpace?: boolean,
  114536. /**
  114537. * Internal Use Only
  114538. */
  114539. reserved?: boolean);
  114540. /**
  114541. * Execute the current task
  114542. * @param scene defines the scene where you want your assets to be loaded
  114543. * @param onSuccess is a callback called when the task is successfully executed
  114544. * @param onError is a callback called if an error occurs
  114545. */
  114546. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114547. }
  114548. /**
  114549. * Define a task used by AssetsManager to load Equirectangular cube textures
  114550. */
  114551. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  114552. /**
  114553. * Defines the name of the task
  114554. */
  114555. name: string;
  114556. /**
  114557. * Defines the location of the file to load
  114558. */
  114559. url: string;
  114560. /**
  114561. * Defines the desired size (the more it increases the longer the generation will be)
  114562. */
  114563. size: number;
  114564. /**
  114565. * Defines if mipmaps should not be generated (default is false)
  114566. */
  114567. noMipmap: boolean;
  114568. /**
  114569. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114570. * but the standard material would require them in Gamma space) (default is true)
  114571. */
  114572. gammaSpace: boolean;
  114573. /**
  114574. * Gets the loaded texture
  114575. */
  114576. texture: EquiRectangularCubeTexture;
  114577. /**
  114578. * Callback called when the task is successful
  114579. */
  114580. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  114581. /**
  114582. * Callback called when the task is successful
  114583. */
  114584. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  114585. /**
  114586. * Creates a new EquiRectangularCubeTextureAssetTask object
  114587. * @param name defines the name of the task
  114588. * @param url defines the location of the file to load
  114589. * @param size defines the desired size (the more it increases the longer the generation will be)
  114590. * If the size is omitted this implies you are using a preprocessed cubemap.
  114591. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114592. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  114593. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  114594. * (default is true)
  114595. */
  114596. constructor(
  114597. /**
  114598. * Defines the name of the task
  114599. */
  114600. name: string,
  114601. /**
  114602. * Defines the location of the file to load
  114603. */
  114604. url: string,
  114605. /**
  114606. * Defines the desired size (the more it increases the longer the generation will be)
  114607. */
  114608. size: number,
  114609. /**
  114610. * Defines if mipmaps should not be generated (default is false)
  114611. */
  114612. noMipmap?: boolean,
  114613. /**
  114614. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114615. * but the standard material would require them in Gamma space) (default is true)
  114616. */
  114617. gammaSpace?: boolean);
  114618. /**
  114619. * Execute the current task
  114620. * @param scene defines the scene where you want your assets to be loaded
  114621. * @param onSuccess is a callback called when the task is successfully executed
  114622. * @param onError is a callback called if an error occurs
  114623. */
  114624. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114625. }
  114626. /**
  114627. * This class can be used to easily import assets into a scene
  114628. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  114629. */
  114630. export class AssetsManager {
  114631. private _scene;
  114632. private _isLoading;
  114633. protected _tasks: AbstractAssetTask[];
  114634. protected _waitingTasksCount: number;
  114635. protected _totalTasksCount: number;
  114636. /**
  114637. * Callback called when all tasks are processed
  114638. */
  114639. onFinish: (tasks: AbstractAssetTask[]) => void;
  114640. /**
  114641. * Callback called when a task is successful
  114642. */
  114643. onTaskSuccess: (task: AbstractAssetTask) => void;
  114644. /**
  114645. * Callback called when a task had an error
  114646. */
  114647. onTaskError: (task: AbstractAssetTask) => void;
  114648. /**
  114649. * Callback called when a task is done (whatever the result is)
  114650. */
  114651. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  114652. /**
  114653. * Observable called when all tasks are processed
  114654. */
  114655. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  114656. /**
  114657. * Observable called when a task had an error
  114658. */
  114659. onTaskErrorObservable: Observable<AbstractAssetTask>;
  114660. /**
  114661. * Observable called when all tasks were executed
  114662. */
  114663. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  114664. /**
  114665. * Observable called when a task is done (whatever the result is)
  114666. */
  114667. onProgressObservable: Observable<IAssetsProgressEvent>;
  114668. /**
  114669. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  114670. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114671. */
  114672. useDefaultLoadingScreen: boolean;
  114673. /**
  114674. * Creates a new AssetsManager
  114675. * @param scene defines the scene to work on
  114676. */
  114677. constructor(scene: Scene);
  114678. /**
  114679. * Add a MeshAssetTask to the list of active tasks
  114680. * @param taskName defines the name of the new task
  114681. * @param meshesNames defines the name of meshes to load
  114682. * @param rootUrl defines the root url to use to locate files
  114683. * @param sceneFilename defines the filename of the scene file
  114684. * @returns a new MeshAssetTask object
  114685. */
  114686. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  114687. /**
  114688. * Add a TextFileAssetTask to the list of active tasks
  114689. * @param taskName defines the name of the new task
  114690. * @param url defines the url of the file to load
  114691. * @returns a new TextFileAssetTask object
  114692. */
  114693. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  114694. /**
  114695. * Add a BinaryFileAssetTask to the list of active tasks
  114696. * @param taskName defines the name of the new task
  114697. * @param url defines the url of the file to load
  114698. * @returns a new BinaryFileAssetTask object
  114699. */
  114700. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  114701. /**
  114702. * Add a ImageAssetTask to the list of active tasks
  114703. * @param taskName defines the name of the new task
  114704. * @param url defines the url of the file to load
  114705. * @returns a new ImageAssetTask object
  114706. */
  114707. addImageTask(taskName: string, url: string): ImageAssetTask;
  114708. /**
  114709. * Add a TextureAssetTask to the list of active tasks
  114710. * @param taskName defines the name of the new task
  114711. * @param url defines the url of the file to load
  114712. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114713. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  114714. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114715. * @returns a new TextureAssetTask object
  114716. */
  114717. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  114718. /**
  114719. * Add a CubeTextureAssetTask to the list of active tasks
  114720. * @param taskName defines the name of the new task
  114721. * @param url defines the url of the file to load
  114722. * @param extensions defines the extension to use to load the cube map (can be null)
  114723. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114724. * @param files defines the list of files to load (can be null)
  114725. * @returns a new CubeTextureAssetTask object
  114726. */
  114727. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  114728. /**
  114729. *
  114730. * Add a HDRCubeTextureAssetTask to the list of active tasks
  114731. * @param taskName defines the name of the new task
  114732. * @param url defines the url of the file to load
  114733. * @param size defines the size you want for the cubemap (can be null)
  114734. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114735. * @param generateHarmonics defines if you want to automatically generate (true by default)
  114736. * @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)
  114737. * @param reserved Internal use only
  114738. * @returns a new HDRCubeTextureAssetTask object
  114739. */
  114740. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  114741. /**
  114742. *
  114743. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  114744. * @param taskName defines the name of the new task
  114745. * @param url defines the url of the file to load
  114746. * @param size defines the size you want for the cubemap (can be null)
  114747. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114748. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114749. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114750. * @returns a new EquiRectangularCubeTextureAssetTask object
  114751. */
  114752. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  114753. /**
  114754. * Remove a task from the assets manager.
  114755. * @param task the task to remove
  114756. */
  114757. removeTask(task: AbstractAssetTask): void;
  114758. private _decreaseWaitingTasksCount;
  114759. private _runTask;
  114760. /**
  114761. * Reset the AssetsManager and remove all tasks
  114762. * @return the current instance of the AssetsManager
  114763. */
  114764. reset(): AssetsManager;
  114765. /**
  114766. * Start the loading process
  114767. * @return the current instance of the AssetsManager
  114768. */
  114769. load(): AssetsManager;
  114770. /**
  114771. * Start the loading process as an async operation
  114772. * @return a promise returning the list of failed tasks
  114773. */
  114774. loadAsync(): Promise<void>;
  114775. }
  114776. }
  114777. declare module BABYLON {
  114778. /**
  114779. * Wrapper class for promise with external resolve and reject.
  114780. */
  114781. export class Deferred<T> {
  114782. /**
  114783. * The promise associated with this deferred object.
  114784. */
  114785. readonly promise: Promise<T>;
  114786. private _resolve;
  114787. private _reject;
  114788. /**
  114789. * The resolve method of the promise associated with this deferred object.
  114790. */
  114791. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  114792. /**
  114793. * The reject method of the promise associated with this deferred object.
  114794. */
  114795. readonly reject: (reason?: any) => void;
  114796. /**
  114797. * Constructor for this deferred object.
  114798. */
  114799. constructor();
  114800. }
  114801. }
  114802. declare module BABYLON {
  114803. /**
  114804. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  114805. */
  114806. export class MeshExploder {
  114807. private _centerMesh;
  114808. private _meshes;
  114809. private _meshesOrigins;
  114810. private _toCenterVectors;
  114811. private _scaledDirection;
  114812. private _newPosition;
  114813. private _centerPosition;
  114814. /**
  114815. * Explodes meshes from a center mesh.
  114816. * @param meshes The meshes to explode.
  114817. * @param centerMesh The mesh to be center of explosion.
  114818. */
  114819. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  114820. private _setCenterMesh;
  114821. /**
  114822. * Get class name
  114823. * @returns "MeshExploder"
  114824. */
  114825. getClassName(): string;
  114826. /**
  114827. * "Exploded meshes"
  114828. * @returns Array of meshes with the centerMesh at index 0.
  114829. */
  114830. getMeshes(): Array<Mesh>;
  114831. /**
  114832. * Explodes meshes giving a specific direction
  114833. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  114834. */
  114835. explode(direction?: number): void;
  114836. }
  114837. }
  114838. declare module BABYLON {
  114839. /**
  114840. * Class used to help managing file picking and drag'n'drop
  114841. */
  114842. export class FilesInput {
  114843. /**
  114844. * List of files ready to be loaded
  114845. */
  114846. static readonly FilesToLoad: {
  114847. [key: string]: File;
  114848. };
  114849. /**
  114850. * Callback called when a file is processed
  114851. */
  114852. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  114853. private _engine;
  114854. private _currentScene;
  114855. private _sceneLoadedCallback;
  114856. private _progressCallback;
  114857. private _additionalRenderLoopLogicCallback;
  114858. private _textureLoadingCallback;
  114859. private _startingProcessingFilesCallback;
  114860. private _onReloadCallback;
  114861. private _errorCallback;
  114862. private _elementToMonitor;
  114863. private _sceneFileToLoad;
  114864. private _filesToLoad;
  114865. /**
  114866. * Creates a new FilesInput
  114867. * @param engine defines the rendering engine
  114868. * @param scene defines the hosting scene
  114869. * @param sceneLoadedCallback callback called when scene is loaded
  114870. * @param progressCallback callback called to track progress
  114871. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  114872. * @param textureLoadingCallback callback called when a texture is loading
  114873. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  114874. * @param onReloadCallback callback called when a reload is requested
  114875. * @param errorCallback callback call if an error occurs
  114876. */
  114877. 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);
  114878. private _dragEnterHandler;
  114879. private _dragOverHandler;
  114880. private _dropHandler;
  114881. /**
  114882. * Calls this function to listen to drag'n'drop events on a specific DOM element
  114883. * @param elementToMonitor defines the DOM element to track
  114884. */
  114885. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  114886. /**
  114887. * Release all associated resources
  114888. */
  114889. dispose(): void;
  114890. private renderFunction;
  114891. private drag;
  114892. private drop;
  114893. private _traverseFolder;
  114894. private _processFiles;
  114895. /**
  114896. * Load files from a drop event
  114897. * @param event defines the drop event to use as source
  114898. */
  114899. loadFiles(event: any): void;
  114900. private _processReload;
  114901. /**
  114902. * Reload the current scene from the loaded files
  114903. */
  114904. reload(): void;
  114905. }
  114906. }
  114907. declare module BABYLON {
  114908. /**
  114909. * Defines the root class used to create scene optimization to use with SceneOptimizer
  114910. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114911. */
  114912. export class SceneOptimization {
  114913. /**
  114914. * Defines the priority of this optimization (0 by default which means first in the list)
  114915. */
  114916. priority: number;
  114917. /**
  114918. * Gets a string describing the action executed by the current optimization
  114919. * @returns description string
  114920. */
  114921. getDescription(): string;
  114922. /**
  114923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114924. * @param scene defines the current scene where to apply this optimization
  114925. * @param optimizer defines the current optimizer
  114926. * @returns true if everything that can be done was applied
  114927. */
  114928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114929. /**
  114930. * Creates the SceneOptimization object
  114931. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114932. * @param desc defines the description associated with the optimization
  114933. */
  114934. constructor(
  114935. /**
  114936. * Defines the priority of this optimization (0 by default which means first in the list)
  114937. */
  114938. priority?: number);
  114939. }
  114940. /**
  114941. * Defines an optimization used to reduce the size of render target textures
  114942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114943. */
  114944. export class TextureOptimization extends SceneOptimization {
  114945. /**
  114946. * Defines the priority of this optimization (0 by default which means first in the list)
  114947. */
  114948. priority: number;
  114949. /**
  114950. * 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
  114951. */
  114952. maximumSize: number;
  114953. /**
  114954. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114955. */
  114956. step: number;
  114957. /**
  114958. * Gets a string describing the action executed by the current optimization
  114959. * @returns description string
  114960. */
  114961. getDescription(): string;
  114962. /**
  114963. * Creates the TextureOptimization object
  114964. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114965. * @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
  114966. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114967. */
  114968. constructor(
  114969. /**
  114970. * Defines the priority of this optimization (0 by default which means first in the list)
  114971. */
  114972. priority?: number,
  114973. /**
  114974. * 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
  114975. */
  114976. maximumSize?: number,
  114977. /**
  114978. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114979. */
  114980. step?: number);
  114981. /**
  114982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114983. * @param scene defines the current scene where to apply this optimization
  114984. * @param optimizer defines the current optimizer
  114985. * @returns true if everything that can be done was applied
  114986. */
  114987. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114988. }
  114989. /**
  114990. * Defines an optimization used to increase or decrease the rendering resolution
  114991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114992. */
  114993. export class HardwareScalingOptimization extends SceneOptimization {
  114994. /**
  114995. * Defines the priority of this optimization (0 by default which means first in the list)
  114996. */
  114997. priority: number;
  114998. /**
  114999. * Defines the maximum scale to use (2 by default)
  115000. */
  115001. maximumScale: number;
  115002. /**
  115003. * Defines the step to use between two passes (0.5 by default)
  115004. */
  115005. step: number;
  115006. private _currentScale;
  115007. private _directionOffset;
  115008. /**
  115009. * Gets a string describing the action executed by the current optimization
  115010. * @return description string
  115011. */
  115012. getDescription(): string;
  115013. /**
  115014. * Creates the HardwareScalingOptimization object
  115015. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115016. * @param maximumScale defines the maximum scale to use (2 by default)
  115017. * @param step defines the step to use between two passes (0.5 by default)
  115018. */
  115019. constructor(
  115020. /**
  115021. * Defines the priority of this optimization (0 by default which means first in the list)
  115022. */
  115023. priority?: number,
  115024. /**
  115025. * Defines the maximum scale to use (2 by default)
  115026. */
  115027. maximumScale?: number,
  115028. /**
  115029. * Defines the step to use between two passes (0.5 by default)
  115030. */
  115031. step?: number);
  115032. /**
  115033. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115034. * @param scene defines the current scene where to apply this optimization
  115035. * @param optimizer defines the current optimizer
  115036. * @returns true if everything that can be done was applied
  115037. */
  115038. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115039. }
  115040. /**
  115041. * Defines an optimization used to remove shadows
  115042. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115043. */
  115044. export class ShadowsOptimization extends SceneOptimization {
  115045. /**
  115046. * Gets a string describing the action executed by the current optimization
  115047. * @return description string
  115048. */
  115049. getDescription(): string;
  115050. /**
  115051. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115052. * @param scene defines the current scene where to apply this optimization
  115053. * @param optimizer defines the current optimizer
  115054. * @returns true if everything that can be done was applied
  115055. */
  115056. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115057. }
  115058. /**
  115059. * Defines an optimization used to turn post-processes off
  115060. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115061. */
  115062. export class PostProcessesOptimization extends SceneOptimization {
  115063. /**
  115064. * Gets a string describing the action executed by the current optimization
  115065. * @return description string
  115066. */
  115067. getDescription(): string;
  115068. /**
  115069. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115070. * @param scene defines the current scene where to apply this optimization
  115071. * @param optimizer defines the current optimizer
  115072. * @returns true if everything that can be done was applied
  115073. */
  115074. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115075. }
  115076. /**
  115077. * Defines an optimization used to turn lens flares off
  115078. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115079. */
  115080. export class LensFlaresOptimization extends SceneOptimization {
  115081. /**
  115082. * Gets a string describing the action executed by the current optimization
  115083. * @return description string
  115084. */
  115085. getDescription(): string;
  115086. /**
  115087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115088. * @param scene defines the current scene where to apply this optimization
  115089. * @param optimizer defines the current optimizer
  115090. * @returns true if everything that can be done was applied
  115091. */
  115092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115093. }
  115094. /**
  115095. * Defines an optimization based on user defined callback.
  115096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115097. */
  115098. export class CustomOptimization extends SceneOptimization {
  115099. /**
  115100. * Callback called to apply the custom optimization.
  115101. */
  115102. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  115103. /**
  115104. * Callback called to get custom description
  115105. */
  115106. onGetDescription: () => string;
  115107. /**
  115108. * Gets a string describing the action executed by the current optimization
  115109. * @returns description string
  115110. */
  115111. getDescription(): string;
  115112. /**
  115113. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115114. * @param scene defines the current scene where to apply this optimization
  115115. * @param optimizer defines the current optimizer
  115116. * @returns true if everything that can be done was applied
  115117. */
  115118. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115119. }
  115120. /**
  115121. * Defines an optimization used to turn particles off
  115122. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115123. */
  115124. export class ParticlesOptimization extends SceneOptimization {
  115125. /**
  115126. * Gets a string describing the action executed by the current optimization
  115127. * @return description string
  115128. */
  115129. getDescription(): string;
  115130. /**
  115131. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115132. * @param scene defines the current scene where to apply this optimization
  115133. * @param optimizer defines the current optimizer
  115134. * @returns true if everything that can be done was applied
  115135. */
  115136. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115137. }
  115138. /**
  115139. * Defines an optimization used to turn render targets off
  115140. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115141. */
  115142. export class RenderTargetsOptimization extends SceneOptimization {
  115143. /**
  115144. * Gets a string describing the action executed by the current optimization
  115145. * @return description string
  115146. */
  115147. getDescription(): string;
  115148. /**
  115149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115150. * @param scene defines the current scene where to apply this optimization
  115151. * @param optimizer defines the current optimizer
  115152. * @returns true if everything that can be done was applied
  115153. */
  115154. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115155. }
  115156. /**
  115157. * Defines an optimization used to merge meshes with compatible materials
  115158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115159. */
  115160. export class MergeMeshesOptimization extends SceneOptimization {
  115161. private static _UpdateSelectionTree;
  115162. /**
  115163. * Gets or sets a boolean which defines if optimization octree has to be updated
  115164. */
  115165. /**
  115166. * Gets or sets a boolean which defines if optimization octree has to be updated
  115167. */
  115168. static UpdateSelectionTree: boolean;
  115169. /**
  115170. * Gets a string describing the action executed by the current optimization
  115171. * @return description string
  115172. */
  115173. getDescription(): string;
  115174. private _canBeMerged;
  115175. /**
  115176. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115177. * @param scene defines the current scene where to apply this optimization
  115178. * @param optimizer defines the current optimizer
  115179. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  115180. * @returns true if everything that can be done was applied
  115181. */
  115182. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  115183. }
  115184. /**
  115185. * Defines a list of options used by SceneOptimizer
  115186. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115187. */
  115188. export class SceneOptimizerOptions {
  115189. /**
  115190. * Defines the target frame rate to reach (60 by default)
  115191. */
  115192. targetFrameRate: number;
  115193. /**
  115194. * Defines the interval between two checkes (2000ms by default)
  115195. */
  115196. trackerDuration: number;
  115197. /**
  115198. * Gets the list of optimizations to apply
  115199. */
  115200. optimizations: SceneOptimization[];
  115201. /**
  115202. * Creates a new list of options used by SceneOptimizer
  115203. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  115204. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  115205. */
  115206. constructor(
  115207. /**
  115208. * Defines the target frame rate to reach (60 by default)
  115209. */
  115210. targetFrameRate?: number,
  115211. /**
  115212. * Defines the interval between two checkes (2000ms by default)
  115213. */
  115214. trackerDuration?: number);
  115215. /**
  115216. * Add a new optimization
  115217. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  115218. * @returns the current SceneOptimizerOptions
  115219. */
  115220. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  115221. /**
  115222. * Add a new custom optimization
  115223. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  115224. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  115225. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115226. * @returns the current SceneOptimizerOptions
  115227. */
  115228. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  115229. /**
  115230. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  115231. * @param targetFrameRate defines the target frame rate (60 by default)
  115232. * @returns a SceneOptimizerOptions object
  115233. */
  115234. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115235. /**
  115236. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  115237. * @param targetFrameRate defines the target frame rate (60 by default)
  115238. * @returns a SceneOptimizerOptions object
  115239. */
  115240. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115241. /**
  115242. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  115243. * @param targetFrameRate defines the target frame rate (60 by default)
  115244. * @returns a SceneOptimizerOptions object
  115245. */
  115246. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115247. }
  115248. /**
  115249. * Class used to run optimizations in order to reach a target frame rate
  115250. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115251. */
  115252. export class SceneOptimizer implements IDisposable {
  115253. private _isRunning;
  115254. private _options;
  115255. private _scene;
  115256. private _currentPriorityLevel;
  115257. private _targetFrameRate;
  115258. private _trackerDuration;
  115259. private _currentFrameRate;
  115260. private _sceneDisposeObserver;
  115261. private _improvementMode;
  115262. /**
  115263. * Defines an observable called when the optimizer reaches the target frame rate
  115264. */
  115265. onSuccessObservable: Observable<SceneOptimizer>;
  115266. /**
  115267. * Defines an observable called when the optimizer enables an optimization
  115268. */
  115269. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  115270. /**
  115271. * Defines an observable called when the optimizer is not able to reach the target frame rate
  115272. */
  115273. onFailureObservable: Observable<SceneOptimizer>;
  115274. /**
  115275. * Gets a boolean indicating if the optimizer is in improvement mode
  115276. */
  115277. readonly isInImprovementMode: boolean;
  115278. /**
  115279. * Gets the current priority level (0 at start)
  115280. */
  115281. readonly currentPriorityLevel: number;
  115282. /**
  115283. * Gets the current frame rate checked by the SceneOptimizer
  115284. */
  115285. readonly currentFrameRate: number;
  115286. /**
  115287. * Gets or sets the current target frame rate (60 by default)
  115288. */
  115289. /**
  115290. * Gets or sets the current target frame rate (60 by default)
  115291. */
  115292. targetFrameRate: number;
  115293. /**
  115294. * Gets or sets the current interval between two checks (every 2000ms by default)
  115295. */
  115296. /**
  115297. * Gets or sets the current interval between two checks (every 2000ms by default)
  115298. */
  115299. trackerDuration: number;
  115300. /**
  115301. * Gets the list of active optimizations
  115302. */
  115303. readonly optimizations: SceneOptimization[];
  115304. /**
  115305. * Creates a new SceneOptimizer
  115306. * @param scene defines the scene to work on
  115307. * @param options defines the options to use with the SceneOptimizer
  115308. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  115309. * @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)
  115310. */
  115311. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  115312. /**
  115313. * Stops the current optimizer
  115314. */
  115315. stop(): void;
  115316. /**
  115317. * Reset the optimizer to initial step (current priority level = 0)
  115318. */
  115319. reset(): void;
  115320. /**
  115321. * Start the optimizer. By default it will try to reach a specific framerate
  115322. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  115323. */
  115324. start(): void;
  115325. private _checkCurrentState;
  115326. /**
  115327. * Release all resources
  115328. */
  115329. dispose(): void;
  115330. /**
  115331. * Helper function to create a SceneOptimizer with one single line of code
  115332. * @param scene defines the scene to work on
  115333. * @param options defines the options to use with the SceneOptimizer
  115334. * @param onSuccess defines a callback to call on success
  115335. * @param onFailure defines a callback to call on failure
  115336. * @returns the new SceneOptimizer object
  115337. */
  115338. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  115339. }
  115340. }
  115341. declare module BABYLON {
  115342. /**
  115343. * Class used to serialize a scene into a string
  115344. */
  115345. export class SceneSerializer {
  115346. /**
  115347. * Clear cache used by a previous serialization
  115348. */
  115349. static ClearCache(): void;
  115350. /**
  115351. * Serialize a scene into a JSON compatible object
  115352. * @param scene defines the scene to serialize
  115353. * @returns a JSON compatible object
  115354. */
  115355. static Serialize(scene: Scene): any;
  115356. /**
  115357. * Serialize a mesh into a JSON compatible object
  115358. * @param toSerialize defines the mesh to serialize
  115359. * @param withParents defines if parents must be serialized as well
  115360. * @param withChildren defines if children must be serialized as well
  115361. * @returns a JSON compatible object
  115362. */
  115363. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  115364. }
  115365. }
  115366. declare module BABYLON {
  115367. /**
  115368. * Class used to host texture specific utilities
  115369. */
  115370. export class TextureTools {
  115371. /**
  115372. * Uses the GPU to create a copy texture rescaled at a given size
  115373. * @param texture Texture to copy from
  115374. * @param width defines the desired width
  115375. * @param height defines the desired height
  115376. * @param useBilinearMode defines if bilinear mode has to be used
  115377. * @return the generated texture
  115378. */
  115379. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  115380. }
  115381. }
  115382. declare module BABYLON {
  115383. /**
  115384. * This represents the different options avilable for the video capture.
  115385. */
  115386. export interface VideoRecorderOptions {
  115387. /** Defines the mime type of the video */
  115388. mimeType: string;
  115389. /** Defines the video the video should be recorded at */
  115390. fps: number;
  115391. /** Defines the chunk size for the recording data */
  115392. recordChunckSize: number;
  115393. /** The audio tracks to attach to the record */
  115394. audioTracks?: MediaStreamTrack[];
  115395. }
  115396. /**
  115397. * This can helps recording videos from BabylonJS.
  115398. * This is based on the available WebRTC functionalities of the browser.
  115399. *
  115400. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  115401. */
  115402. export class VideoRecorder {
  115403. private static readonly _defaultOptions;
  115404. /**
  115405. * Returns wehther or not the VideoRecorder is available in your browser.
  115406. * @param engine Defines the Babylon Engine to check the support for
  115407. * @returns true if supported otherwise false
  115408. */
  115409. static IsSupported(engine: Engine): boolean;
  115410. private readonly _options;
  115411. private _canvas;
  115412. private _mediaRecorder;
  115413. private _recordedChunks;
  115414. private _fileName;
  115415. private _resolve;
  115416. private _reject;
  115417. /**
  115418. * True wether a recording is already in progress.
  115419. */
  115420. readonly isRecording: boolean;
  115421. /**
  115422. * Create a new VideoCapture object which can help converting what you see in Babylon to
  115423. * a video file.
  115424. * @param engine Defines the BabylonJS Engine you wish to record
  115425. * @param options Defines options that can be used to customized the capture
  115426. */
  115427. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  115428. /**
  115429. * Stops the current recording before the default capture timeout passed in the startRecording
  115430. * functions.
  115431. */
  115432. stopRecording(): void;
  115433. /**
  115434. * Starts recording the canvas for a max duration specified in parameters.
  115435. * @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.
  115436. * @param maxDuration Defines the maximum recording time in seconds.
  115437. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  115438. * @return a promise callback at the end of the recording with the video data in Blob.
  115439. */
  115440. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  115441. /**
  115442. * Releases internal resources used during the recording.
  115443. */
  115444. dispose(): void;
  115445. private _handleDataAvailable;
  115446. private _handleError;
  115447. private _handleStop;
  115448. }
  115449. }
  115450. declare module BABYLON {
  115451. /**
  115452. * Class containing a set of static utilities functions for screenshots
  115453. */
  115454. export class ScreenshotTools {
  115455. /**
  115456. * Captures a screenshot of the current rendering
  115457. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115458. * @param engine defines the rendering engine
  115459. * @param camera defines the source camera
  115460. * @param size This parameter can be set to a single number or to an object with the
  115461. * following (optional) properties: precision, width, height. If a single number is passed,
  115462. * it will be used for both width and height. If an object is passed, the screenshot size
  115463. * will be derived from the parameters. The precision property is a multiplier allowing
  115464. * rendering at a higher or lower resolution
  115465. * @param successCallback defines the callback receives a single parameter which contains the
  115466. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115467. * src parameter of an <img> to display it
  115468. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115469. * Check your browser for supported MIME types
  115470. */
  115471. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  115472. /**
  115473. * Generates an image screenshot from the specified camera.
  115474. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115475. * @param engine The engine to use for rendering
  115476. * @param camera The camera to use for rendering
  115477. * @param size This parameter can be set to a single number or to an object with the
  115478. * following (optional) properties: precision, width, height. If a single number is passed,
  115479. * it will be used for both width and height. If an object is passed, the screenshot size
  115480. * will be derived from the parameters. The precision property is a multiplier allowing
  115481. * rendering at a higher or lower resolution
  115482. * @param successCallback The callback receives a single parameter which contains the
  115483. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115484. * src parameter of an <img> to display it
  115485. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115486. * Check your browser for supported MIME types
  115487. * @param samples Texture samples (default: 1)
  115488. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115489. * @param fileName A name for for the downloaded file.
  115490. */
  115491. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115492. }
  115493. }
  115494. declare module BABYLON {
  115495. /**
  115496. * A cursor which tracks a point on a path
  115497. */
  115498. export class PathCursor {
  115499. private path;
  115500. /**
  115501. * Stores path cursor callbacks for when an onchange event is triggered
  115502. */
  115503. private _onchange;
  115504. /**
  115505. * The value of the path cursor
  115506. */
  115507. value: number;
  115508. /**
  115509. * The animation array of the path cursor
  115510. */
  115511. animations: Animation[];
  115512. /**
  115513. * Initializes the path cursor
  115514. * @param path The path to track
  115515. */
  115516. constructor(path: Path2);
  115517. /**
  115518. * Gets the cursor point on the path
  115519. * @returns A point on the path cursor at the cursor location
  115520. */
  115521. getPoint(): Vector3;
  115522. /**
  115523. * Moves the cursor ahead by the step amount
  115524. * @param step The amount to move the cursor forward
  115525. * @returns This path cursor
  115526. */
  115527. moveAhead(step?: number): PathCursor;
  115528. /**
  115529. * Moves the cursor behind by the step amount
  115530. * @param step The amount to move the cursor back
  115531. * @returns This path cursor
  115532. */
  115533. moveBack(step?: number): PathCursor;
  115534. /**
  115535. * Moves the cursor by the step amount
  115536. * If the step amount is greater than one, an exception is thrown
  115537. * @param step The amount to move the cursor
  115538. * @returns This path cursor
  115539. */
  115540. move(step: number): PathCursor;
  115541. /**
  115542. * Ensures that the value is limited between zero and one
  115543. * @returns This path cursor
  115544. */
  115545. private ensureLimits;
  115546. /**
  115547. * Runs onchange callbacks on change (used by the animation engine)
  115548. * @returns This path cursor
  115549. */
  115550. private raiseOnChange;
  115551. /**
  115552. * Executes a function on change
  115553. * @param f A path cursor onchange callback
  115554. * @returns This path cursor
  115555. */
  115556. onchange(f: (cursor: PathCursor) => void): PathCursor;
  115557. }
  115558. }
  115559. declare module BABYLON {
  115560. /** @hidden */
  115561. export var blurPixelShader: {
  115562. name: string;
  115563. shader: string;
  115564. };
  115565. }
  115566. declare module BABYLON {
  115567. /** @hidden */
  115568. export var bones300Declaration: {
  115569. name: string;
  115570. shader: string;
  115571. };
  115572. }
  115573. declare module BABYLON {
  115574. /** @hidden */
  115575. export var instances300Declaration: {
  115576. name: string;
  115577. shader: string;
  115578. };
  115579. }
  115580. declare module BABYLON {
  115581. /** @hidden */
  115582. export var pointCloudVertexDeclaration: {
  115583. name: string;
  115584. shader: string;
  115585. };
  115586. }
  115587. // Mixins
  115588. interface Window {
  115589. mozIndexedDB: IDBFactory;
  115590. webkitIndexedDB: IDBFactory;
  115591. msIndexedDB: IDBFactory;
  115592. webkitURL: typeof URL;
  115593. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  115594. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  115595. WebGLRenderingContext: WebGLRenderingContext;
  115596. MSGesture: MSGesture;
  115597. CANNON: any;
  115598. AudioContext: AudioContext;
  115599. webkitAudioContext: AudioContext;
  115600. PointerEvent: any;
  115601. Math: Math;
  115602. Uint8Array: Uint8ArrayConstructor;
  115603. Float32Array: Float32ArrayConstructor;
  115604. mozURL: typeof URL;
  115605. msURL: typeof URL;
  115606. VRFrameData: any; // WebVR, from specs 1.1
  115607. DracoDecoderModule: any;
  115608. setImmediate(handler: (...args: any[]) => void): number;
  115609. }
  115610. interface HTMLCanvasElement {
  115611. requestPointerLock(): void;
  115612. msRequestPointerLock?(): void;
  115613. mozRequestPointerLock?(): void;
  115614. webkitRequestPointerLock?(): void;
  115615. /** Track wether a record is in progress */
  115616. isRecording: boolean;
  115617. /** Capture Stream method defined by some browsers */
  115618. captureStream(fps?: number): MediaStream;
  115619. }
  115620. interface CanvasRenderingContext2D {
  115621. msImageSmoothingEnabled: boolean;
  115622. }
  115623. interface MouseEvent {
  115624. mozMovementX: number;
  115625. mozMovementY: number;
  115626. webkitMovementX: number;
  115627. webkitMovementY: number;
  115628. msMovementX: number;
  115629. msMovementY: number;
  115630. }
  115631. interface Navigator {
  115632. mozGetVRDevices: (any: any) => any;
  115633. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115634. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115635. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115636. webkitGetGamepads(): Gamepad[];
  115637. msGetGamepads(): Gamepad[];
  115638. webkitGamepads(): Gamepad[];
  115639. }
  115640. interface HTMLVideoElement {
  115641. mozSrcObject: any;
  115642. }
  115643. interface Math {
  115644. fround(x: number): number;
  115645. imul(a: number, b: number): number;
  115646. }
  115647. interface WebGLProgram {
  115648. context?: WebGLRenderingContext;
  115649. vertexShader?: WebGLShader;
  115650. fragmentShader?: WebGLShader;
  115651. isParallelCompiled: boolean;
  115652. onCompiled?: () => void;
  115653. }
  115654. interface WebGLRenderingContext {
  115655. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  115656. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  115657. vertexAttribDivisor(index: number, divisor: number): void;
  115658. createVertexArray(): any;
  115659. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  115660. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  115661. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  115662. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  115663. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  115664. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  115665. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  115666. // Queries
  115667. createQuery(): WebGLQuery;
  115668. deleteQuery(query: WebGLQuery): void;
  115669. beginQuery(target: number, query: WebGLQuery): void;
  115670. endQuery(target: number): void;
  115671. getQueryParameter(query: WebGLQuery, pname: number): any;
  115672. getQuery(target: number, pname: number): any;
  115673. MAX_SAMPLES: number;
  115674. RGBA8: number;
  115675. READ_FRAMEBUFFER: number;
  115676. DRAW_FRAMEBUFFER: number;
  115677. UNIFORM_BUFFER: number;
  115678. HALF_FLOAT_OES: number;
  115679. RGBA16F: number;
  115680. RGBA32F: number;
  115681. R32F: number;
  115682. RG32F: number;
  115683. RGB32F: number;
  115684. R16F: number;
  115685. RG16F: number;
  115686. RGB16F: number;
  115687. RED: number;
  115688. RG: number;
  115689. R8: number;
  115690. RG8: number;
  115691. UNSIGNED_INT_24_8: number;
  115692. DEPTH24_STENCIL8: number;
  115693. /* Multiple Render Targets */
  115694. drawBuffers(buffers: number[]): void;
  115695. readBuffer(src: number): void;
  115696. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  115697. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  115698. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  115699. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  115700. // Occlusion Query
  115701. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  115702. ANY_SAMPLES_PASSED: number;
  115703. QUERY_RESULT_AVAILABLE: number;
  115704. QUERY_RESULT: number;
  115705. }
  115706. interface WebGLBuffer {
  115707. references: number;
  115708. capacity: number;
  115709. is32Bits: boolean;
  115710. }
  115711. interface WebGLProgram {
  115712. transformFeedback?: WebGLTransformFeedback | null;
  115713. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  115714. }
  115715. interface EXT_disjoint_timer_query {
  115716. QUERY_COUNTER_BITS_EXT: number;
  115717. TIME_ELAPSED_EXT: number;
  115718. TIMESTAMP_EXT: number;
  115719. GPU_DISJOINT_EXT: number;
  115720. QUERY_RESULT_EXT: number;
  115721. QUERY_RESULT_AVAILABLE_EXT: number;
  115722. queryCounterEXT(query: WebGLQuery, target: number): void;
  115723. createQueryEXT(): WebGLQuery;
  115724. beginQueryEXT(target: number, query: WebGLQuery): void;
  115725. endQueryEXT(target: number): void;
  115726. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  115727. deleteQueryEXT(query: WebGLQuery): void;
  115728. }
  115729. interface WebGLUniformLocation {
  115730. _currentState: any;
  115731. }
  115732. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  115733. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  115734. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  115735. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115736. interface WebGLRenderingContext {
  115737. readonly RASTERIZER_DISCARD: number;
  115738. readonly DEPTH_COMPONENT24: number;
  115739. readonly TEXTURE_3D: number;
  115740. readonly TEXTURE_2D_ARRAY: number;
  115741. readonly TEXTURE_COMPARE_FUNC: number;
  115742. readonly TEXTURE_COMPARE_MODE: number;
  115743. readonly COMPARE_REF_TO_TEXTURE: number;
  115744. readonly TEXTURE_WRAP_R: number;
  115745. readonly HALF_FLOAT: number;
  115746. readonly RGB8: number;
  115747. readonly RED_INTEGER: number;
  115748. readonly RG_INTEGER: number;
  115749. readonly RGB_INTEGER: number;
  115750. readonly RGBA_INTEGER: number;
  115751. readonly R8_SNORM: number;
  115752. readonly RG8_SNORM: number;
  115753. readonly RGB8_SNORM: number;
  115754. readonly RGBA8_SNORM: number;
  115755. readonly R8I: number;
  115756. readonly RG8I: number;
  115757. readonly RGB8I: number;
  115758. readonly RGBA8I: number;
  115759. readonly R8UI: number;
  115760. readonly RG8UI: number;
  115761. readonly RGB8UI: number;
  115762. readonly RGBA8UI: number;
  115763. readonly R16I: number;
  115764. readonly RG16I: number;
  115765. readonly RGB16I: number;
  115766. readonly RGBA16I: number;
  115767. readonly R16UI: number;
  115768. readonly RG16UI: number;
  115769. readonly RGB16UI: number;
  115770. readonly RGBA16UI: number;
  115771. readonly R32I: number;
  115772. readonly RG32I: number;
  115773. readonly RGB32I: number;
  115774. readonly RGBA32I: number;
  115775. readonly R32UI: number;
  115776. readonly RG32UI: number;
  115777. readonly RGB32UI: number;
  115778. readonly RGBA32UI: number;
  115779. readonly RGB10_A2UI: number;
  115780. readonly R11F_G11F_B10F: number;
  115781. readonly RGB9_E5: number;
  115782. readonly RGB10_A2: number;
  115783. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  115784. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  115785. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  115786. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115787. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  115788. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  115789. 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;
  115790. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  115791. readonly TRANSFORM_FEEDBACK: number;
  115792. readonly INTERLEAVED_ATTRIBS: number;
  115793. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  115794. createTransformFeedback(): WebGLTransformFeedback;
  115795. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  115796. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  115797. beginTransformFeedback(primitiveMode: number): void;
  115798. endTransformFeedback(): void;
  115799. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  115800. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115801. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115802. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115803. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  115804. }
  115805. interface ImageBitmap {
  115806. readonly width: number;
  115807. readonly height: number;
  115808. close(): void;
  115809. }
  115810. interface WebGLQuery extends WebGLObject {
  115811. }
  115812. declare var WebGLQuery: {
  115813. prototype: WebGLQuery;
  115814. new(): WebGLQuery;
  115815. };
  115816. interface WebGLSampler extends WebGLObject {
  115817. }
  115818. declare var WebGLSampler: {
  115819. prototype: WebGLSampler;
  115820. new(): WebGLSampler;
  115821. };
  115822. interface WebGLSync extends WebGLObject {
  115823. }
  115824. declare var WebGLSync: {
  115825. prototype: WebGLSync;
  115826. new(): WebGLSync;
  115827. };
  115828. interface WebGLTransformFeedback extends WebGLObject {
  115829. }
  115830. declare var WebGLTransformFeedback: {
  115831. prototype: WebGLTransformFeedback;
  115832. new(): WebGLTransformFeedback;
  115833. };
  115834. interface WebGLVertexArrayObject extends WebGLObject {
  115835. }
  115836. declare var WebGLVertexArrayObject: {
  115837. prototype: WebGLVertexArrayObject;
  115838. new(): WebGLVertexArrayObject;
  115839. };
  115840. // Type definitions for WebVR API
  115841. // Project: https://w3c.github.io/webvr/
  115842. // Definitions by: six a <https://github.com/lostfictions>
  115843. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115844. interface VRDisplay extends EventTarget {
  115845. /**
  115846. * Dictionary of capabilities describing the VRDisplay.
  115847. */
  115848. readonly capabilities: VRDisplayCapabilities;
  115849. /**
  115850. * z-depth defining the far plane of the eye view frustum
  115851. * enables mapping of values in the render target depth
  115852. * attachment to scene coordinates. Initially set to 10000.0.
  115853. */
  115854. depthFar: number;
  115855. /**
  115856. * z-depth defining the near plane of the eye view frustum
  115857. * enables mapping of values in the render target depth
  115858. * attachment to scene coordinates. Initially set to 0.01.
  115859. */
  115860. depthNear: number;
  115861. /**
  115862. * An identifier for this distinct VRDisplay. Used as an
  115863. * association point in the Gamepad API.
  115864. */
  115865. readonly displayId: number;
  115866. /**
  115867. * A display name, a user-readable name identifying it.
  115868. */
  115869. readonly displayName: string;
  115870. readonly isConnected: boolean;
  115871. readonly isPresenting: boolean;
  115872. /**
  115873. * If this VRDisplay supports room-scale experiences, the optional
  115874. * stage attribute contains details on the room-scale parameters.
  115875. */
  115876. readonly stageParameters: VRStageParameters | null;
  115877. /**
  115878. * Passing the value returned by `requestAnimationFrame` to
  115879. * `cancelAnimationFrame` will unregister the callback.
  115880. * @param handle Define the hanle of the request to cancel
  115881. */
  115882. cancelAnimationFrame(handle: number): void;
  115883. /**
  115884. * Stops presenting to the VRDisplay.
  115885. * @returns a promise to know when it stopped
  115886. */
  115887. exitPresent(): Promise<void>;
  115888. /**
  115889. * Return the current VREyeParameters for the given eye.
  115890. * @param whichEye Define the eye we want the parameter for
  115891. * @returns the eye parameters
  115892. */
  115893. getEyeParameters(whichEye: string): VREyeParameters;
  115894. /**
  115895. * Populates the passed VRFrameData with the information required to render
  115896. * the current frame.
  115897. * @param frameData Define the data structure to populate
  115898. * @returns true if ok otherwise false
  115899. */
  115900. getFrameData(frameData: VRFrameData): boolean;
  115901. /**
  115902. * Get the layers currently being presented.
  115903. * @returns the list of VR layers
  115904. */
  115905. getLayers(): VRLayer[];
  115906. /**
  115907. * Return a VRPose containing the future predicted pose of the VRDisplay
  115908. * when the current frame will be presented. The value returned will not
  115909. * change until JavaScript has returned control to the browser.
  115910. *
  115911. * The VRPose will contain the position, orientation, velocity,
  115912. * and acceleration of each of these properties.
  115913. * @returns the pose object
  115914. */
  115915. getPose(): VRPose;
  115916. /**
  115917. * Return the current instantaneous pose of the VRDisplay, with no
  115918. * prediction applied.
  115919. * @returns the current instantaneous pose
  115920. */
  115921. getImmediatePose(): VRPose;
  115922. /**
  115923. * The callback passed to `requestAnimationFrame` will be called
  115924. * any time a new frame should be rendered. When the VRDisplay is
  115925. * presenting the callback will be called at the native refresh
  115926. * rate of the HMD. When not presenting this function acts
  115927. * identically to how window.requestAnimationFrame acts. Content should
  115928. * make no assumptions of frame rate or vsync behavior as the HMD runs
  115929. * asynchronously from other displays and at differing refresh rates.
  115930. * @param callback Define the eaction to run next frame
  115931. * @returns the request handle it
  115932. */
  115933. requestAnimationFrame(callback: FrameRequestCallback): number;
  115934. /**
  115935. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  115936. * Repeat calls while already presenting will update the VRLayers being displayed.
  115937. * @param layers Define the list of layer to present
  115938. * @returns a promise to know when the request has been fulfilled
  115939. */
  115940. requestPresent(layers: VRLayer[]): Promise<void>;
  115941. /**
  115942. * Reset the pose for this display, treating its current position and
  115943. * orientation as the "origin/zero" values. VRPose.position,
  115944. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  115945. * updated when calling resetPose(). This should be called in only
  115946. * sitting-space experiences.
  115947. */
  115948. resetPose(): void;
  115949. /**
  115950. * The VRLayer provided to the VRDisplay will be captured and presented
  115951. * in the HMD. Calling this function has the same effect on the source
  115952. * canvas as any other operation that uses its source image, and canvases
  115953. * created without preserveDrawingBuffer set to true will be cleared.
  115954. * @param pose Define the pose to submit
  115955. */
  115956. submitFrame(pose?: VRPose): void;
  115957. }
  115958. declare var VRDisplay: {
  115959. prototype: VRDisplay;
  115960. new(): VRDisplay;
  115961. };
  115962. interface VRLayer {
  115963. leftBounds?: number[] | Float32Array | null;
  115964. rightBounds?: number[] | Float32Array | null;
  115965. source?: HTMLCanvasElement | null;
  115966. }
  115967. interface VRDisplayCapabilities {
  115968. readonly canPresent: boolean;
  115969. readonly hasExternalDisplay: boolean;
  115970. readonly hasOrientation: boolean;
  115971. readonly hasPosition: boolean;
  115972. readonly maxLayers: number;
  115973. }
  115974. interface VREyeParameters {
  115975. /** @deprecated */
  115976. readonly fieldOfView: VRFieldOfView;
  115977. readonly offset: Float32Array;
  115978. readonly renderHeight: number;
  115979. readonly renderWidth: number;
  115980. }
  115981. interface VRFieldOfView {
  115982. readonly downDegrees: number;
  115983. readonly leftDegrees: number;
  115984. readonly rightDegrees: number;
  115985. readonly upDegrees: number;
  115986. }
  115987. interface VRFrameData {
  115988. readonly leftProjectionMatrix: Float32Array;
  115989. readonly leftViewMatrix: Float32Array;
  115990. readonly pose: VRPose;
  115991. readonly rightProjectionMatrix: Float32Array;
  115992. readonly rightViewMatrix: Float32Array;
  115993. readonly timestamp: number;
  115994. }
  115995. interface VRPose {
  115996. readonly angularAcceleration: Float32Array | null;
  115997. readonly angularVelocity: Float32Array | null;
  115998. readonly linearAcceleration: Float32Array | null;
  115999. readonly linearVelocity: Float32Array | null;
  116000. readonly orientation: Float32Array | null;
  116001. readonly position: Float32Array | null;
  116002. readonly timestamp: number;
  116003. }
  116004. interface VRStageParameters {
  116005. sittingToStandingTransform?: Float32Array;
  116006. sizeX?: number;
  116007. sizeY?: number;
  116008. }
  116009. interface Navigator {
  116010. getVRDisplays(): Promise<VRDisplay[]>;
  116011. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116012. }
  116013. interface Window {
  116014. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116015. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116016. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116017. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116018. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116019. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116020. }
  116021. interface Gamepad {
  116022. readonly displayId: number;
  116023. }
  116024. interface XRDevice {
  116025. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116026. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116027. }
  116028. interface XRSession {
  116029. getInputSources(): Array<any>;
  116030. baseLayer: XRWebGLLayer;
  116031. requestFrameOfReference(type: string): Promise<void>;
  116032. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116033. end(): Promise<void>;
  116034. requestAnimationFrame: Function;
  116035. addEventListener: Function;
  116036. }
  116037. interface XRSessionCreationOptions {
  116038. outputContext?: WebGLRenderingContext | null;
  116039. immersive?: boolean;
  116040. environmentIntegration?: boolean;
  116041. }
  116042. interface XRLayer {
  116043. getViewport: Function;
  116044. framebufferWidth: number;
  116045. framebufferHeight: number;
  116046. }
  116047. interface XRView {
  116048. projectionMatrix: Float32Array;
  116049. }
  116050. interface XRFrame {
  116051. getDevicePose: Function;
  116052. getInputPose: Function;
  116053. views: Array<XRView>;
  116054. baseLayer: XRLayer;
  116055. }
  116056. interface XRFrameOfReference {
  116057. }
  116058. interface XRWebGLLayer extends XRLayer {
  116059. framebuffer: WebGLFramebuffer;
  116060. }
  116061. declare var XRWebGLLayer: {
  116062. prototype: XRWebGLLayer;
  116063. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  116064. };